reactjrx 1.101.1 → 1.105.1

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 (107) hide show
  1. package/dist/index.cjs +96 -8
  2. package/dist/index.d.ts +11 -8
  3. package/dist/index.js +97 -9
  4. package/dist/lib/{queries → deprecated}/client/mutations/mutation/executeMutation.d.ts +1 -0
  5. package/dist/lib/{queries → deprecated}/client/mutations/utils/filters.d.ts +1 -0
  6. package/dist/lib/{queries → deprecated}/client/queries/query/execution/executeQuery.d.ts +1 -0
  7. package/dist/lib/{queries → deprecated}/client/queries/query/operators.d.ts +1 -0
  8. package/dist/lib/{queries → deprecated}/client/queries/query/state/whenNewData.d.ts +1 -0
  9. package/dist/lib/logger.d.ts +16 -16
  10. package/dist/lib/queries/useMutation$.d.ts +5 -0
  11. package/dist/lib/queries/useMutation.test.d.ts +1 -0
  12. package/dist/lib/queries/useQuery$.d.ts +5 -0
  13. package/dist/lib/queries/useQuery.cleanup.test.d.ts +1 -0
  14. package/dist/lib/queries/useQuery.deduplication.test.d.ts +1 -0
  15. package/dist/lib/queries/useQuery.invalidation.test.d.ts +1 -0
  16. package/dist/lib/queries/useQuery.keys.test.d.ts +1 -0
  17. package/dist/lib/queries/useQuery.test.d.ts +1 -0
  18. package/dist/tests/utils.d.ts +1 -1
  19. package/package.json +3 -6
  20. /package/dist/lib/{queries → deprecated}/client/QueryClient.d.ts +0 -0
  21. /package/dist/lib/{queries → deprecated}/client/QueryClient.rq.test.d.ts +0 -0
  22. /package/dist/lib/{queries → deprecated}/client/QueryClient.types.rq.test.d.ts +0 -0
  23. /package/dist/lib/{queries → deprecated}/client/focusManager.d.ts +0 -0
  24. /package/dist/lib/{queries → deprecated}/client/focusManager.rq.test.d.ts +0 -0
  25. /package/dist/lib/{queries → deprecated}/client/keys/hashKey.d.ts +0 -0
  26. /package/dist/lib/{queries → deprecated}/client/keys/hashKey.test.d.ts +0 -0
  27. /package/dist/lib/{queries → deprecated}/client/keys/matchKey.d.ts +0 -0
  28. /package/dist/lib/{queries → deprecated}/client/keys/matchKey.test.d.ts +0 -0
  29. /package/dist/lib/{queries → deprecated}/client/keys/nanoid.d.ts +0 -0
  30. /package/dist/lib/{queries → deprecated}/client/keys/partialMatchKey.d.ts +0 -0
  31. /package/dist/lib/{queries → deprecated}/client/keys/partialMatchKey.rq.test.d.ts +0 -0
  32. /package/dist/lib/{queries → deprecated}/client/keys/types.d.ts +0 -0
  33. /package/dist/lib/{queries → deprecated}/client/mutations/cache/MutationCache.d.ts +0 -0
  34. /package/dist/lib/{queries → deprecated}/client/mutations/cache/mutationCache.rq.test.d.ts +0 -0
  35. /package/dist/lib/{queries → deprecated}/client/mutations/cache/types.d.ts +0 -0
  36. /package/dist/lib/{queries → deprecated}/client/mutations/mutation/Mutation.d.ts +0 -0
  37. /package/dist/lib/{queries → deprecated}/client/mutations/mutation/delayWhenNetworkOnline.d.ts +0 -0
  38. /package/dist/lib/{queries → deprecated}/client/mutations/mutation/mutation.options.test.d.ts +0 -0
  39. /package/dist/lib/{queries → deprecated}/client/mutations/mutation/observeUntilFinished.d.ts +0 -0
  40. /package/dist/lib/{queries → deprecated}/client/mutations/mutation/types.d.ts +0 -0
  41. /package/dist/lib/{queries → deprecated}/client/mutations/mutation/waitForNetworkOnError.d.ts +0 -0
  42. /package/dist/lib/{queries → deprecated}/client/mutations/mutations.test.d.ts +0 -0
  43. /package/dist/lib/{queries → deprecated}/client/mutations/observers/MutationObserver.d.ts +0 -0
  44. /package/dist/lib/{queries → deprecated}/client/mutations/observers/mutationObserver.rq.test.d.ts +0 -0
  45. /package/dist/lib/{queries → deprecated}/client/mutations/observers/mutationObserver.test.d.ts +0 -0
  46. /package/dist/lib/{queries → deprecated}/client/mutations/observers/types.d.ts +0 -0
  47. /package/dist/lib/{queries → deprecated}/client/mutations/runner/MutationRunner.d.ts +0 -0
  48. /package/dist/lib/{queries → deprecated}/client/mutations/runner/mutationRunner.test.d.ts +0 -0
  49. /package/dist/lib/{queries → deprecated}/client/mutations/types.d.ts +0 -0
  50. /package/dist/lib/{queries → deprecated}/client/mutations/utils/defaultMutationState.d.ts +0 -0
  51. /package/dist/lib/{queries → deprecated}/client/mutations/utils/distinctUntilStateChanged.d.ts +0 -0
  52. /package/dist/lib/{queries → deprecated}/client/onlineManager.d.ts +0 -0
  53. /package/dist/lib/{queries → deprecated}/client/queries/cache/QueryCache.d.ts +0 -0
  54. /package/dist/lib/{queries → deprecated}/client/queries/cache/types.d.ts +0 -0
  55. /package/dist/lib/{queries → deprecated}/client/queries/observer/QueryObserver.d.ts +0 -0
  56. /package/dist/lib/{queries → deprecated}/client/queries/observer/QueryObserver.rq.test.d.ts +0 -0
  57. /package/dist/lib/{queries → deprecated}/client/queries/observer/QueryObserver.types.rq.test.d.ts +0 -0
  58. /package/dist/lib/{queries → deprecated}/client/queries/observer/queryStateHelpers.d.ts +0 -0
  59. /package/dist/lib/{queries → deprecated}/client/queries/observer/types.d.ts +0 -0
  60. /package/dist/lib/{queries → deprecated}/client/queries/query/Query.d.ts +0 -0
  61. /package/dist/lib/{queries → deprecated}/client/queries/query/delayOnNetworkMode.d.ts +0 -0
  62. /package/dist/lib/{queries → deprecated}/client/queries/query/delayUntilFocus.d.ts +0 -0
  63. /package/dist/lib/{queries → deprecated}/client/queries/query/execution/completeFnIfNotMoreObservers.d.ts +0 -0
  64. /package/dist/lib/{queries → deprecated}/client/queries/query/getDefaultState.d.ts +0 -0
  65. /package/dist/lib/{queries → deprecated}/client/queries/query/query.rq.test.d.ts +0 -0
  66. /package/dist/lib/{queries → deprecated}/client/queries/query/query.test.d.ts +0 -0
  67. /package/dist/lib/{queries → deprecated}/client/queries/query/types.d.ts +0 -0
  68. /package/dist/lib/{queries → deprecated}/client/queries/retryer/CancelledError.d.ts +0 -0
  69. /package/dist/lib/{queries → deprecated}/client/queries/retryer/types.d.ts +0 -0
  70. /package/dist/lib/{queries → deprecated}/client/queries/retryer/utils.d.ts +0 -0
  71. /package/dist/lib/{queries → deprecated}/client/queries/types.d.ts +0 -0
  72. /package/dist/lib/{queries → deprecated}/client/queries/utils.d.ts +0 -0
  73. /package/dist/lib/{queries → deprecated}/client/store.d.ts +0 -0
  74. /package/dist/lib/{queries → deprecated}/client/tests/utils.d.ts +0 -0
  75. /package/dist/lib/{queries → deprecated}/client/types.d.ts +0 -0
  76. /package/dist/lib/{queries → deprecated}/client/utils/keepPreviousData.d.ts +0 -0
  77. /package/dist/lib/{queries → deprecated}/client/utils/makeObservable.d.ts +0 -0
  78. /package/dist/lib/{queries → deprecated}/react/QueryClientProvider.d.ts +0 -0
  79. /package/dist/lib/{queries → deprecated}/react/QueryClientProvider.rq.test.d.ts +0 -0
  80. /package/dist/lib/{queries → deprecated}/react/mutations/types.d.ts +0 -0
  81. /package/dist/lib/{queries → deprecated}/react/mutations/useIsMutating.d.ts +0 -0
  82. /package/dist/lib/{queries → deprecated}/react/mutations/useIsMutating.test.d.ts +0 -0
  83. /package/dist/lib/{queries → deprecated}/react/mutations/useMutation.d.ts +0 -0
  84. /package/dist/lib/{queries → deprecated}/react/mutations/useMutation.keys.test.d.ts +0 -0
  85. /package/dist/lib/{queries → deprecated}/react/mutations/useMutation.rq.test.d.ts +0 -0
  86. /package/dist/lib/{queries → deprecated}/react/mutations/useMutation.switch.test.d.ts +0 -0
  87. /package/dist/lib/{queries → deprecated}/react/mutations/useMutation.test.d.ts +0 -0
  88. /package/dist/lib/{queries → deprecated}/react/mutations/useMutationState.d.ts +0 -0
  89. /package/dist/lib/{queries → deprecated}/react/mutations/useMutationState.test.d.ts +0 -0
  90. /package/dist/lib/{queries → deprecated}/react/queries/QueryErrorResetBoundary.d.ts +0 -0
  91. /package/dist/lib/{queries → deprecated}/react/queries/QueryOptions.rq.types.typeTest.d.ts +0 -0
  92. /package/dist/lib/{queries → deprecated}/react/queries/errorBoundaryUtils.d.ts +0 -0
  93. /package/dist/lib/{queries → deprecated}/react/queries/isRestoring.d.ts +0 -0
  94. /package/dist/lib/{queries → deprecated}/react/queries/queryOptions.d.ts +0 -0
  95. /package/dist/lib/{queries → deprecated}/react/queries/types.d.ts +0 -0
  96. /package/dist/lib/{queries → deprecated}/react/queries/useBaseQuery.d.ts +0 -0
  97. /package/dist/lib/{queries → deprecated}/react/queries/useForeverQuery.d.ts +0 -0
  98. /package/dist/lib/{queries → deprecated}/react/queries/useIsFetching.d.ts +0 -0
  99. /package/dist/lib/{queries → deprecated}/react/queries/useIsFetching.rq.test.d.ts +0 -0
  100. /package/dist/lib/{queries → deprecated}/react/queries/useQuery.d.ts +0 -0
  101. /package/dist/lib/{queries → deprecated}/react/queries/useQuery.deduplication.test.d.ts +0 -0
  102. /package/dist/lib/{queries → deprecated}/react/queries/useQuery.invalidation.test.d.ts +0 -0
  103. /package/dist/lib/{queries → deprecated}/react/queries/useQuery.keys.test.d.ts +0 -0
  104. /package/dist/lib/{queries → deprecated}/react/queries/useQuery.rq.test.d.ts +0 -0
  105. /package/dist/lib/{queries → deprecated}/react/queries/useQuery.rq.types.test.d.ts +0 -0
  106. /package/dist/lib/{queries → deprecated}/react/queries/useQuery.test.d.ts +0 -0
  107. /package/dist/lib/{queries → deprecated}/react/useQueryClient.d.ts +0 -0
