@tanstack/angular-query 5.0.0-rc.3 → 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.
Files changed (70) hide show
  1. package/hydration-state-key.mjs +10 -13
  2. package/hydration-state-key.mjs.map +1 -1
  3. package/index.mjs +8 -20
  4. package/index.mjs.map +1 -1
  5. package/infinite-query-options.d.ts +7 -18
  6. package/infinite-query-options.mjs +6 -5
  7. package/infinite-query-options.mjs.map +1 -1
  8. package/inject-base-query.d.ts +3 -0
  9. package/inject-base-query.mjs +62 -58
  10. package/inject-base-query.mjs.map +1 -1
  11. package/inject-infinite-query.d.ts +7 -11
  12. package/inject-infinite-query.mjs +16 -32
  13. package/inject-infinite-query.mjs.map +1 -1
  14. package/inject-is-fetching.d.ts +1 -1
  15. package/inject-is-fetching.mjs +22 -15
  16. package/inject-is-fetching.mjs.map +1 -1
  17. package/inject-is-mutating.d.ts +1 -1
  18. package/inject-is-mutating.mjs +22 -15
  19. package/inject-is-mutating.mjs.map +1 -1
  20. package/inject-is-restoring.d.ts +2 -0
  21. package/inject-is-restoring.mjs +28 -17
  22. package/inject-is-restoring.mjs.map +1 -1
  23. package/inject-mutation-state.d.ts +9 -0
  24. package/inject-mutation-state.mjs +25 -23
  25. package/inject-mutation-state.mjs.map +1 -1
  26. package/inject-mutation.d.ts +2 -4
  27. package/inject-mutation.mjs +87 -67
  28. package/inject-mutation.mjs.map +1 -1
  29. package/inject-queries.d.ts +1 -3
  30. package/inject-queries.mjs +122 -114
  31. package/inject-queries.mjs.map +1 -1
  32. package/inject-queries.types.d.ts +17 -1
  33. package/inject-query.d.ts +7 -13
  34. package/inject-query.mjs +11 -14
  35. package/inject-query.mjs.map +1 -1
  36. package/internal.mjs +2 -7
  37. package/mutation-options.d.ts +2 -6
  38. package/mutation-options.mjs +6 -5
  39. package/mutation-options.mjs.map +1 -1
  40. package/package.json +2 -2
  41. package/providers.d.ts +16 -14
  42. package/providers.mjs +138 -75
  43. package/providers.mjs.map +1 -1
  44. package/query-options.d.ts +6 -16
  45. package/query-options.mjs +6 -5
  46. package/query-options.mjs.map +1 -1
  47. package/query-resource.d.ts +4 -3
  48. package/query-resource.mjs +72 -63
  49. package/query-resource.mjs.map +1 -1
  50. package/schematics/migrate-from-experimental/index.js +38 -9
  51. package/schematics/migrate-from-experimental/workspace.js +48 -12
  52. package/schematics/ng-add/index.js +1 -1
  53. package/types.d.ts +76 -16
  54. package/utils/inject-external-store.d.ts +3 -0
  55. package/utils/inject-external-store.mjs +54 -38
  56. package/utils/inject-external-store.mjs.map +1 -1
  57. package/utils/inject-pending-tasks-lifecycle.d.ts +13 -1
  58. package/utils/inject-pending-tasks-lifecycle.mjs +32 -29
  59. package/utils/inject-pending-tasks-lifecycle.mjs.map +1 -1
  60. package/utils/inject-query-zone.d.ts +4 -1
  61. package/utils/inject-query-zone.mjs +12 -7
  62. package/utils/inject-query-zone.mjs.map +1 -1
  63. package/utils/resource-types.d.ts +3 -0
  64. package/utils/result-fields.d.ts +9 -0
  65. package/utils/result-fields.mjs +55 -62
  66. package/utils/result-fields.mjs.map +1 -1
  67. package/utils/signal-proxy.d.ts +6 -0
  68. package/utils/signal-proxy.mjs +16 -9
  69. package/utils/signal-proxy.mjs.map +1 -1
  70. package/internal.mjs.map +0 -1
@@ -1,41 +1,57 @@
1
- import { assertInInjectionContext, inject, DestroyRef, signal, computed, effect, untracked } from "@angular/core";
2
1
  import { injectQueryZone } from "./inject-query-zone.mjs";