package/dist/index.cjs CHANGED
@@ -14,6 +14,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
14
14
  const React = require("react");
15
15
  const rxjs = require("rxjs");
16
16
  const operators = require("rxjs/operators");
17
+ const reactQuery = require("@tanstack/react-query");
17
18
  const jsxRuntime = require("react/jsx-runtime");
18
19
  function _interopNamespaceDefault(e) {
19
20
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
@@ -202,13 +203,20 @@ const useObservableState = (defaultValue) => {
202
203
  );
203
204
  return [subject$.current, setState, subject.current.getValue()];
204
205
  };
206
+ const useLiveBehaviorSubject = (state) => {
207
+ const subject = useBehaviorSubject(state);
208
+ React.useEffect(() => {
209
+ subject.current.next(state);
210
+ }, [state, subject]);
211
+ return subject;
212
+ };
205
213
  const SIGNAL_RESET = Symbol("SIGNAL_RESET");
206
214
  function signal(config = {}) {
207
215
  const normalizedConfig = {
208
216
  default: config.default,
209
217
  key: config.key
210
218
  };
211
- const { default: defaultValue } = normalizedConfig ?? {};
219
+ const { default: defaultValue } = normalizedConfig;
212
220
  const subject = new rxjs.BehaviorSubject(defaultValue);
213
221
  const setValue = (arg) => {
214
222
  const update = (value) => {
@@ -356,13 +364,6 @@ const createLocalStorageAdapter = ({
356
364
  }
357
365
  };
358
366
  };
359
- const useLiveBehaviorSubject = (state) => {
360
- const subject = useBehaviorSubject(state);
361
- React.useEffect(() => {
362
- subject.current.next(state);
363
- }, [state, subject]);
364
- return subject;
365
- };
366
367
  const IDENTIFIER_PERSISTANCE_KEY = "__reactjrx";
367
368
  const getNormalizedPersistanceValue = (unknownValue) => {
368
369
  if (typeof unknownValue === "object" && unknownValue !== null && IDENTIFIER_PERSISTANCE_KEY in unknownValue && unknownValue[IDENTIFIER_PERSISTANCE_KEY] === IDENTIFIER_PERSISTANCE_KEY) {
@@ -652,6 +653,90 @@ function isDefined(arg) {
652
653
  }
653
654
  const arrayEqual = (a, b) => a.length === b.length && a.every((v, i) => v === b[i]);
654
655
  const isServer = typeof window === "undefined" || "Deno" in window;
656
+ function useQuery$(options, queryClient) {
657
+ const sub = React.useRef();
658
+ const _queryClient = reactQuery.useQueryClient(queryClient);
659
+ const queryFnAsync = (context) => {
660
+ let isResolved = false;
661
+ return new Promise((resolve, reject) => {
662
+ let lastData = void 0;
663
+ if (sub.current) {
664
+ sub.current.unsubscribe();
665
+ sub.current = void 0;
666
+ }
667
+ const unsub = _queryClient.getQueryCache().subscribe((d) => {
668
+ var _a;
669
+ if (d.type === "observerRemoved" && d.query.observers.length === 0) {
670
+ unsub();
671
+ _queryClient.cancelQueries({ queryKey: context.queryKey });
672
+ (_a = sub.current) == null ? void 0 : _a.unsubscribe();
673
+ }
674
+ });
675
+ const source = rxjs.defer(
676
+ () => typeof options.queryFn === "function" ? options.queryFn(context) : options.queryFn
677
+ );
678
+ sub.current = source.pipe(
679
+ rxjs.finalize(() => {
680
+ unsub();
681
+ isResolved = true;
682
+ })
683
+ ).subscribe({
684
+ next: (data) => {
685
+ lastData = data;
686
+ _queryClient == null ? void 0 : _queryClient.setQueryData(context.queryKey, data);
687
+ },
688
+ error: (error) => {
689
+ isResolved = true;
690
+ reject(error);
691
+ },
692
+ complete: () => {
693
+ if (lastData === void 0)
694
+ return reject(new Error("Stream completed without any data"));
695
+ if (isResolved) return;
696
+ isResolved = true;
697
+ resolve(lastData);
698
+ }
699
+ });
700
+ });
701
+ };
702
+ const result = reactQuery.useQuery(
703
+ {
704
+ ...options,
705
+ queryFn: queryFnAsync
706
+ },
707
+ queryClient
708
+ );
709
+ return result;
710
+ }
711
+ function useMutation$(options, queryClient) {
712
+ const mutationFnAsync = (variables) => {
713
+ let lastData;
714
+ return new Promise((resolve, reject) => {
715
+ const source = typeof options.mutationFn === "function" ? options.mutationFn(variables) : options.mutationFn;
716
+ source.pipe(rxjs.take(1)).subscribe({
717
+ next: (data) => {
718
+ lastData = data;
719
+ },
720
+ error: (error) => {
721
+ reject(error);
722
+ },
723
+ complete: () => {
724
+ if (lastData === void 0)
725
+ return reject(new Error("Stream completed without any data"));
726
+ resolve(lastData);
727
+ }
728
+ });
729
+ });
730
+ };
731
+ const result = reactQuery.useMutation(
732
+ {
733
+ ...options,
734
+ mutationFn: mutationFnAsync
735
+ },
736
+ queryClient
737
+ );
738
+ return result;
739
+ }
655
740
  function hasObjectPrototype(o) {
656
741
  return Object.prototype.toString.call(o) === "[object Object]";
657
742
  }
@@ -3416,14 +3501,17 @@ exports.signal = signal;
3416
3501
  exports.useBehaviorSubject = useBehaviorSubject;
3417
3502
  exports.useEffectOnce = useEffectOnce;
3418
3503
  exports.useForeverQuery = useForeverQuery;
3504
+ exports.useLiveBehaviorSubject = useLiveBehaviorSubject;
3419
3505
  exports.useLiveRef = useLiveRef;
3420
3506
  exports.useMount = useMount;
3421
3507
  exports.useMutation = useMutation;
3508
+ exports.useMutation$ = useMutation$;
3422
3509
  exports.useObservableState = useObservableState;
3423
3510
  exports.useObserve = useObserve;
3424
3511
  exports.useObserveCallback = useObserveCallback;
3425
3512
  exports.usePersistSignals = usePersistSignals;
3426
3513
  exports.useQuery = useQuery;
3514
+ exports.useQuery$ = useQuery$;
3427
3515
  exports.useQueryClient = useQueryClient;
3428
3516
  exports.useSignal = useSignal;
3429
3517
  exports.useSignalValue = useSignalValue;
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export * from './lib/binding/useObservableEvent';
4
4
  export * from './lib/binding/useObservableState';
5
5
  export * from './lib/binding/useSubject';
6
6
  export * from './lib/binding/useBehaviorSubject';
7
+ export * from './lib/binding/useLiveBehaviorSubject';
7
8
  export * from './lib/state/signal';
8
9
  export * from './lib/state/react/useSignalValue';
9
10
  export * from './lib/state/react/useSignal';
@@ -13,12 +14,14 @@ export * from './lib/state/persistance/adapters/createLocalStorageAdapter';
13
14
  export * from './lib/state/react/usePersistSignals';
14
15
  export { type SignalPersistenceConfig } from './lib/state/persistance/types';
15
16
  export * from './lib/utils';
16
- export * from './lib/queries/react/mutations/useMutation';
17
- export * from './lib/queries/react/queries/useQuery';
18
- export * from './lib/queries/react/useQueryClient';
19
- export * from './lib/queries/react/queries/useForeverQuery';
17
+ export * from './lib/queries/useQuery$';
18
+ export * from './lib/queries/useMutation$';
19
+ export * from './lib/deprecated/react/mutations/useMutation';
20
+ export * from './lib/deprecated/react/queries/useQuery';
21
+ export * from './lib/deprecated/react/useQueryClient';
22
+ export * from './lib/deprecated/react/queries/useForeverQuery';
20
23
  export * from './lib/binding/useSubscribeEffect';
21
- export * from './lib/queries/client/QueryClient';
22
- export { QueryCache } from './lib/queries/client/queries/cache/QueryCache';
23
- export { QueryClientProvider } from './lib/queries/react/QueryClientProvider';
24
- export { MutationCache } from './lib/queries/client/mutations/cache/MutationCache';
24
+ export * from './lib/deprecated/client/QueryClient';
25
+ export { QueryCache } from './lib/deprecated/client/queries/cache/QueryCache';
26
+ export { QueryClientProvider } from './lib/deprecated/react/QueryClientProvider';
27
+ export { MutationCache } from './lib/deprecated/client/mutations/cache/MutationCache';
package/dist/index.js CHANGED
@@ -11,8 +11,9 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
11
11
  var _trigger$, _mutationRunner, _currentMutationSubject, _visibility$, _focusedSubject, _client, _currentQuery, _fetchSubject, _currentQueryInitialState, _lastResult, _lastQueryWithDefinedData, _observers, _observerCount, _cancelSubject, _executeSubject, _store, _defaultOptions, _initialState, _notifySubject, _store2, _mutationCache, _queryCache, _mutationDefaults, _queryDefaults, _defaultOptions2;
12
12
  import * as React from "react";
13
13
  import { useRef, useMemo, useCallback, useSyncExternalStore, useEffect, useState, createContext, memo, useContext } from "react";
14
- import { isObservable, from, of, defer, startWith, identity, distinctUntilChanged, tap, catchError, EMPTY, Subject, BehaviorSubject, skip, first, map, switchMap, zip, share, merge, throttleTime, asyncScheduler, concatMap, scan, throwError, timer, Observable, takeWhile, filter, last, mergeMap as mergeMap$1, takeUntil, shareReplay, ignoreElements, fromEvent, noop as noop$1, pairwise, NEVER, delay, interval, withLatestFrom, retry, iif, isEmpty, concat, toArray, take, combineLatest, endWith, lastValueFrom } from "rxjs";
14
+ import { isObservable, from, of, defer, startWith, identity, distinctUntilChanged, tap, catchError, EMPTY, Subject, BehaviorSubject, skip, first, map, switchMap, zip, share, merge, throttleTime, asyncScheduler, concatMap, scan, throwError, timer, finalize, take, Observable, takeWhile, filter, last, mergeMap as mergeMap$1, takeUntil, shareReplay, ignoreElements, fromEvent, noop as noop$1, pairwise, NEVER, delay, interval, withLatestFrom, retry, iif, isEmpty, concat, toArray, combineLatest, endWith, lastValueFrom } from "rxjs";
15
15
  import { catchError as catchError$1, mergeMap, retryWhen, concatMap as concatMap$1, first as first$1, tap as tap$1 } from "rxjs/operators";
16
+ import { useQueryClient as useQueryClient$1, useQuery as useQuery$1, useMutation as useMutation$1 } from "@tanstack/react-query";
16
17
  import { jsxs, jsx } from "react/jsx-runtime";
17
18
  const useLiveRef = (value) => {
18
19
  const ref = useRef(value);
@@ -184,13 +185,20 @@ const useObservableState = (defaultValue) => {
184
185
  );
185
186
  return [subject$.current, setState, subject.current.getValue()];
186
187
  };
188
+ const useLiveBehaviorSubject = (state) => {
189
+ const subject = useBehaviorSubject(state);
190
+ useEffect(() => {
191
+ subject.current.next(state);
192
+ }, [state, subject]);
193
+ return subject;
194
+ };
187
195
  const SIGNAL_RESET = Symbol("SIGNAL_RESET");
188
196
  function signal(config = {}) {
189
197
  const normalizedConfig = {
190
198
  default: config.default,
191
199
  key: config.key
192
200
  };
193
- const { default: defaultValue } = normalizedConfig ?? {};
201
+ const { default: defaultValue } = normalizedConfig;
194
202
  const subject = new BehaviorSubject(defaultValue);
195
203
  const setValue = (arg) => {
196
204
  const update = (value) => {
@@ -338,13 +346,6 @@ const createLocalStorageAdapter = ({
338
346
  }
339
347
  };
340
348
  };
341
- const useLiveBehaviorSubject = (state) => {
342
- const subject = useBehaviorSubject(state);
343
- useEffect(() => {
344
- subject.current.next(state);
345
- }, [state, subject]);
346
- return subject;
347
- };
348
349
  const IDENTIFIER_PERSISTANCE_KEY = "__reactjrx";
349
350
  const getNormalizedPersistanceValue = (unknownValue) => {
350
351
  if (typeof unknownValue === "object" && unknownValue !== null && IDENTIFIER_PERSISTANCE_KEY in unknownValue && unknownValue[IDENTIFIER_PERSISTANCE_KEY] === IDENTIFIER_PERSISTANCE_KEY) {
@@ -634,6 +635,90 @@ function isDefined(arg) {
634
635
  }
635
636
  const arrayEqual = (a, b) => a.length === b.length && a.every((v, i) => v === b[i]);
636
637
  const isServer = typeof window === "undefined" || "Deno" in window;
638
+ function useQuery$(options, queryClient) {
639
+ const sub = useRef();
640
+ const _queryClient = useQueryClient$1(queryClient);
641
+ const queryFnAsync = (context) => {
642
+ let isResolved = false;
643
+ return new Promise((resolve, reject) => {
644
+ let lastData = void 0;
645
+ if (sub.current) {
646
+ sub.current.unsubscribe();
647
+ sub.current = void 0;
648
+ }
649
+ const unsub = _queryClient.getQueryCache().subscribe((d) => {
650
+ var _a;
651
+ if (d.type === "observerRemoved" && d.query.observers.length === 0) {
652
+ unsub();
653
+ _queryClient.cancelQueries({ queryKey: context.queryKey });
654
+ (_a = sub.current) == null ? void 0 : _a.unsubscribe();
655
+ }
656
+ });
657
+ const source = defer(
658
+ () => typeof options.queryFn === "function" ? options.queryFn(context) : options.queryFn
659
+ );
660
+ sub.current = source.pipe(
661
+ finalize(() => {
662
+ unsub();
663
+ isResolved = true;
664
+ })
665
+ ).subscribe({
666
+ next: (data) => {
667
+ lastData = data;
668
+ _queryClient == null ? void 0 : _queryClient.setQueryData(context.queryKey, data);
669
+ },
670
+ error: (error) => {
671
+ isResolved = true;
672
+ reject(error);
673
+ },
674
+ complete: () => {
675
+ if (lastData === void 0)
676
+ return reject(new Error("Stream completed without any data"));
677
+ if (isResolved) return;
678
+ isResolved = true;
679
+ resolve(lastData);
680
+ }
681
+ });
682
+ });
683
+ };
684
+ const result = useQuery$1(
685
+ {
686
+ ...options,
687
+ queryFn: queryFnAsync
688
+ },
689
+ queryClient
690
+ );
691
+ return result;
692
+ }
693
+ function useMutation$(options, queryClient) {
694
+ const mutationFnAsync = (variables) => {
695
+ let lastData;
696
+ return new Promise((resolve, reject) => {
697
+ const source = typeof options.mutationFn === "function" ? options.mutationFn(variables) : options.mutationFn;
698
+ source.pipe(take(1)).subscribe({
699
+ next: (data) => {
700
+ lastData = data;
701
+ },
702
+ error: (error) => {
703
+ reject(error);
704
+ },
705
+ complete: () => {
706
+ if (lastData === void 0)
707
+ return reject(new Error("Stream completed without any data"));
708
+ resolve(lastData);
709
+ }
710
+ });
711
+ });
712
+ };
713
+ const result = useMutation$1(
714
+ {
715
+ ...options,
716
+ mutationFn: mutationFnAsync
717
+ },
718
+ queryClient
719
+ );
720
+ return result;
721
+ }
637
722
  function hasObjectPrototype(o) {
638
723
  return Object.prototype.toString.call(o) === "[object Object]";
639
724
  }
@@ -3399,14 +3484,17 @@ export {
3399
3484
  useBehaviorSubject,
3400
3485
  useEffectOnce,
3401
3486
  useForeverQuery,
3487
+ useLiveBehaviorSubject,
3402
3488
  useLiveRef,
3403
3489
  useMount,
3404
3490
  useMutation,
3491
+ useMutation$,
3405
3492
  useObservableState,
3406
3493
  useObserve,
3407
3494
  useObserveCallback,
3408
3495
  usePersistSignals,
3409
3496
  useQuery,
3497
+ useQuery$,
3410
3498
  useQueryClient,
3411
3499
  useSignal,
3412
3500
  useSignalValue,
@@ -1,4 +1,5 @@
1
1
  import { MutationOptions, MutationState } from './types';
2
+ import { DefaultError } from '../../types';
2
3
  export declare const executeMutation: <TData = unknown, TError = Error, TVariables = void, TContext = unknown>({ variables, state, options }: {
3
4
  variables: TVariables;
4
5
  state: MutationState<TData, TError, TVariables, TContext>;
@@ -1,2 +1,3 @@
1
+ import { DefaultError } from '../../types';
1
2
  import { MutationFilters } from '../types';
2
3
  export declare const createPredicateForFilters: <TData = unknown, TError = Error, TVariables = any, TContext = unknown>({ mutationKey, status, predicate, exact }?: MutationFilters<TData, TError, TVariables, TContext>) => (mutation: import('../mutation/Mutation').Mutation<TData, TError, TVariables, TContext>) => boolean;
@@ -1,5 +1,6 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { QueryKey } from '../../../keys/types';
3
+ import { DefaultError } from '../../../types';
3
4
  import { QueryState } from '../types';
4
5
  import { QueryOptions } from '../../types';
5
6
  export declare const executeQuery: <TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: QueryOptions<TQueryFnData, TError, TData, TQueryKey> & {
@@ -1,3 +1,4 @@
1
+ import { DefaultError } from '../../types';
1
2
  import { Observable } from 'rxjs';
2
3
  import { QueryOptions } from '../types';
3
4
  import { QueryState } from './types';
@@ -1,4 +1,5 @@
1
1
  import { Observable } from 'rxjs';
2
+ import { DefaultError } from '../../../types';
2
3
  import { QueryState } from '../types';
3
4
  export declare const whenNewData: <TQueryFnData = unknown, TError = Error, TData = TQueryFnData>(source: Observable<Partial<QueryState<TData, TError>>>) => Observable<{
4
5
  data: TData | undefined;
@@ -9,18 +9,18 @@ export declare function createLogger(env: string): {
9
9
  namespace(name: string, style?: {
10
10
  backgroundColor: string;
11
11
  color: string;
12
- }): any;
12
+ }): /*elided*/ any;
13
13
  printNamespaces(): {
14
14
  namespaces: string;
15
15
  styles: string[];
16
16
  };
17
- print(method: "log" | "warn" | "error" | "group", ...message: any[]): any;
18
- printWithoutNamespace(method: "log" | "warn" | "error" | "group", ...message: any[]): any;
19
- log(...message: any): any;
20
- warn(...message: any): any;
21
- error(...message: any): any;
22
- group(...message: any): any;
23
- groupEnd(): any;
17
+ print(method: "log" | "warn" | "error" | "group", ...message: any[]): /*elided*/ any;
18
+ printWithoutNamespace(method: "log" | "warn" | "error" | "group", ...message: any[]): /*elided*/ any;
19
+ log(...message: any): /*elided*/ any;
20
+ warn(...message: any): /*elided*/ any;
21
+ error(...message: any): /*elided*/ any;
22
+ group(...message: any): /*elided*/ any;
23
+ groupEnd(): /*elided*/ any;
24
24
  };
25
25
  export declare const Logger: {
26
26
  namespaces: {
@@ -33,16 +33,16 @@ export declare const Logger: {
33
33
  namespace(name: string, style?: {
34
34
  backgroundColor: string;
35
35
  color: string;
36
- }): any;
36
+ }): /*elided*/ any;
37
37
  printNamespaces(): {
38
38
  namespaces: string;
39
39
  styles: string[];
40
40
  };
41
- print(method: "log" | "warn" | "error" | "group", ...message: any[]): any;
42
- printWithoutNamespace(method: "log" | "warn" | "error" | "group", ...message: any[]): any;
43
- log(...message: any): any;
44
- warn(...message: any): any;
45
- error(...message: any): any;
46
- group(...message: any): any;
47
- groupEnd(): any;
41
+ print(method: "log" | "warn" | "error" | "group", ...message: any[]): /*elided*/ any;
42
+ printWithoutNamespace(method: "log" | "warn" | "error" | "group", ...message: any[]): /*elided*/ any;
43
+ log(...message: any): /*elided*/ any;
44
+ warn(...message: any): /*elided*/ any;
45
+ error(...message: any): /*elided*/ any;
46
+ group(...message: any): /*elided*/ any;
47
+ groupEnd(): /*elided*/ any;
48
48
  };
@@ -0,0 +1,5 @@
1
+ import { DefaultError, QueryClient, UseMutationOptions } from '@tanstack/react-query';
2
+ import { Observable } from 'rxjs';
3
+ export declare function useMutation$<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown>(options: Omit<UseMutationOptions<TData, TError, TVariables, TContext>, "mutationFn"> & {
4
+ mutationFn: ((variables: TVariables) => Observable<TData>) | Observable<TData>;
5
+ }, queryClient?: QueryClient): import('@tanstack/react-query').UseMutationResult<TData, TError, TVariables, TContext>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import { DefaultError, QueryClient, QueryFunctionContext, QueryKey, UseQueryOptions } from '@tanstack/react-query';
2
+ import { Observable } from 'rxjs';
3
+ export declare function useQuery$<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: Omit<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, "queryFn"> & {
4
+ queryFn: ((context: QueryFunctionContext<TQueryKey>) => Observable<TQueryFnData>) | Observable<TQueryFnData>;
5
+ }, queryClient?: QueryClient): import('@tanstack/react-query').UseQueryResult<TData, TError>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { render } from '@testing-library/react';
2
- import { QueryClient, QueryClientConfig } from '../lib/queries/client/QueryClient';
2
+ import { QueryClient, QueryClientConfig } from '../lib/deprecated/client/QueryClient';
3
3
  import { default as React } from 'react';
4
4
  export declare const waitForTimeout: (timeout: number) => Promise<undefined>;
5
5
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "reactjrx",
3
3
  "private": false,
4
- "version": "1.101.1",
4
+ "version": "1.105.1",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"
@@ -14,9 +14,6 @@
14
14
  "require": "./dist/index.umd.cjs"
15
15
  }
16
16
  },
17
- "engines": {
18
- "node": "20"
19
- },
20
17
  "types": "./dist/index.d.ts",
21
18
  "publishConfig": {
22
19
  "access": "public"
@@ -37,10 +34,10 @@
37
34
  "peerDependencies": {
38
35
  "react": "18",
39
36
  "react-dom": "18",
40
- "rxjs": "*"
37
+ "rxjs": "*",
38
+ "@tanstack/react-query": "^5.8.4"
41
39
  },
42
40
  "devDependencies": {
43
- "@tanstack/react-query": "^5.8.4",
44
41
  "@testing-library/jest-dom": "^6.2.0",
45
42
  "@testing-library/react": "^16.0.0",
46
43
  "@types/node": "^20.0.0",