2
+ import { DestroyRef, assertInInjectionContext, computed, effect, inject, signal, untracked } from "@angular/core";
3
+ //#region src/utils/inject-external-store.ts
4
+ /**
5
+ * Creates a readonly Angular signal backed by a synchronous external store.
6
+ *
7
+ * Store access, subscription setup, and cleanup run outside NgZone so background
8
+ * timers do not hold Angular stability open.
9
+ *
10
+ * Reads evaluate snapshots without subscribing. An effect owns the subscription
11
+ * and invalidates the snapshot after setup, closing the gap between an early
12
+ * read and connection. The next read recomputes the snapshot; equality prevents
13
+ * unchanged values from propagating. Unread snapshots stay lazy.
14
+ *
15
+ * Notifications invalidate snapshots synchronously once connected. Snapshot-only
16
+ * dependencies do not reinstall the subscription. Subscription setup and cleanup
17
+ * may read the returned signal; factories and snapshot readers must not recurse.
18
+ *
19
+ * Only factory/snapshot errors are exposed on reads. Subscription and cleanup
20
+ * errors follow Angular's normal effect error handling; the helper does not store
21
+ * them or implement retries. Destruction stops observation without changing the
22
+ * cached snapshot.
23
+ * @param binding - Produces the current snapshot reader and optional subscription.
24
+ * @param options - Optional equality comparison for snapshots.
25
+ * @returns A readonly signal containing the latest external snapshot.
26
+ */
3
27
  function injectExternalStore(binding, options) {
4
- if (typeof ngDevMode === "undefined" || ngDevMode) {
5
- assertInInjectionContext(injectExternalStore);
6
- }
7
- const owner = inject(DestroyRef);
8
- const outsideZone = injectQueryZone();
9
- const revision = signal(0);
10
- const requested = computed(() => outsideZone(binding));
11
- const invalidate = () => untracked(() => revision.update((n) => n + 1));
12
- effect((onCleanup) => {
13
- if (owner.destroyed) return;
14
- const current = requested();
15
- outsideZone(
16
- () => untracked(() => {
17
- var _a;
18
- try {
19
- const unsubscribe = (_a = current.subscribe) == null ? void 0 : _a.call(current, invalidate);
20
- if (unsubscribe) {
21
- if (owner.destroyed) unsubscribe();
22
- else onCleanup(() => outsideZone(unsubscribe));
23
- }
24
- } finally {
25
- invalidate();
26
- }
27
- })
28
- );
29
- });
30
- return computed(
31
- () => {
32
- revision();
33
- return outsideZone(() => requested().getSnapshot());
34
- },
35
- (options == null ? void 0 : options.equal) ? { equal: options.equal } : void 0
36
- );
28
+ if (typeof ngDevMode === "undefined" || ngDevMode) assertInInjectionContext(injectExternalStore);
29
+ const owner = inject(DestroyRef);
30
+ const outsideZone = injectQueryZone();
31
+ const revision = signal(0);
32
+ const requested = computed(() => outsideZone(binding));
33
+ const invalidate = () => untracked(() => revision.update((n) => n + 1));
34
+ effect((onCleanup) => {
35
+ if (owner.destroyed) return;
36
+ const current = requested();
37
+ outsideZone(() => untracked(() => {
38
+ try {
39
+ const unsubscribe = current.subscribe?.(invalidate);
40
+ if (unsubscribe) {
41
+ if (owner.destroyed) unsubscribe();
42
+ else onCleanup(() => outsideZone(unsubscribe));
43
+ }
44
+ } finally {
45
+ invalidate();
46
+ }
47
+ }));
48
+ });
49
+ return computed(() => {
50
+ revision();
51
+ return outsideZone(() => requested().getSnapshot());
52
+ }, options?.equal ? { equal: options.equal } : void 0);
37
53
  }
38
- export {
39
- injectExternalStore
40
- };
41
- //# sourceMappingURL=inject-external-store.mjs.map
54
+ //#endregion
55
+ export { injectExternalStore };
56
+
57
+ //# sourceMappingURL=inject-external-store.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"inject-external-store.mjs","sources":["../../src/utils/inject-external-store.ts"],"sourcesContent":["import {\n DestroyRef,\n assertInInjectionContext,\n computed,\n effect,\n inject,\n signal,\n untracked,\n} from '@angular/core'\nimport { injectQueryZone } from './inject-query-zone'\nimport type { Signal, ValueEqualityFn } from '@angular/core'\n\ninterface ExternalBinding<T> {\n /** Synchronous snapshot. Angular signals read here are tracked dependencies. */\n readonly getSnapshot: () => T\n /** Omit to pause observation; changing eligibility requires a new descriptor. */\n readonly subscribe?: ((notify: () => void) => () => void) | undefined\n}\n\ninterface ExternalStoreOptions<T> {\n /** Snapshot equality, defaulting to Object.is. Does not control connection identity. */\n readonly equal?: ValueEqualityFn<T> | undefined\n}\n\n/**\n * Creates a readonly Angular signal backed by a synchronous external store.\n *\n * Store access, subscription setup, and cleanup run outside NgZone so background\n * timers do not hold Angular stability open.\n *\n * Reads evaluate snapshots without subscribing. An effect owns the subscription\n * and invalidates the snapshot after setup, closing the gap between an early\n * read and connection. The next read recomputes the snapshot; equality prevents\n * unchanged values from propagating. Unread snapshots stay lazy.\n *\n * Notifications invalidate snapshots synchronously once connected. Snapshot-only\n * dependencies do not reinstall the subscription. Subscription setup and cleanup\n * may read the returned signal; factories and snapshot readers must not recurse.\n *\n * Only factory/snapshot errors are exposed on reads. Subscription and cleanup\n * errors follow Angular's normal effect error handling; the helper does not store\n * them or implement retries. Destruction stops observation without changing the\n * cached snapshot.\n */\nexport function injectExternalStore<T>(\n binding: () => ExternalBinding<T>,\n options?: ExternalStoreOptions<T>,\n): Signal<T> {\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n assertInInjectionContext(injectExternalStore)\n }\n const owner = inject(DestroyRef)\n const outsideZone = injectQueryZone()\n const revision = signal(0)\n const requested = computed(() => outsideZone(binding))\n const invalidate = () => untracked(() => revision.update((n) => n + 1))\n\n effect((onCleanup) => {\n // The previous subscription's cleanup may have destroyed the owner.\n if (owner.destroyed) return\n const current = requested()\n outsideZone(() =>\n untracked(() => {\n try {\n const unsubscribe = current.subscribe?.(invalidate)\n if (unsubscribe) {\n // subscribe() can trigger component/injector destruction before returning.\n // Registering cleanup afterward misses that destruction.\n if (owner.destroyed) unsubscribe()\n else onCleanup(() => outsideZone(unsubscribe))\n }\n } finally {\n // Invalidate after subscribing so an early cached snapshot cannot miss\n // changes before or during setup. Do not eagerly read the snapshot.\n invalidate()\n }\n }),\n )\n })\n\n return computed(\n () => {\n revision()\n return outsideZone(() => requested().getSnapshot())\n },\n options?.equal ? { equal: options.equal } : undefined,\n )\n}\n"],"names":[],"mappings":";;AA4CO,SAAS,oBACd,SACA,SACW;AACX,MAAI,OAAO,cAAc,eAAe,WAAW;AACjD,6BAAyB,mBAAmB;AAAA,EAC9C;AACA,QAAM,QAAQ,OAAO,UAAU;AAC/B,QAAM,cAAc,gBAAA;AACpB,QAAM,WAAW,OAAO,CAAC;AACzB,QAAM,YAAY,SAAS,MAAM,YAAY,OAAO,CAAC;AACrD,QAAM,aAAa,MAAM,UAAU,MAAM,SAAS,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC;AAEtE,SAAO,CAAC,cAAc;AAEpB,QAAI,MAAM,UAAW;AACrB,UAAM,UAAU,UAAA;AAChB;AAAA,MAAY,MACV,UAAU,MAAM;;AACd,YAAI;AACF,gBAAM,eAAc,aAAQ,cAAR,iCAAoB;AACxC,cAAI,aAAa;AAGf,gBAAI,MAAM,UAAW,aAAA;AAAA,gBAChB,WAAU,MAAM,YAAY,WAAW,CAAC;AAAA,UAC/C;AAAA,QACF,UAAA;AAGE,qBAAA;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IAAA;AAAA,EAEL,CAAC;AAED,SAAO;AAAA,IACL,MAAM;AACJ,eAAA;AACA,aAAO,YAAY,MAAM,UAAA,EAAY,aAAa;AAAA,IACpD;AAAA,KACA,mCAAS,SAAQ,EAAE,OAAO,QAAQ,UAAU;AAAA,EAAA;AAEhD;"}
1
+ {"version":3,"file":"inject-external-store.mjs","names":[],"sources":["../../src/utils/inject-external-store.ts"],"sourcesContent":["import {\n DestroyRef,\n assertInInjectionContext,\n computed,\n effect,\n inject,\n signal,\n untracked,\n} from '@angular/core'\nimport { injectQueryZone } from './inject-query-zone'\nimport type { Signal, ValueEqualityFn } from '@angular/core'\n\ninterface ExternalBinding<T> {\n /** Synchronous snapshot. Angular signals read here are tracked dependencies. */\n readonly getSnapshot: () => T\n /** Omit to pause observation; changing eligibility requires a new descriptor. */\n readonly subscribe?: ((notify: () => void) => () => void) | undefined\n}\n\ninterface ExternalStoreOptions<T> {\n /** Snapshot equality, defaulting to Object.is. Does not control connection identity. */\n readonly equal?: ValueEqualityFn<T> | undefined\n}\n\n/**\n * Creates a readonly Angular signal backed by a synchronous external store.\n *\n * Store access, subscription setup, and cleanup run outside NgZone so background\n * timers do not hold Angular stability open.\n *\n * Reads evaluate snapshots without subscribing. An effect owns the subscription\n * and invalidates the snapshot after setup, closing the gap between an early\n * read and connection. The next read recomputes the snapshot; equality prevents\n * unchanged values from propagating. Unread snapshots stay lazy.\n *\n * Notifications invalidate snapshots synchronously once connected. Snapshot-only\n * dependencies do not reinstall the subscription. Subscription setup and cleanup\n * may read the returned signal; factories and snapshot readers must not recurse.\n *\n * Only factory/snapshot errors are exposed on reads. Subscription and cleanup\n * errors follow Angular's normal effect error handling; the helper does not store\n * them or implement retries. Destruction stops observation without changing the\n * cached snapshot.\n * @param binding - Produces the current snapshot reader and optional subscription.\n * @param options - Optional equality comparison for snapshots.\n * @returns A readonly signal containing the latest external snapshot.\n */\nexport function injectExternalStore<T>(\n binding: () => ExternalBinding<T>,\n options?: ExternalStoreOptions<T>,\n): Signal<T> {\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n assertInInjectionContext(injectExternalStore)\n }\n const owner = inject(DestroyRef)\n const outsideZone = injectQueryZone()\n const revision = signal(0)\n const requested = computed(() => outsideZone(binding))\n const invalidate = () => untracked(() => revision.update((n) => n + 1))\n\n effect((onCleanup) => {\n // The previous subscription's cleanup may have destroyed the owner.\n if (owner.destroyed) return\n const current = requested()\n outsideZone(() =>\n untracked(() => {\n try {\n const unsubscribe = current.subscribe?.(invalidate)\n if (unsubscribe) {\n // subscribe() can trigger component/injector destruction before returning.\n // Registering cleanup afterward misses that destruction.\n if (owner.destroyed) unsubscribe()\n else onCleanup(() => outsideZone(unsubscribe))\n }\n } finally {\n // Invalidate after subscribing so an early cached snapshot cannot miss\n // changes before or during setup. Do not eagerly read the snapshot.\n invalidate()\n }\n }),\n )\n })\n\n return computed(\n () => {\n revision()\n return outsideZone(() => requested().getSnapshot())\n },\n options?.equal ? { equal: options.equal } : undefined,\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,SAAgB,oBACd,SACA,SACW;CACX,IAAI,OAAO,cAAc,eAAe,WACtC,yBAAyB,mBAAmB;CAE9C,MAAM,QAAQ,OAAO,UAAU;CAC/B,MAAM,cAAc,gBAAgB;CACpC,MAAM,WAAW,OAAO,CAAC;CACzB,MAAM,YAAY,eAAe,YAAY,OAAO,CAAC;CACrD,MAAM,mBAAmB,gBAAgB,SAAS,QAAQ,MAAM,IAAI,CAAC,CAAC;CAEtE,QAAQ,cAAc;EAEpB,IAAI,MAAM,WAAW;EACrB,MAAM,UAAU,UAAU;EAC1B,kBACE,gBAAgB;GACd,IAAI;IACF,MAAM,cAAc,QAAQ,YAAY,UAAU;IAClD,IAAI,aAAa;KAGf,IAAI,MAAM,WAAW,YAAY;UAC5B,gBAAgB,YAAY,WAAW,CAAC;IAC/C;GACF,UAAU;IAGR,WAAW;GACb;EACF,CAAC,CACH;CACF,CAAC;CAED,OAAO,eACC;EACJ,SAAS;EACT,OAAO,kBAAkB,UAAU,CAAC,CAAC,YAAY,CAAC;CACpD,GACA,SAAS,QAAQ,EAAE,OAAO,QAAQ,MAAM,IAAI,KAAA,CAC9C;AACF"}
@@ -1,6 +1,18 @@
1
+ /**
2
+ * Tracks ownership and pending work for the current Angular injection context.
3
+ */
1
4
  export interface QueryLifecycle {
5
+ /**
6
+ * Whether Angular has destroyed the injection context that owns this query.
7
+ */
2
8
  readonly destroyed: boolean;
9
+ /**
10
+ * Adds or releases the task that keeps Angular unstable while owned work is pending.
11
+ */
3
12
  setPending: (pending: boolean) => void;
4
13
  }
5
- /** Tracks pending work for the lifetime of the current injection context. */
14
+ /**
15
+ * Tracks pending work for the lifetime of the current injection context.
16
+ * @returns The destruction state and pending-task controller for this context.
17
+ */
6
18
  export declare function injectPendingTasksLifecycle(): QueryLifecycle;
@@ -1,31 +1,34 @@
1
- import { inject, DestroyRef, PendingTasks, NgZone } from "@angular/core";
1
+ import { DestroyRef, NgZone, PendingTasks, inject } from "@angular/core";
2
+ //#region src/utils/inject-pending-tasks-lifecycle.ts
3
+ /**
4
+ * Tracks pending work for the lifetime of the current injection context.
5
+ * @returns The destruction state and pending-task controller for this context.
6
+ */
2
7
  function injectPendingTasksLifecycle() {
3
- const destroyRef = inject(DestroyRef);
4
- const pendingTasks = inject(PendingTasks);
5
- const ngZone = inject(NgZone);
6
- let taskCleanup;
7
- const lifecycle = {
8
- get destroyed() {
9
- return destroyRef.destroyed;
10
- },
11
- setPending(pending) {
12
- if (pending) {
13
- if (!destroyRef.destroyed && !taskCleanup) {
14
- taskCleanup = pendingTasks.add();
15
- }
16
- return;
17
- }
18
- const cleanup = taskCleanup;
19
- taskCleanup = void 0;
20
- if (cleanup) ngZone.run(cleanup);
21
- }
22
- };
23
- destroyRef.onDestroy(() => {
24
- lifecycle.setPending(false);
25
- });
26
- return lifecycle;
8
+ const destroyRef = inject(DestroyRef);
9
+ const pendingTasks = inject(PendingTasks);
10
+ const ngZone = inject(NgZone);
11
+ let taskCleanup;
12
+ const lifecycle = {
13
+ get destroyed() {
14
+ return destroyRef.destroyed;
15
+ },
16
+ setPending(pending) {
17
+ if (pending) {
18
+ if (!destroyRef.destroyed && !taskCleanup) taskCleanup = pendingTasks.add();
19
+ return;
20
+ }
21
+ const cleanup = taskCleanup;
22
+ taskCleanup = void 0;
23
+ if (cleanup) ngZone.run(cleanup);
24
+ }
25
+ };
26
+ destroyRef.onDestroy(() => {
27
+ lifecycle.setPending(false);
28
+ });
29
+ return lifecycle;
27
30
  }
28
- export {
29
- injectPendingTasksLifecycle
30
- };
31
- //# sourceMappingURL=inject-pending-tasks-lifecycle.mjs.map
31
+ //#endregion
32
+ export { injectPendingTasksLifecycle };
33
+
34
+ //# sourceMappingURL=inject-pending-tasks-lifecycle.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"inject-pending-tasks-lifecycle.mjs","sources":["../../src/utils/inject-pending-tasks-lifecycle.ts"],"sourcesContent":["import { DestroyRef, NgZone, PendingTasks, inject } from '@angular/core'\n\nexport interface QueryLifecycle {\n readonly destroyed: boolean\n setPending: (pending: boolean) => void\n}\n\n/** Tracks pending work for the lifetime of the current injection context. */\nexport function injectPendingTasksLifecycle(): QueryLifecycle {\n const destroyRef = inject(DestroyRef)\n const pendingTasks = inject(PendingTasks)\n const ngZone = inject(NgZone)\n let taskCleanup: (() => void) | undefined\n\n const lifecycle: QueryLifecycle = {\n get destroyed() {\n return destroyRef.destroyed\n },\n setPending(pending) {\n if (pending) {\n if (!destroyRef.destroyed && !taskCleanup) {\n taskCleanup = pendingTasks.add()\n }\n return\n }\n\n const cleanup = taskCleanup\n taskCleanup = undefined\n // Enter NgZone while our task is still held to avoid transient stability\n // before dependent queries are scheduled.\n // In zoneless apps, NgZone.run simply invokes the cleanup.\n if (cleanup) ngZone.run(cleanup)\n },\n }\n\n destroyRef.onDestroy(() => {\n lifecycle.setPending(false)\n })\n\n return lifecycle\n}\n"],"names":[],"mappings":";AAQO,SAAS,8BAA8C;AAC5D,QAAM,aAAa,OAAO,UAAU;AACpC,QAAM,eAAe,OAAO,YAAY;AACxC,QAAM,SAAS,OAAO,MAAM;AAC5B,MAAI;AAEJ,QAAM,YAA4B;AAAA,IAChC,IAAI,YAAY;AACd,aAAO,WAAW;AAAA,IACpB;AAAA,IACA,WAAW,SAAS;AAClB,UAAI,SAAS;AACX,YAAI,CAAC,WAAW,aAAa,CAAC,aAAa;AACzC,wBAAc,aAAa,IAAA;AAAA,QAC7B;AACA;AAAA,MACF;AAEA,YAAM,UAAU;AAChB,oBAAc;AAId,UAAI,QAAS,QAAO,IAAI,OAAO;AAAA,IACjC;AAAA,EAAA;AAGF,aAAW,UAAU,MAAM;AACzB,cAAU,WAAW,KAAK;AAAA,EAC5B,CAAC;AAED,SAAO;AACT;"}
1
+ {"version":3,"file":"inject-pending-tasks-lifecycle.mjs","names":[],"sources":["../../src/utils/inject-pending-tasks-lifecycle.ts"],"sourcesContent":["import { DestroyRef, NgZone, PendingTasks, inject } from '@angular/core'\n\n/**\n * Tracks ownership and pending work for the current Angular injection context.\n */\nexport interface QueryLifecycle {\n /**\n * Whether Angular has destroyed the injection context that owns this query.\n */\n readonly destroyed: boolean\n /**\n * Adds or releases the task that keeps Angular unstable while owned work is pending.\n */\n setPending: (pending: boolean) => void\n}\n\n/**\n * Tracks pending work for the lifetime of the current injection context.\n * @returns The destruction state and pending-task controller for this context.\n */\nexport function injectPendingTasksLifecycle(): QueryLifecycle {\n const destroyRef = inject(DestroyRef)\n const pendingTasks = inject(PendingTasks)\n const ngZone = inject(NgZone)\n let taskCleanup: (() => void) | undefined\n\n const lifecycle: QueryLifecycle = {\n get destroyed() {\n return destroyRef.destroyed\n },\n setPending(pending) {\n if (pending) {\n if (!destroyRef.destroyed && !taskCleanup) {\n taskCleanup = pendingTasks.add()\n }\n return\n }\n\n const cleanup = taskCleanup\n taskCleanup = undefined\n // Enter NgZone while our task is still held to avoid transient stability\n // before dependent queries are scheduled.\n // In zoneless apps, NgZone.run simply invokes the cleanup.\n if (cleanup) ngZone.run(cleanup)\n },\n }\n\n destroyRef.onDestroy(() => {\n lifecycle.setPending(false)\n })\n\n return lifecycle\n}\n"],"mappings":";;;;;;AAoBA,SAAgB,8BAA8C;CAC5D,MAAM,aAAa,OAAO,UAAU;CACpC,MAAM,eAAe,OAAO,YAAY;CACxC,MAAM,SAAS,OAAO,MAAM;CAC5B,IAAI;CAEJ,MAAM,YAA4B;EAChC,IAAI,YAAY;GACd,OAAO,WAAW;EACpB;EACA,WAAW,SAAS;GAClB,IAAI,SAAS;IACX,IAAI,CAAC,WAAW,aAAa,CAAC,aAC5B,cAAc,aAAa,IAAI;IAEjC;GACF;GAEA,MAAM,UAAU;GAChB,cAAc,KAAA;GAId,IAAI,SAAS,OAAO,IAAI,OAAO;EACjC;CACF;CAEA,WAAW,gBAAgB;EACzB,UAAU,WAAW,KAAK;CAC5B,CAAC;CAED,OAAO;AACT"}
@@ -1,2 +1,5 @@
1
- /** Keep Query's background timers out of Angular's stability tracking. */
1
+ /**
2
+ * Keeps Query's background timers out of Angular's stability tracking.
3
+ * @returns A function that runs callbacks outside the injected NgZone.
4
+ */
2
5
  export declare function injectQueryZone(): <T>(fn: () => T) => T;
@@ -1,9 +1,14 @@
1
- import { inject, NgZone } from "@angular/core";
1
+ import { NgZone, inject } from "@angular/core";
2
+ //#region src/utils/inject-query-zone.ts
3
+ /**
4
+ * Keeps Query's background timers out of Angular's stability tracking.
5
+ * @returns A function that runs callbacks outside the injected NgZone.
6
+ */
2
7
  function injectQueryZone() {
3
- const ngZone = inject(NgZone);
4
- return (fn) => ngZone.runOutsideAngular(fn);
8
+ const ngZone = inject(NgZone);
9
+ return (fn) => ngZone.runOutsideAngular(fn);
5
10
  }
6
- export {
7
- injectQueryZone
8
- };
9
- //# sourceMappingURL=inject-query-zone.mjs.map
11
+ //#endregion
12
+ export { injectQueryZone };
13
+
14
+ //# sourceMappingURL=inject-query-zone.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"inject-query-zone.mjs","sources":["../../src/utils/inject-query-zone.ts"],"sourcesContent":["import { NgZone, inject } from '@angular/core'\n\n/** Keep Query's background timers out of Angular's stability tracking. */\nexport function injectQueryZone() {\n const ngZone = inject(NgZone)\n return <T>(fn: () => T): T => ngZone.runOutsideAngular(fn)\n}\n"],"names":[],"mappings":";AAGO,SAAS,kBAAkB;AAChC,QAAM,SAAS,OAAO,MAAM;AAC5B,SAAO,CAAI,OAAmB,OAAO,kBAAkB,EAAE;AAC3D;"}
1
+ {"version":3,"file":"inject-query-zone.mjs","names":[],"sources":["../../src/utils/inject-query-zone.ts"],"sourcesContent":["import { NgZone, inject } from '@angular/core'\n\n/**\n * Keeps Query's background timers out of Angular's stability tracking.\n * @returns A function that runs callbacks outside the injected NgZone.\n */\nexport function injectQueryZone() {\n const ngZone = inject(NgZone)\n return <T>(fn: () => T): T => ngZone.runOutsideAngular(fn)\n}\n"],"mappings":";;;;;;AAMA,SAAgB,kBAAkB;CAChC,MAAM,SAAS,OAAO,MAAM;CAC5B,QAAW,OAAmB,OAAO,kBAAkB,EAAE;AAC3D"}
@@ -1,4 +1,7 @@
1
1
  import { ResourceStatus } from '@angular/core';
2
+ /**
3
+ * A discriminated snapshot containing either a resource value or its current error.
4
+ */
2
5
  export type ResourceSnapshot<T> = {
3
6
  readonly status: 'error';
4
7
  readonly error: Error;
@@ -72,9 +72,18 @@ declare const mutationFields: {
72
72
  isSuccess: true;
73
73
  };
74
74
  export declare const queryResultFields: Array<keyof typeof queryFields>;
75
+ /**
76
+ * The query observer value fields exposed as Angular signals.
77
+ */
75
78
  export type QueryResultFields = (typeof queryResultFields)[number];
76
79
  export declare const infiniteQueryResultFields: Array<keyof typeof infiniteQueryFields>;
80
+ /**
81
+ * The paginated query observer value fields exposed as Angular signals.
82
+ */
77
83
  export type InfiniteQueryResultFields = (typeof infiniteQueryResultFields)[number];
78
84
  export declare const mutationResultFields: Array<keyof typeof mutationFields>;
85
+ /**
86
+ * The mutation observer value fields exposed as Angular signals.
87
+ */
79
88
  export type MutationResultFields = (typeof mutationResultFields)[number];
80
89
  export {};
@@ -1,65 +1,58 @@
1
- const queryFields = {
2
- data: true,
3
- dataUpdatedAt: true,
4
- error: true,
5
- errorUpdatedAt: true,
6
- failureCount: true,
7
- failureReason: true,
8
- errorUpdateCount: true,
9
- isError: true,
10
- isFetched: true,
11
- isFetchedAfterMount: true,
12
- isFetching: true,
13
- isLoading: true,
14
- isPending: true,
15
- isLoadingError: true,
16
- isInitialLoading: true,
17
- isPaused: true,
18
- isPlaceholderData: true,
19
- isRefetchError: true,
20
- isRefetching: true,
21
- isStale: true,
22
- isSuccess: true,
23
- isEnabled: true,
24
- status: true,
25
- fetchStatus: true
1
+ //#region src/utils/result-fields.ts
2
+ var queryFields = {
3
+ data: true,
4
+ dataUpdatedAt: true,
5
+ error: true,
6
+ errorUpdatedAt: true,
7
+ failureCount: true,
8
+ failureReason: true,
9
+ errorUpdateCount: true,
10
+ isError: true,
11
+ isFetched: true,
12
+ isFetchedAfterMount: true,
13
+ isFetching: true,
14
+ isLoading: true,
15
+ isPending: true,
16
+ isLoadingError: true,
17
+ isInitialLoading: true,
18
+ isPaused: true,
19
+ isPlaceholderData: true,
20
+ isRefetchError: true,
21
+ isRefetching: true,
22
+ isStale: true,
23
+ isSuccess: true,
24
+ isEnabled: true,
25
+ status: true,
26
+ fetchStatus: true
26
27
  };
27
- const infiniteQueryFields = {
28
- ...queryFields,
29
- hasNextPage: true,
30
- hasPreviousPage: true,
31
- isFetchNextPageError: true,
32
- isFetchingNextPage: true,
33
- isFetchPreviousPageError: true,
34
- isFetchingPreviousPage: true
28
+ var infiniteQueryFields = {
29
+ ...queryFields,
30
+ hasNextPage: true,
31
+ hasPreviousPage: true,
32
+ isFetchNextPageError: true,
33
+ isFetchingNextPage: true,
34
+ isFetchPreviousPageError: true,
35
+ isFetchingPreviousPage: true
35
36
  };
36
- const mutationFields = {
37
- context: true,
38
- data: true,
39
- error: true,
40
- failureCount: true,
41
- failureReason: true,
42
- isPaused: true,
43
- status: true,
44
- variables: true,
45
- submittedAt: true,
46
- isError: true,
47
- isIdle: true,
48
- isPending: true,
49
- isSuccess: true
37
+ var mutationFields = {
38
+ context: true,
39
+ data: true,
40
+ error: true,
41
+ failureCount: true,
42
+ failureReason: true,
43
+ isPaused: true,
44
+ status: true,
45
+ variables: true,
46
+ submittedAt: true,
47
+ isError: true,
48
+ isIdle: true,
49
+ isPending: true,
50
+ isSuccess: true
50
51
  };
51
- const queryResultFields = /* @__PURE__ */ Object.keys(
52
- queryFields
53
- );
54
- const infiniteQueryResultFields = /* @__PURE__ */ Object.keys(
55
- infiniteQueryFields
56
- );
57
- const mutationResultFields = /* @__PURE__ */ Object.keys(
58
- mutationFields
59
- );
60
- export {
61
- infiniteQueryResultFields,
62
- mutationResultFields,
63
- queryResultFields
64
- };
65
- //# sourceMappingURL=result-fields.mjs.map
52
+ var queryResultFields = /* #__PURE__ */ Object.keys(queryFields);
53
+ var infiniteQueryResultFields = /* #__PURE__ */ Object.keys(infiniteQueryFields);
54
+ var mutationResultFields = /* #__PURE__ */ Object.keys(mutationFields);
55
+ //#endregion
56
+ export { infiniteQueryResultFields, mutationResultFields, queryResultFields };
57
+
58
+ //# sourceMappingURL=result-fields.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"result-fields.mjs","sources":["../../src/utils/result-fields.ts"],"sourcesContent":["import type {\n InfiniteQueryObserverResult,\n MutationObserverResult,\n QueryObserverResult,\n} from '@tanstack/query-core'\nimport type { MethodKeys } from './signal-proxy'\n\ntype Fields<T> = { [K in Exclude<keyof T, MethodKeys<T>>]: true }\n\n// Exhaustive maps keep the field surface aligned with query-core at compile time.\nconst queryFields = {\n data: true,\n dataUpdatedAt: true,\n error: true,\n errorUpdatedAt: true,\n failureCount: true,\n failureReason: true,\n errorUpdateCount: true,\n isError: true,\n isFetched: true,\n isFetchedAfterMount: true,\n isFetching: true,\n isLoading: true,\n isPending: true,\n isLoadingError: true,\n isInitialLoading: true,\n isPaused: true,\n isPlaceholderData: true,\n isRefetchError: true,\n isRefetching: true,\n isStale: true,\n isSuccess: true,\n isEnabled: true,\n status: true,\n fetchStatus: true,\n} satisfies Fields<QueryObserverResult>\n\nconst infiniteQueryFields = {\n ...queryFields,\n hasNextPage: true,\n hasPreviousPage: true,\n isFetchNextPageError: true,\n isFetchingNextPage: true,\n isFetchPreviousPageError: true,\n isFetchingPreviousPage: true,\n} satisfies Fields<InfiniteQueryObserverResult>\n\nconst mutationFields = {\n context: true,\n data: true,\n error: true,\n failureCount: true,\n failureReason: true,\n isPaused: true,\n status: true,\n variables: true,\n submittedAt: true,\n isError: true,\n isIdle: true,\n isPending: true,\n isSuccess: true,\n} satisfies Fields<MutationObserverResult>\n\nexport const queryResultFields = /* @__PURE__ */ Object.keys(\n queryFields,\n) as Array<keyof typeof queryFields>\nexport type QueryResultFields = (typeof queryResultFields)[number]\n\nexport const infiniteQueryResultFields = /* @__PURE__ */ Object.keys(\n infiniteQueryFields,\n) as Array<keyof typeof infiniteQueryFields>\nexport type InfiniteQueryResultFields =\n (typeof infiniteQueryResultFields)[number]\n\nexport const mutationResultFields = /* @__PURE__ */ Object.keys(\n mutationFields,\n) as Array<keyof typeof mutationFields>\nexport type MutationResultFields = (typeof mutationResultFields)[number]\n"],"names":[],"mappings":"AAUA,MAAM,cAAc;AAAA,EAClB,MAAM;AAAA,EACN,eAAe;AAAA,EACf,OAAO;AAAA,EACP,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,eAAe;AAAA,EACf,kBAAkB;AAAA,EAClB,SAAS;AAAA,EACT,WAAW;AAAA,EACX,qBAAqB;AAAA,EACrB,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AAAA,EACX,gBAAgB;AAAA,EAChB,kBAAkB;AAAA,EAClB,UAAU;AAAA,EACV,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,SAAS;AAAA,EACT,WAAW;AAAA,EACX,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,aAAa;AACf;AAEA,MAAM,sBAAsB;AAAA,EAC1B,GAAG;AAAA,EACH,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,sBAAsB;AAAA,EACtB,oBAAoB;AAAA,EACpB,0BAA0B;AAAA,EAC1B,wBAAwB;AAC1B;AAEA,MAAM,iBAAiB;AAAA,EACrB,SAAS;AAAA,EACT,MAAM;AAAA,EACN,OAAO;AAAA,EACP,cAAc;AAAA,EACd,eAAe;AAAA,EACf,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,aAAa;AAAA,EACb,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,WAAW;AACb;AAEO,MAAM,oBAAoC,uBAAO;AAAA,EACtD;AACF;AAGO,MAAM,4BAA4C,uBAAO;AAAA,EAC9D;AACF;AAIO,MAAM,uBAAuC,uBAAO;AAAA,EACzD;AACF;"}
1
+ {"version":3,"file":"result-fields.mjs","names":[],"sources":["../../src/utils/result-fields.ts"],"sourcesContent":["import type {\n InfiniteQueryObserverResult,\n MutationObserverResult,\n QueryObserverResult,\n} from '@tanstack/query-core'\nimport type { MethodKeys } from './signal-proxy'\n\ntype Fields<T> = { [K in Exclude<keyof T, MethodKeys<T>>]: true }\n\n// Exhaustive maps keep the field surface aligned with query-core at compile time.\nconst queryFields = {\n data: true,\n dataUpdatedAt: true,\n error: true,\n errorUpdatedAt: true,\n failureCount: true,\n failureReason: true,\n errorUpdateCount: true,\n isError: true,\n isFetched: true,\n isFetchedAfterMount: true,\n isFetching: true,\n isLoading: true,\n isPending: true,\n isLoadingError: true,\n isInitialLoading: true,\n isPaused: true,\n isPlaceholderData: true,\n isRefetchError: true,\n isRefetching: true,\n isStale: true,\n isSuccess: true,\n isEnabled: true,\n status: true,\n fetchStatus: true,\n} satisfies Fields<QueryObserverResult>\n\nconst infiniteQueryFields = {\n ...queryFields,\n hasNextPage: true,\n hasPreviousPage: true,\n isFetchNextPageError: true,\n isFetchingNextPage: true,\n isFetchPreviousPageError: true,\n isFetchingPreviousPage: true,\n} satisfies Fields<InfiniteQueryObserverResult>\n\nconst mutationFields = {\n context: true,\n data: true,\n error: true,\n failureCount: true,\n failureReason: true,\n isPaused: true,\n status: true,\n variables: true,\n submittedAt: true,\n isError: true,\n isIdle: true,\n isPending: true,\n isSuccess: true,\n} satisfies Fields<MutationObserverResult>\n\nexport const queryResultFields = /* #__PURE__ */ Object.keys(\n queryFields,\n) as Array<keyof typeof queryFields>\n/**\n * The query observer value fields exposed as Angular signals.\n */\nexport type QueryResultFields = (typeof queryResultFields)[number]\n\nexport const infiniteQueryResultFields = /* #__PURE__ */ Object.keys(\n infiniteQueryFields,\n) as Array<keyof typeof infiniteQueryFields>\n/**\n * The paginated query observer value fields exposed as Angular signals.\n */\nexport type InfiniteQueryResultFields =\n (typeof infiniteQueryResultFields)[number]\n\nexport const mutationResultFields = /* #__PURE__ */ Object.keys(\n mutationFields,\n) as Array<keyof typeof mutationFields>\n/**\n * The mutation observer value fields exposed as Angular signals.\n */\nexport type MutationResultFields = (typeof mutationResultFields)[number]\n"],"mappings":";AAUA,IAAM,cAAc;CAClB,MAAM;CACN,eAAe;CACf,OAAO;CACP,gBAAgB;CAChB,cAAc;CACd,eAAe;CACf,kBAAkB;CAClB,SAAS;CACT,WAAW;CACX,qBAAqB;CACrB,YAAY;CACZ,WAAW;CACX,WAAW;CACX,gBAAgB;CAChB,kBAAkB;CAClB,UAAU;CACV,mBAAmB;CACnB,gBAAgB;CAChB,cAAc;CACd,SAAS;CACT,WAAW;CACX,WAAW;CACX,QAAQ;CACR,aAAa;AACf;AAEA,IAAM,sBAAsB;CAC1B,GAAG;CACH,aAAa;CACb,iBAAiB;CACjB,sBAAsB;CACtB,oBAAoB;CACpB,0BAA0B;CAC1B,wBAAwB;AAC1B;AAEA,IAAM,iBAAiB;CACrB,SAAS;CACT,MAAM;CACN,OAAO;CACP,cAAc;CACd,eAAe;CACf,UAAU;CACV,QAAQ;CACR,WAAW;CACX,aAAa;CACb,SAAS;CACT,QAAQ;CACR,WAAW;CACX,WAAW;AACb;AAEA,IAAa,oBAAoC,uBAAO,KACtD,WACF;AAMA,IAAa,4BAA4C,uBAAO,KAC9D,mBACF;AAOA,IAAa,uBAAuC,uBAAO,KACzD,cACF"}
@@ -1,7 +1,13 @@
1
1
  import { Signal } from '@angular/core';
2
+ /**
3
+ * Names of object properties whose values are callable.
4
+ */
2
5
  export type MethodKeys<T> = {
3
6
  [K in keyof T]: T[K] extends (...args: Array<any>) => any ? K : never;
4
7
  }[keyof T];
8
+ /**
9
+ * Exposes selected object fields as Angular signals and leaves all other fields unchanged.
10
+ */
5
11
  export type MapToSignals<T, TSignalFields extends keyof any = never> = {
6
12
  [K in keyof T as K extends TSignalFields ? K : never]: Signal<T[K]>;
7
13
  } & {
@@ -1,12 +1,19 @@
1
1
  import { computed } from "@angular/core";
2
+ //#region src/utils/signal-proxy.ts
3
+ /**
4
+ * Maps known result fields to lazy computed signals on an ordinary object.
5
+ * Creating or enumerating the fields never evaluates the source. Imperative
6
+ * methods are defined by each adapter, outside this mapping.
7
+ * @param inputSignal - The source snapshot.
8
+ * @param fields - The fields exposed as signals.
9
+ * @returns An object containing one stable signal per field.
10
+ */
2
11
  function signalProxy(inputSignal, fields) {
3
- const result = {};
4
- for (const field of fields) {
5
- result[field] = computed(() => inputSignal()[field]);
6
- }
7
- return result;
12
+ const result = {};
13
+ for (const field of fields) result[field] = computed(() => inputSignal()[field]);
14
+ return result;
8
15
  }
9
- export {
10
- signalProxy
11
- };
12
- //# sourceMappingURL=signal-proxy.mjs.map
16
+ //#endregion
17
+ export { signalProxy };
18
+
19
+ //# sourceMappingURL=signal-proxy.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"signal-proxy.mjs","sources":["../../src/utils/signal-proxy.ts"],"sourcesContent":["import { computed } from '@angular/core'\nimport type { Signal } from '@angular/core'\n\nexport type MethodKeys<T> = {\n [K in keyof T]: T[K] extends (...args: Array<any>) => any ? K : never\n}[keyof T]\n\nexport type MapToSignals<T, TSignalFields extends keyof any = never> = {\n [K in keyof T as K extends TSignalFields ? K : never]: Signal<T[K]>\n} & {\n [K in keyof T as K extends TSignalFields ? never : K]: T[K]\n}\n\n/**\n * Maps known result fields to lazy computed signals on an ordinary object.\n * Creating or enumerating the fields never evaluates the source. Imperative\n * methods are defined by each adapter, outside this mapping.\n * @param inputSignal - The source snapshot.\n * @param fields - The fields exposed as signals.\n * @returns An object containing one stable signal per field.\n */\nexport function signalProxy<T, TField extends keyof T>(\n inputSignal: Signal<T>,\n fields: ReadonlyArray<TField>,\n): { [P in TField]: Signal<T[P]> } {\n const result = {} as { [P in TField]: Signal<T[P]> }\n for (const field of fields) {\n result[field] = computed(() => inputSignal()[field])\n }\n return result\n}\n"],"names":[],"mappings":";AAqBO,SAAS,YACd,aACA,QACiC;AACjC,QAAM,SAAS,CAAA;AACf,aAAW,SAAS,QAAQ;AAC1B,WAAO,KAAK,IAAI,SAAS,MAAM,YAAA,EAAc,KAAK,CAAC;AAAA,EACrD;AACA,SAAO;AACT;"}
1
+ {"version":3,"file":"signal-proxy.mjs","names":[],"sources":["../../src/utils/signal-proxy.ts"],"sourcesContent":["import { computed } from '@angular/core'\nimport type { Signal } from '@angular/core'\n\n/**\n * Names of object properties whose values are callable.\n */\nexport type MethodKeys<T> = {\n [K in keyof T]: T[K] extends (...args: Array<any>) => any ? K : never\n}[keyof T]\n\n/**\n * Exposes selected object fields as Angular signals and leaves all other fields unchanged.\n */\nexport type MapToSignals<T, TSignalFields extends keyof any = never> = {\n [K in keyof T as K extends TSignalFields ? K : never]: Signal<T[K]>\n} & {\n [K in keyof T as K extends TSignalFields ? never : K]: T[K]\n}\n\n/**\n * Maps known result fields to lazy computed signals on an ordinary object.\n * Creating or enumerating the fields never evaluates the source. Imperative\n * methods are defined by each adapter, outside this mapping.\n * @param inputSignal - The source snapshot.\n * @param fields - The fields exposed as signals.\n * @returns An object containing one stable signal per field.\n */\nexport function signalProxy<T, TField extends keyof T>(\n inputSignal: Signal<T>,\n fields: ReadonlyArray<TField>,\n): { [P in TField]: Signal<T[P]> } {\n const result = {} as { [P in TField]: Signal<T[P]> }\n for (const field of fields) {\n result[field] = computed(() => inputSignal()[field])\n }\n return result\n}\n"],"mappings":";;;;;;;;;;AA2BA,SAAgB,YACd,aACA,QACiC;CACjC,MAAM,SAAS,CAAC;CAChB,KAAK,MAAM,SAAS,QAClB,OAAO,SAAS,eAAe,YAAY,CAAC,CAAC,MAAM;CAErD,OAAO;AACT"}
package/internal.mjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"internal.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}