reactjrx 1.112.0 → 1.113.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/dist/index.cjs CHANGED
@@ -1,951 +1,2 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
6
- const react = require("react");
7
- const rxjs = require("rxjs");
8
- const operators = require("rxjs/operators");
9
- const reactQuery = require("@tanstack/react-query");
10
- const jsxRuntime = require("react/jsx-runtime");
11
- const useLiveRef = (value) => {
12
- const ref = react.useRef(value);
13
- react.useMemo(() => {
14
- ref.current = value;
15
- }, [value]);
16
- return ref;
17
- };
18
- function isPromiseLike(value) {
19
- return value instanceof Promise || value && typeof value === "object" && "then" in value && typeof value.then === "function" && "catch" in value && value.catch === "function";
20
- }
21
- function makeObservable(something) {
22
- if (rxjs.isObservable(something)) return () => something;
23
- if (isPromiseLike(something)) return () => rxjs.from(something);
24
- if (typeof something !== "function") return () => rxjs.of(something);
25
- const somethingAsFunction = something;
26
- return (params) => rxjs.defer(() => {
27
- const result = somethingAsFunction(params);
28
- if (isPromiseLike(result)) {
29
- return rxjs.from(result);
30
- }
31
- if (rxjs.isObservable(result)) {
32
- return result;
33
- }
34
- return rxjs.of(result);
35
- });
36
- }
37
- function useObserve(source$, optionsOrDeps, maybeDeps) {
38
- const options = optionsOrDeps != null && !Array.isArray(optionsOrDeps) ? optionsOrDeps : {
39
- defaultValue: void 0,
40
- unsubscribeOnUnmount: true,
41
- compareFn: void 0
42
- };
43
- const deps = !maybeDeps && Array.isArray(optionsOrDeps) ? optionsOrDeps : typeof source$ === "function" ? maybeDeps ?? [] : [source$];
44
- const valueRef = react.useRef(
45
- "getValue" in source$ && typeof source$.getValue === "function" ? source$.getValue() : options.defaultValue
46
- );
47
- const sourceRef = useLiveRef(source$);
48
- const optionsRef = useLiveRef(options);
49
- const getSnapshot = react.useCallback(() => {
50
- return valueRef.current;
51
- }, []);
52
- const subscribe = react.useCallback(
53
- (next) => {
54
- const source = sourceRef.current;
55
- const sub = makeObservable(source)().pipe(
56
- optionsRef.current.defaultValue ? rxjs.startWith(optionsRef.current.defaultValue) : rxjs.identity,
57
- /**
58
- * @important there is already a Object.is comparison in place from react
59
- * so we only add a custom compareFn if provided
60
- */
61
- optionsRef.current.compareFn ? rxjs.distinctUntilChanged((a, b) => {
62
- if (a === void 0 || b === void 0) return false;
63
- return optionsRef.current.compareFn(a, b);
64
- }) : rxjs.identity,
65
- rxjs.tap((value) => {
66
- valueRef.current = value;
67
- }),
68
- rxjs.catchError((error) => {
69
- console.error(error);
70
- return rxjs.EMPTY;
71
- })
72
- ).subscribe(next);
73
- return () => {
74
- if (optionsRef.current.unsubscribeOnUnmount === false) return;
75
- sub.unsubscribe();
76
- };
77
- },
78
- // eslint-disable-next-line react-hooks/exhaustive-deps
79
- [...deps]
80
- );
81
- const result = react.useSyncExternalStore(subscribe, getSnapshot);
82
- return result;
83
- }
84
- function useSubscribe(source, deps = []) {
85
- const sourceRef = useLiveRef(source);
86
- react.useEffect(() => {
87
- const sub = makeObservable(sourceRef.current)().pipe(
88
- rxjs.catchError((error) => {
89
- console.error(error);
90
- return rxjs.EMPTY;
91
- })
92
- ).subscribe();
93
- return () => {
94
- sub.unsubscribe();
95
- };
96
- }, [
97
- // eslint-disable-next-line react-hooks/exhaustive-deps
98
- ...deps,
99
- sourceRef
100
- ]);
101
- }
102
- const useConstant = (fn) => {
103
- const ref = react.useRef(void 0);
104
- if (!ref.current) {
105
- ref.current = fn();
106
- }
107
- react.useEffect(() => {
108
- if (process.env.NODE_ENV === "development") ;
109
- }, []);
110
- return ref;
111
- };
112
- const useSubject = ({
113
- onBeforeComplete,
114
- completeOnUnmount = true
115
- } = {}) => {
116
- const subject = useConstant(() => new rxjs.Subject());
117
- const completed = react.useRef(false);
118
- const onBeforeCompleteRef = useLiveRef(onBeforeComplete);
119
- const completeOnUnmountRef = useLiveRef(completeOnUnmount);
120
- react.useEffect(() => {
121
- if (completed.current) {
122
- subject.current = new rxjs.Subject();
123
- completed.current = false;
124
- }
125
- return () => {
126
- if (!completeOnUnmountRef.current) {
127
- completed.current = true;
128
- return;
129
- }
130
- if (!completed.current) {
131
- if (onBeforeCompleteRef.current != null) onBeforeCompleteRef.current();
132
- subject.current.complete();
133
- completed.current = true;
134
- }
135
- };
136
- }, [completeOnUnmountRef, onBeforeCompleteRef, subject]);
137
- return subject;
138
- };
139
- const useObservableCallback = () => {
140
- const subject = useSubject();
141
- const trigger = react.useCallback(
142
- (arg) => {
143
- subject.current.next(arg);
144
- },
145
- // eslint-disable-next-line react-hooks/exhaustive-deps
146
- []
147
- );
148
- return [subject.current, trigger];
149
- };
150
- const useBehaviorSubject = (state) => {
151
- const subject = useConstant(() => new rxjs.BehaviorSubject(state));
152
- const completed = react.useRef(false);
153
- const stateRef = react.useRef(state);
154
- react.useEffect(() => {
155
- if (completed.current) {
156
- subject.current = new rxjs.BehaviorSubject(stateRef.current);
157
- completed.current = false;
158
- }
159
- return () => {
160
- if (!completed.current) {
161
- subject.current.complete();
162
- completed.current = true;
163
- }
164
- };
165
- }, [subject]);
166
- return subject;
167
- };
168
- const useObservableState = (defaultValue) => {
169
- const subject = useBehaviorSubject(defaultValue);
170
- const subject$ = useLiveRef(subject.current.asObservable());
171
- const setState = react.useCallback(
172
- (value) => {
173
- subject.current.next(value);
174
- },
175
- // eslint-disable-next-line react-hooks/exhaustive-deps
176
- [subject.current]
177
- );
178
- return [subject$.current, setState, subject.current.getValue()];
179
- };
180
- const useLiveBehaviorSubject = (state) => {
181
- const subject = useBehaviorSubject(state);
182
- react.useEffect(() => {
183
- subject.current.next(state);
184
- }, [state, subject]);
185
- return subject;
186
- };
187
- function useSubscribeEffect(source, unsafeOptions, deps = []) {
188
- const options = unsafeOptions != null && !Array.isArray(unsafeOptions) ? unsafeOptions : {};
189
- const retryOption = options.retry ?? true;
190
- const onErrorRef = useLiveRef(
191
- options.onError ?? ((error) => {
192
- console.error(error);
193
- })
194
- );
195
- const sourceAsObservable = react.useCallback(() => makeObservable(source)(), deps);
196
- const enhancerMakeObservable = react.useCallback(
197
- () => sourceAsObservable().pipe(
198
- rxjs.catchError((error) => {
199
- onErrorRef.current(error);
200
- throw error;
201
- }),
202
- retryOption ? rxjs.retry() : rxjs.identity
203
- ),
204
- [sourceAsObservable, retryOption, onErrorRef]
205
- );
206
- useSubscribe(enhancerMakeObservable, deps);
207
- }
208
- const SIGNAL_RESET = Symbol("SIGNAL_RESET");
209
- function signal(config = {}) {
210
- const normalizedConfig = {
211
- default: config.default,
212
- key: config.key
213
- };
214
- const { default: defaultValue } = normalizedConfig;
215
- const subject = new rxjs.BehaviorSubject(defaultValue);
216
- const setValue = (arg) => {
217
- const update = (value) => {
218
- if ("key" in config) {
219
- console.log(
220
- "[reactjrx][state][signal]:",
221
- `Value update for signal ${config.key}`,
222
- { prev: subject.getValue(), curr: value }
223
- );
224
- }
225
- subject.next(value);
226
- };
227
- if (typeof arg === "function") {
228
- const change = arg(subject.getValue());
229
- if (change === subject.getValue()) return;
230
- return update(change);
231
- }
232
- if (arg === SIGNAL_RESET) {
233
- if (defaultValue === subject.getValue()) return;
234
- return update(defaultValue ?? void 0);
235
- }
236
- if (arg === subject.getValue()) return;
237
- return update(arg);
238
- };
239
- const getValue = () => subject.getValue();
240
- if ("get" in config) {
241
- const getter = (signal2) => {
242
- signal2.subject.pipe(rxjs.skip(1), rxjs.first()).subscribe(() => {
243
- var _a;
244
- const newValue = (_a = config.get) == null ? void 0 : _a.call(config, getter);
245
- setValue(newValue);
246
- });
247
- return signal2.getValue();
248
- };
249
- const defaultValue2 = config.get(getter);
250
- setValue(defaultValue2);
251
- return {
252
- getValue,
253
- config,
254
- subject
255
- };
256
- }
257
- return {
258
- setValue,
259
- getValue,
260
- config: normalizedConfig,
261
- subject
262
- };
263
- }
264
- function useSignalValue(signal2, selector) {
265
- const defaultSelector = () => signal2.getValue();
266
- const selectorOrDefault = selector ?? defaultSelector;
267
- return useObserve(
268
- () => {
269
- const observed$ = signal2.subject.pipe(
270
- rxjs.map((value) => {
271
- const selectedValue = selectorOrDefault(value);
272
- return selectedValue;
273
- }),
274
- rxjs.distinctUntilChanged()
275
- );
276
- return observed$;
277
- },
278
- {
279
- defaultValue: selectorOrDefault(signal2.getValue())
280
- },
281
- []
282
- );
283
- }
284
- const useSignal = (config) => {
285
- const [stateSignal] = react.useState(() => signal(config));
286
- const value = useSignalValue(stateSignal);
287
- return [value, stateSignal];
288
- };
289
- const createLocalforageAdapter = (forage) => ({
290
- getItem: async (key) => {
291
- const serializedValue = await forage.getItem(key);
292
- if (!serializedValue) return void 0;
293
- return JSON.parse(serializedValue);
294
- },
295
- setItem: async (key, value) => {
296
- await forage.setItem(key, JSON.stringify(value));
297
- },
298
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
299
- removeItem: async (_) => {
300
- },
301
- clear: async () => {
302
- }
303
- });
304
- const normalizeStore = (store) => {
305
- if (!store || typeof store !== "object") {
306
- return void 0;
307
- }
308
- return store;
309
- };
310
- const createSharedStoreAdapter = ({
311
- adapter,
312
- key
313
- }) => ({
314
- clear: async () => {
315
- return await adapter.removeItem(key);
316
- },
317
- removeItem: async (keyToDelete) => {
318
- const unsafeStore = await adapter.getItem(key);
319
- const { [keyToDelete]: toRemove, ...rest } = normalizeStore(unsafeStore) ?? {};
320
- await adapter.setItem(key, rest);
321
- },
322
- getItem: async (itemKey) => {
323
- const unsafeStore = await adapter.getItem(key);
324
- const store = normalizeStore(unsafeStore) ?? {};
325
- if (itemKey in store) {
326
- return store[itemKey];
327
- }
328
- return void 0;
329
- },
330
- setItem: async (itemKey, value) => {
331
- const unsafeStore = await adapter.getItem(key);
332
- const store = normalizeStore(unsafeStore) ?? {};
333
- await adapter.setItem(key, { ...store, [itemKey]: value });
334
- }
335
- });
336
- const createLocalStorageAdapter = ({
337
- key
338
- } = {}) => {
339
- if (key) {
340
- return createSharedStoreAdapter({
341
- adapter: createLocalStorageAdapter(),
342
- key
343
- });
344
- }
345
- return {
346
- clear: async () => {
347
- localStorage.clear();
348
- },
349
- removeItem: async (key2) => {
350
- localStorage.removeItem(key2);
351
- },
352
- getItem: async (key2) => {
353
- const serializedValue = localStorage.getItem(key2);
354
- if (!serializedValue) return void 0;
355
- return JSON.parse(serializedValue);
356
- },
357
- setItem: async (key2, value) => {
358
- localStorage.setItem(key2, JSON.stringify(value));
359
- }
360
- };
361
- };
362
- const IDENTIFIER_PERSISTANCE_KEY = "__reactjrx";
363
- const getNormalizedPersistanceValue = (unknownValue) => {
364
- if (typeof unknownValue === "object" && unknownValue !== null && IDENTIFIER_PERSISTANCE_KEY in unknownValue && unknownValue[IDENTIFIER_PERSISTANCE_KEY] === IDENTIFIER_PERSISTANCE_KEY) {
365
- return unknownValue;
366
- }
367
- return void 0;
368
- };
369
- const persistValue = ({
370
- adapter,
371
- config
372
- }) => {
373
- const { signal: signal2, version } = config;
374
- const state = signal2.getValue();
375
- const value = {
376
- value: state,
377
- [IDENTIFIER_PERSISTANCE_KEY]: IDENTIFIER_PERSISTANCE_KEY,
378
- migrationVersion: version
379
- };
380
- if (process.env.NODE_ENV === "development") {
381
- console.log(
382
- "[reactjrx][state][persistance]:",
383
- `Persist value`,
384
- value,
385
- `for signal ${signal2.config.key}`
386
- );
387
- }
388
- return rxjs.from(adapter.setItem(signal2.config.key, value)).pipe(
389
- rxjs.catchError((e) => {
390
- console.error(e);
391
- return rxjs.of(null);
392
- })
393
- );
394
- };
395
- function hydrateValueToSignal({
396
- adapter,
397
- config
398
- }) {
399
- const { hydrate = ({ value }) => value, signal: signal2, version } = config;
400
- return rxjs.from(adapter.getItem(signal2.config.key)).pipe(
401
- rxjs.switchMap((value) => {
402
- const normalizedValue = getNormalizedPersistanceValue(value);
403
- if (!normalizedValue) return rxjs.of(value);
404
- const storedVersionIsInvalid = typeof normalizedValue.migrationVersion !== "number";
405
- const signalVersionIsSuperior = normalizedValue.migrationVersion !== void 0 && version > normalizedValue.migrationVersion;
406
- if (storedVersionIsInvalid || signalVersionIsSuperior || normalizedValue.value === void 0) {
407
- return rxjs.of(value);
408
- }
409
- const correctVersionValue = normalizedValue.value;
410
- if (process.env.NODE_ENV === "development") {
411
- console.log(
412
- "[reactjrx][state][persistance]:",
413
- `Hydrate value`,
414
- normalizedValue,
415
- `for signal ${signal2.config.key}`
416
- );
417
- }
418
- signal2.setValue(hydrate({ value: correctVersionValue, version }));
419
- return rxjs.of(value);
420
- })
421
- );
422
- }
423
- function persistSignals({
424
- entries = [],
425
- onHydrated,
426
- adapter
427
- }) {
428
- const signalsHydrated$ = entries.length === 0 ? rxjs.of([]) : rxjs.zip(
429
- ...entries.map(
430
- (config) => hydrateValueToSignal({
431
- adapter,
432
- config
433
- })
434
- )
435
- );
436
- const isHydrated$ = signalsHydrated$.pipe(
437
- rxjs.tap(onHydrated),
438
- rxjs.catchError((error) => {
439
- console.error("Unable to hydrate", error);
440
- return rxjs.EMPTY;
441
- }),
442
- rxjs.share()
443
- );
444
- const persisted$ = isHydrated$.pipe(
445
- rxjs.switchMap(
446
- () => rxjs.merge(
447
- ...entries.map(
448
- (config) => config.signal.subject.pipe(
449
- rxjs.throttleTime(500, rxjs.asyncScheduler, {
450
- trailing: true
451
- }),
452
- rxjs.switchMap(
453
- () => rxjs.from(
454
- persistValue({
455
- adapter,
456
- config
457
- })
458
- )
459
- )
460
- )
461
- )
462
- )
463
- )
464
- );
465
- return rxjs.merge(
466
- isHydrated$.pipe(
467
- rxjs.map(() => ({
468
- type: "hydrated"
469
- }))
470
- ),
471
- persisted$.pipe(
472
- rxjs.map(() => ({
473
- type: "persisted"
474
- }))
475
- )
476
- );
477
- }
478
- function shallowEqual(objA, objB) {
479
- if (objA === null || objA === void 0 || objB === void 0) {
480
- return objA === objB;
481
- }
482
- if (typeof objA !== "object" || typeof objB !== "object") {
483
- return objA === objB;
484
- }
485
- if (objA.constructor !== (objB == null ? void 0 : objB.constructor)) {
486
- return false;
487
- }
488
- const keysA = Object.keys(objA);
489
- const keysB = Object.keys(objB);
490
- if (keysA.length !== keysB.length) {
491
- return false;
492
- }
493
- for (const key of keysA) {
494
- if (!objB.hasOwnProperty(key) || objA[key] !== objB[key]) {
495
- return false;
496
- }
497
- }
498
- return true;
499
- }
500
- function usePersistSignals({
501
- entries = [],
502
- onHydrated,
503
- adapter
504
- }) {
505
- const onHydratedRef = useLiveRef(onHydrated);
506
- const adapterSubject = useLiveBehaviorSubject(adapter);
507
- const entriesSubject = useLiveBehaviorSubject(entries);
508
- return useObserve(
509
- () => {
510
- const persistence$ = adapterSubject.current.pipe(
511
- rxjs.switchMap((adapter2) => {
512
- if (!adapter2) return rxjs.of({ type: "reset" });
513
- return rxjs.merge(
514
- rxjs.of({ type: "reset" }),
515
- entriesSubject.current.pipe(
516
- rxjs.concatMap(
517
- (entries2) => persistSignals({
518
- adapter: adapter2,
519
- entries: entries2,
520
- onHydrated: () => {
521
- var _a;
522
- (_a = onHydratedRef.current) == null ? void 0 : _a.call(onHydratedRef);
523
- }
524
- })
525
- )
526
- )
527
- );
528
- })
529
- );
530
- return persistence$.pipe(
531
- rxjs.scan(
532
- (acc, event) => {
533
- if (event.type === "reset") return { isHydrated: false };
534
- if (event.type === "hydrated") return { isHydrated: true };
535
- return acc;
536
- },
537
- { isHydrated: false }
538
- )
539
- );
540
- },
541
- { defaultValue: { isHydrated: false }, compareFn: shallowEqual },
542
- [adapterSubject, entriesSubject]
543
- );
544
- }
545
- const useUnmountObservable = () => {
546
- const subject = useSubject({
547
- onBeforeComplete: () => {
548
- subject.current.next();
549
- }
550
- });
551
- return subject;
552
- };
553
- const useEffectOnce = (effect) => {
554
- react.useEffect(effect, []);
555
- };
556
- const useMount = (fn) => {
557
- useEffectOnce(() => {
558
- fn();
559
- });
560
- };
561
- function getDelay(backoffDelay, maxInterval) {
562
- return Math.min(backoffDelay, maxInterval);
563
- }
564
- function exponentialBackoffDelay(iteration, initialInterval) {
565
- return Math.pow(2, iteration) * initialInterval;
566
- }
567
- function retryBackoff(config) {
568
- const {
569
- retry,
570
- retryDelay,
571
- retryAfterDelay,
572
- retryAfter = () => rxjs.of(true)
573
- } = config;
574
- const maxRetries = typeof retry !== "function" ? retry === false ? 0 : retry === true ? Infinity : retry ?? Infinity : Infinity;
575
- const shouldRetry = typeof retry === "function" ? (
576
- // ? (attempt: number, error: TError) => of(retry(attempt, error))
577
- retry
578
- ) : () => true;
579
- const initialInterval = typeof retryDelay === "number" ? retryDelay : 100;
580
- const normalizedConfig = {
581
- shouldRetry,
582
- ...config
583
- };
584
- const {
585
- maxInterval = Infinity,
586
- resetOnSuccess = false,
587
- backoffDelay = exponentialBackoffDelay
588
- } = normalizedConfig;
589
- return (source) => rxjs.defer(() => {
590
- let caughtErrors = 0;
591
- const shouldRetryFn = (attempt, error) => attempt < maxRetries ? shouldRetry(attempt, error) : false;
592
- return source.pipe(
593
- operators.catchError((error) => {
594
- var _a;
595
- caughtErrors++;
596
- if (!shouldRetryFn(caughtErrors - 1, error)) throw error;
597
- const caughtErrorResult$ = (_a = config.caughtError) == null ? void 0 : _a.call(config, caughtErrors, error);
598
- if (!caughtErrorResult$) throw error;
599
- return caughtErrorResult$.pipe(
600
- operators.mergeMap(
601
- (source2) => rxjs.merge(
602
- rxjs.of(source2),
603
- rxjs.throwError(() => error)
604
- )
605
- )
606
- );
607
- }),
608
- operators.retryWhen((errors) => {
609
- return errors.pipe(
610
- operators.concatMap((error) => {
611
- const attempt = caughtErrors - 1;
612
- return retryAfter().pipe(
613
- operators.first(),
614
- operators.mergeMap(
615
- () => shouldRetryFn(attempt, error) ? rxjs.timer(
616
- getDelay(
617
- backoffDelay(attempt, initialInterval),
618
- maxInterval
619
- )
620
- ).pipe(
621
- operators.mergeMap((timer2) => {
622
- if (retryAfterDelay && !retryAfterDelay(attempt, error))
623
- return rxjs.throwError(() => error);
624
- return rxjs.of(timer2);
625
- })
626
- ) : rxjs.throwError(() => error)
627
- )
628
- );
629
- })
630
- );
631
- }),
632
- operators.catchError((e) => {
633
- if (config.catchError) {
634
- return config.catchError(caughtErrors, e);
635
- }
636
- throw e;
637
- }),
638
- operators.tap(() => {
639
- if (resetOnSuccess) {
640
- caughtErrors = 0;
641
- }
642
- })
643
- );
644
- });
645
- }
646
- function isDefined(arg) {
647
- return arg !== null && arg !== void 0;
648
- }
649
- const arrayEqual = (a, b) => a.length === b.length && a.every((v, i) => v === b[i]);
650
- const isServer = typeof window === "undefined" || "Deno" in window;
651
- class QueryClient$ {
652
- constructor() {
653
- __publicField(this, "queryMap", /* @__PURE__ */ new Map());
654
- }
655
- getQuery(queryHash) {
656
- return this.queryMap.get(queryHash);
657
- }
658
- setQuery(queryKey, query$, signal2) {
659
- const queryHash = reactQuery.hashKey(queryKey);
660
- const sharedQuery$ = query$.pipe(
661
- /**
662
- * abort signal is triggered on:
663
- * - manual cancellation from user
664
- * - unmounting the component
665
- * @see https://tanstack.com/query/latest/docs/framework/react/guides/query-cancellation
666
- */
667
- rxjs.takeUntil(rxjs.fromEvent(signal2, "abort")),
668
- rxjs.share()
669
- );
670
- const cacheEntry = {
671
- query$: sharedQuery$,
672
- signal: signal2,
673
- sub: void 0,
674
- isCompleted: false,
675
- lastData: void 0
676
- };
677
- this.queryMap.set(queryHash, cacheEntry);
678
- const sub = sharedQuery$.subscribe({
679
- next: (data) => {
680
- const entry = this.queryMap.get(queryHash);
681
- if (entry) {
682
- entry.lastData = { value: data };
683
- }
684
- },
685
- complete: () => {
686
- this.deleteQuery(queryHash);
687
- }
688
- });
689
- cacheEntry.sub = sub;
690
- return cacheEntry;
691
- }
692
- deleteQuery(queryHash) {
693
- const entry = this.queryMap.get(queryHash);
694
- if (!entry) return;
695
- if (entry.sub) {
696
- entry.sub.unsubscribe();
697
- entry.sub = void 0;
698
- }
699
- entry.isCompleted = true;
700
- this.queryMap.delete(queryHash);
701
- }
702
- destroy() {
703
- this.queryMap.forEach((_, key) => {
704
- this.deleteQuery(key);
705
- });
706
- }
707
- }
708
- const Context = react.createContext(void 0);
709
- const QueryClientProvider$ = react.memo(
710
- ({
711
- children,
712
- client: _client
713
- }) => {
714
- const [client] = react.useState(() => _client ?? new QueryClient$());
715
- react.useEffect(() => {
716
- return () => {
717
- client.destroy();
718
- };
719
- }, [client]);
720
- return /* @__PURE__ */ jsxRuntime.jsx(Context.Provider, { value: client, children });
721
- }
722
- );
723
- const useQueryClient$ = () => {
724
- const client = react.useContext(Context);
725
- if (!client) {
726
- throw new Error(
727
- "useReactJrxQueryClient must be used within a ReactJrxQueryProvider"
728
- );
729
- }
730
- return client;
731
- };
732
- function useQuery$(options, queryClient) {
733
- const _queryClient = reactQuery.useQueryClient(queryClient);
734
- const queryClient$ = useQueryClient$();
735
- const queryFnAsync = (context) => {
736
- return new Promise((resolve, reject) => {
737
- const getSource = () => rxjs.defer(
738
- () => typeof options.queryFn === "function" ? options.queryFn(context) : options.queryFn
739
- );
740
- const queryHash = reactQuery.hashKey(context.queryKey);
741
- const queryCacheEntry = queryClient$.getQuery(queryHash) ?? queryClient$.setQuery(context.queryKey, getSource(), context.signal);
742
- const query$ = queryCacheEntry.query$;
743
- query$.pipe(
744
- rxjs.take(1),
745
- /**
746
- * If several values are emitted during this delay, we will only
747
- * keep the last value. This is unfortunate but it's the best we can do
748
- * for now.
749
- */
750
- rxjs.delay(1)
751
- ).subscribe({
752
- error: (error) => {
753
- return reject(error);
754
- },
755
- complete: () => {
756
- if ((queryCacheEntry == null ? void 0 : queryCacheEntry.lastData) === void 0) {
757
- if (queryCacheEntry.signal.aborted) {
758
- return resolve(void 0);
759
- }
760
- console.log(
761
- `cancelled due to stream completing without data for query ${queryHash}`,
762
- queryCacheEntry == null ? void 0 : queryCacheEntry.lastData
763
- );
764
- _queryClient.cancelQueries({
765
- queryKey: context.queryKey,
766
- exact: true
767
- });
768
- return resolve(void 0);
769
- }
770
- resolve(queryCacheEntry.lastData.value);
771
- if ((queryCacheEntry == null ? void 0 : queryCacheEntry.isCompleted) === false) {
772
- setTimeout(() => {
773
- _queryClient == null ? void 0 : _queryClient.refetchQueries({
774
- queryKey: context.queryKey,
775
- exact: true
776
- });
777
- });
778
- }
779
- }
780
- });
781
- });
782
- };
783
- const result = reactQuery.useQuery(
784
- {
785
- ...options,
786
- queryFn: queryFnAsync
787
- },
788
- queryClient
789
- );
790
- return result;
791
- }
792
- function useMutation$(options, queryClient) {
793
- const stateSubject = useBehaviorSubject({
794
- status: "idle",
795
- isPending: false,
796
- isError: false,
797
- isSuccess: false,
798
- isIdle: true
799
- });
800
- const result = reactQuery.useMutation(
801
- {
802
- ...options,
803
- mutationFn: (variables) => {
804
- let lastData;
805
- return new Promise((resolve, reject) => {
806
- const source = typeof options.mutationFn === "function" ? options.mutationFn(variables) : options.mutationFn;
807
- source.pipe(rxjs.take(1)).subscribe({
808
- next: (data) => {
809
- lastData = { value: data };
810
- },
811
- error: (error) => {
812
- reject(error);
813
- },
814
- complete: () => {
815
- if (lastData === void 0)
816
- return reject(new Error("Stream completed without any data"));
817
- resolve(lastData.value);
818
- }
819
- });
820
- });
821
- }
822
- },
823
- queryClient
824
- );
825
- const { status, isPending, isError, isSuccess, isIdle } = result;
826
- react.useEffect(() => {
827
- stateSubject.current.next({ status, isPending, isError, isSuccess, isIdle });
828
- }, [status, isPending, isError, isSuccess, isIdle, stateSubject]);
829
- return { ...result, state$: stateSubject.current };
830
- }
831
- function useSwitchMutation$(options, queryClient) {
832
- const [cancel$, cancel] = useObservableCallback();
833
- const { mutate, mutateAsync, ...rest } = useMutation$(
834
- {
835
- ...options,
836
- mutationFn: (variables) => {
837
- const source = typeof options.mutationFn === "function" ? options.mutationFn(variables) : options.mutationFn;
838
- return source.pipe(rxjs.takeUntil(cancel$), rxjs.defaultIfEmpty(null));
839
- }
840
- },
841
- queryClient
842
- );
843
- const mutateSwitch = react.useCallback(
844
- (variables) => {
845
- cancel();
846
- return mutate(variables);
847
- },
848
- [mutate, cancel]
849
- );
850
- const mutateAsyncSwitch = react.useCallback(
851
- (variables) => {
852
- cancel();
853
- return mutateAsync(variables);
854
- },
855
- [mutateAsync, cancel]
856
- );
857
- return { ...rest, mutate: mutateSwitch, mutateAsync: mutateAsyncSwitch };
858
- }
859
- function useContactMutation$(options, queryClient) {
860
- const client = reactQuery.useQueryClient(queryClient);
861
- const mutationKey = options.mutationKey;
862
- const { mutateAsync, ...rest } = useMutation$(
863
- {
864
- ...options,
865
- onMutate({ variables }) {
866
- var _a;
867
- return (_a = options.onMutate) == null ? void 0 : _a.call(options, variables);
868
- },
869
- onSuccess(data, variables, context) {
870
- var _a;
871
- return (_a = options.onSuccess) == null ? void 0 : _a.call(options, data, variables.variables, context);
872
- },
873
- onError(error, variables, context) {
874
- var _a;
875
- return (_a = options.onError) == null ? void 0 : _a.call(options, error, variables.variables, context);
876
- },
877
- onSettled(data, error, variables, context) {
878
- var _a;
879
- return (_a = options.onSettled) == null ? void 0 : _a.call(options, data, error, variables.variables, context);
880
- },
881
- mutationFn: ({ ready$, variables }) => {
882
- const source = typeof options.mutationFn === "function" ? options.mutationFn(variables) : options.mutationFn;
883
- return ready$.pipe(
884
- rxjs.filter((isReady) => isReady),
885
- rxjs.first(),
886
- rxjs.switchMap(() => source)
887
- );
888
- }
889
- },
890
- queryClient
891
- );
892
- const mutateAsyncConcat = react.useCallback(
893
- async (variables) => {
894
- const mutations = client.getMutationCache().findAll({
895
- mutationKey,
896
- exact: true
897
- });
898
- const subject = new rxjs.BehaviorSubject(false);
899
- const result = mutateAsync({ variables, ready$: subject });
900
- await Promise.all(
901
- mutations.map((mutation) => mutation.continue().catch(rxjs.noop))
902
- );
903
- subject.next(true);
904
- return await result.finally(() => {
905
- subject.complete();
906
- });
907
- },
908
- [mutateAsync, client, mutationKey]
909
- );
910
- const mutateConcat = react.useCallback(
911
- (variables) => {
912
- mutateAsyncConcat(variables).catch(rxjs.noop);
913
- },
914
- [mutateAsyncConcat]
915
- );
916
- return { ...rest, mutate: mutateConcat, mutateAsync: mutateAsyncConcat };
917
- }
918
- exports.Context = Context;
919
- exports.QueryClient$ = QueryClient$;
920
- exports.QueryClientProvider$ = QueryClientProvider$;
921
- exports.SIGNAL_RESET = SIGNAL_RESET;
922
- exports.arrayEqual = arrayEqual;
923
- exports.createLocalStorageAdapter = createLocalStorageAdapter;
924
- exports.createLocalforageAdapter = createLocalforageAdapter;
925
- exports.exponentialBackoffDelay = exponentialBackoffDelay;
926
- exports.getDelay = getDelay;
927
- exports.isDefined = isDefined;
928
- exports.isPromiseLike = isPromiseLike;
929
- exports.isServer = isServer;
930
- exports.retryBackoff = retryBackoff;
931
- exports.signal = signal;
932
- exports.useBehaviorSubject = useBehaviorSubject;
933
- exports.useContactMutation$ = useContactMutation$;
934
- exports.useEffectOnce = useEffectOnce;
935
- exports.useLiveBehaviorSubject = useLiveBehaviorSubject;
936
- exports.useLiveRef = useLiveRef;
937
- exports.useMount = useMount;
938
- exports.useMutation$ = useMutation$;
939
- exports.useObservableCallback = useObservableCallback;
940
- exports.useObservableState = useObservableState;
941
- exports.useObserve = useObserve;
942
- exports.usePersistSignals = usePersistSignals;
943
- exports.useQuery$ = useQuery$;
944
- exports.useQueryClient$ = useQueryClient$;
945
- exports.useSignal = useSignal;
946
- exports.useSignalValue = useSignalValue;
947
- exports.useSubject = useSubject;
948
- exports.useSubscribe = useSubscribe;
949
- exports.useSubscribeEffect = useSubscribeEffect;
950
- exports.useSwitchMutation$ = useSwitchMutation$;
951
- exports.useUnmountObservable = useUnmountObservable;
1
+ "use strict";var J=Object.defineProperty;var B=(e,t,r)=>t in e?J(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Q=(e,t,r)=>B(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react"),n=require("rxjs"),S=require("rxjs/operators"),w=require("@tanstack/react-query"),Y=require("react/jsx-runtime"),g=e=>{const t=f.useRef(e);return f.useMemo(()=>{t.current=e},[e]),t};function $(e){return e instanceof Promise||e&&typeof e=="object"&&"then"in e&&typeof e.then=="function"&&"catch"in e&&e.catch==="function"}function R(e){if(n.isObservable(e))return()=>e;if($(e))return()=>n.from(e);if(typeof e!="function")return()=>n.of(e);const t=e;return r=>n.defer(()=>{const u=t(r);return $(u)?n.from(u):n.isObservable(u)?u:n.of(u)})}function O(e,t,r){const u=t!=null&&!Array.isArray(t)?t:{defaultValue:void 0,unsubscribeOnUnmount:!0,compareFn:void 0},c=!r&&Array.isArray(t)?t:typeof e=="function"?r??[]:[e],o=f.useRef("getValue"in e&&typeof e.getValue=="function"?e.getValue():u.defaultValue),s=g(e),l=g(u),a=f.useCallback(()=>o.current,[]),i=f.useCallback(y=>{const b=s.current,h=R(b)().pipe(l.current.defaultValue?n.startWith(l.current.defaultValue):n.identity,l.current.compareFn?n.distinctUntilChanged((p,m)=>p===void 0||m===void 0?!1:l.current.compareFn(p,m)):n.identity,n.tap(p=>{o.current=p}),n.catchError(p=>(console.error(p),n.EMPTY))).subscribe(y);return()=>{l.current.unsubscribeOnUnmount!==!1&&h.unsubscribe()}},[...c]);return f.useSyncExternalStore(i,a)}function j(e,t=[]){const r=g(e);f.useEffect(()=>{const u=R(r.current)().pipe(n.catchError(c=>(console.error(c),n.EMPTY))).subscribe();return()=>{u.unsubscribe()}},[...t,r])}const P=e=>{const t=f.useRef(void 0);return t.current||(t.current=e()),f.useEffect(()=>{process.env.NODE_ENV},[]),t},q=({onBeforeComplete:e,completeOnUnmount:t=!0}={})=>{const r=P(()=>new n.Subject),u=f.useRef(!1),c=g(e),o=g(t);return f.useEffect(()=>(u.current&&(r.current=new n.Subject,u.current=!1),()=>{if(!o.current){u.current=!0;return}u.current||(c.current!=null&&c.current(),r.current.complete(),u.current=!0)}),[o,c,r]),r},A=()=>{const e=q(),t=f.useCallback(r=>{e.current.next(r)},[]);return[e.current,t]},I=e=>{const t=P(()=>new n.BehaviorSubject(e)),r=f.useRef(!1),u=f.useRef(e);return f.useEffect(()=>(r.current&&(t.current=new n.BehaviorSubject(u.current),r.current=!1),()=>{r.current||(t.current.complete(),r.current=!0)}),[t]),t},G=e=>{const t=I(e),r=g(t.current.asObservable()),u=f.useCallback(c=>{t.current.next(c)},[t.current]);return[r.current,u,t.current.getValue()]},k=e=>{const t=I(e);return f.useEffect(()=>{t.current.next(e)},[e,t]),t};function W(e,t,r=[]){const u=t!=null&&!Array.isArray(t)?t:{},c=u.retry??!0,o=g(u.onError??(a=>{console.error(a)})),s=f.useCallback(()=>R(e)(),r),l=f.useCallback(()=>s().pipe(n.catchError(a=>{throw o.current(a),a}),c?n.retry():n.identity),[s,c,o]);j(l,r)}const D=Symbol("SIGNAL_RESET");function N(e={}){const t={default:e.default,key:e.key},{default:r}=t,u=new n.BehaviorSubject(r),c=s=>{const l=a=>{"key"in e&&console.log("[reactjrx][state][signal]:",`Value update for signal ${e.key}`,{prev:u.getValue(),curr:a}),u.next(a)};if(typeof s=="function"){const a=s(u.getValue());return a===u.getValue()?void 0:l(a)}if(s===D)return r===u.getValue()?void 0:l(r??void 0);if(s!==u.getValue())return l(s)},o=()=>u.getValue();if("get"in e){const s=a=>(a.subject.pipe(n.skip(1),n.first()).subscribe(()=>{var d;const i=(d=e.get)==null?void 0:d.call(e,s);c(i)}),a.getValue()),l=e.get(s);return c(l),{getValue:o,config:e,subject:u}}return{setValue:c,getValue:o,config:t,subject:u}}function L(e,t){const u=t??(()=>e.getValue());return O(()=>e.subject.pipe(n.map(o=>u(o)),n.distinctUntilChanged()),{defaultValue:u(e.getValue())},[])}const X=e=>{const[t]=f.useState(()=>N(e));return[L(t),t]},Z=e=>({getItem:async t=>{const r=await e.getItem(t);if(r)return JSON.parse(r)},setItem:async(t,r)=>{await e.setItem(t,JSON.stringify(r))},removeItem:async t=>{},clear:async()=>{}}),C=e=>{if(!(!e||typeof e!="object"))return e},ee=({adapter:e,key:t})=>({clear:async()=>await e.removeItem(t),removeItem:async r=>{const u=await e.getItem(t),{[r]:c,...o}=C(u)??{};await e.setItem(t,o)},getItem:async r=>{const u=await e.getItem(t),c=C(u)??{};if(r in c)return c[r]},setItem:async(r,u)=>{const c=await e.getItem(t),o=C(c)??{};await e.setItem(t,{...o,[r]:u})}}),T=({key:e}={})=>e?ee({adapter:T(),key:e}):{clear:async()=>{localStorage.clear()},removeItem:async t=>{localStorage.removeItem(t)},getItem:async t=>{const r=localStorage.getItem(t);if(r)return JSON.parse(r)},setItem:async(t,r)=>{localStorage.setItem(t,JSON.stringify(r))}},V="__reactjrx",te=e=>{if(typeof e=="object"&&e!==null&&V in e&&e[V]===V)return e},re=({adapter:e,config:t})=>{const{signal:r,version:u}=t,o={value:r.getValue(),[V]:V,migrationVersion:u};return process.env.NODE_ENV==="development"&&console.log("[reactjrx][state][persistance]:","Persist value",o,`for signal ${r.config.key}`),n.from(e.setItem(r.config.key,o)).pipe(n.catchError(s=>(console.error(s),n.of(null))))};function ne({adapter:e,config:t}){const{hydrate:r=({value:o})=>o,signal:u,version:c}=t;return n.from(e.getItem(u.config.key)).pipe(n.switchMap(o=>{const s=te(o);if(!s)return n.of(o);const l=typeof s.migrationVersion!="number",a=s.migrationVersion!==void 0&&c>s.migrationVersion;if(l||a||s.value===void 0)return n.of(o);const i=s.value;return process.env.NODE_ENV==="development"&&console.log("[reactjrx][state][persistance]:","Hydrate value",s,`for signal ${u.config.key}`),u.setValue(r({value:i,version:c})),n.of(o)}))}function ue({entries:e=[],onHydrated:t,adapter:r}){const c=(e.length===0?n.of([]):n.zip(...e.map(s=>ne({adapter:r,config:s})))).pipe(n.tap(t),n.catchError(s=>(console.error("Unable to hydrate",s),n.EMPTY)),n.share()),o=c.pipe(n.switchMap(()=>n.merge(...e.map(s=>s.signal.subject.pipe(n.throttleTime(500,n.asyncScheduler,{trailing:!0}),n.switchMap(()=>n.from(re({adapter:r,config:s}))))))));return n.merge(c.pipe(n.map(()=>({type:"hydrated"}))),o.pipe(n.map(()=>({type:"persisted"}))))}function se(e,t){if(e==null||t===void 0||typeof e!="object"||typeof t!="object")return e===t;if(e.constructor!==(t==null?void 0:t.constructor))return!1;const r=Object.keys(e),u=Object.keys(t);if(r.length!==u.length)return!1;for(const c of r)if(!t.hasOwnProperty(c)||e[c]!==t[c])return!1;return!0}function ce({entries:e=[],onHydrated:t,adapter:r}){const u=g(t),c=k(r),o=k(e);return O(()=>c.current.pipe(n.switchMap(l=>l?n.merge(n.of({type:"reset"}),o.current.pipe(n.concatMap(a=>ue({adapter:l,entries:a,onHydrated:()=>{var i;(i=u.current)==null||i.call(u)}})))):n.of({type:"reset"}))).pipe(n.scan((l,a)=>a.type==="reset"?{isHydrated:!1}:a.type==="hydrated"?{isHydrated:!0}:l,{isHydrated:!1})),{defaultValue:{isHydrated:!1},compareFn:se},[c,o])}const ae=()=>{const e=q({onBeforeComplete:()=>{e.current.next()}});return e},_=e=>{f.useEffect(e,[])},oe=e=>{_(()=>{e()})};function K(e,t){return Math.min(e,t)}function U(e,t){return Math.pow(2,e)*t}function ie(e){const{retry:t,retryDelay:r,retryAfterDelay:u,retryAfter:c=()=>n.of(!0)}=e,o=typeof t!="function"?t===!1?0:t===!0?1/0:t??1/0:1/0,s=typeof t=="function"?t:()=>!0,l=typeof r=="number"?r:100,a={shouldRetry:s,...e},{maxInterval:i=1/0,resetOnSuccess:d=!1,backoffDelay:y=U}=a;return b=>n.defer(()=>{let h=0;const p=(m,v)=>m<o?s(m,v):!1;return b.pipe(S.catchError(m=>{var E;if(h++,!p(h-1,m))throw m;const v=(E=e.caughtError)==null?void 0:E.call(e,h,m);if(!v)throw m;return v.pipe(S.mergeMap(M=>n.merge(n.of(M),n.throwError(()=>m))))}),S.retryWhen(m=>m.pipe(S.concatMap(v=>{const E=h-1;return c().pipe(S.first(),S.mergeMap(()=>p(E,v)?n.timer(K(y(E,l),i)).pipe(S.mergeMap(M=>u&&!u(E,v)?n.throwError(()=>v):n.of(M))):n.throwError(()=>v)))}))),S.catchError(m=>{if(e.catchError)return e.catchError(h,m);throw m}),S.tap(()=>{d&&(h=0)}))})}function le(e){return e!=null}const fe=(e,t)=>e.length===t.length&&e.every((r,u)=>r===t[u]),ye=typeof window>"u"||"Deno"in window;class H{constructor(){Q(this,"queryMap",new Map)}getQuery(t){return this.queryMap.get(t)}setQuery(t,r,u){const c=w.hashKey(t),o=r.pipe(n.takeUntil(n.fromEvent(u,"abort")),n.share()),s={query$:o,signal:u,sub:void 0,isCompleted:!1,lastData:void 0};this.queryMap.set(c,s);const l=o.subscribe({next:a=>{const i=this.queryMap.get(c);i&&(i.lastData={value:a})},complete:()=>{this.deleteQuery(c)}});return s.sub=l,s}deleteQuery(t){const r=this.queryMap.get(t);r&&(r.sub&&(r.sub.unsubscribe(),r.sub=void 0),r.isCompleted=!0,this.queryMap.delete(t))}destroy(){this.queryMap.forEach((t,r)=>{this.deleteQuery(r)})}}const x=f.createContext(void 0),de=f.memo(({children:e,client:t})=>{const[r]=f.useState(()=>t??new H);return f.useEffect(()=>()=>{r.destroy()},[r]),Y.jsx(x.Provider,{value:r,children:e})}),z=()=>{const e=f.useContext(x);if(!e)throw new Error("useReactJrxQueryClient must be used within a ReactJrxQueryProvider");return e};function me(e,t){const r=w.useQueryClient(t),u=z(),c=s=>new Promise((l,a)=>{const i=()=>n.defer(()=>typeof e.queryFn=="function"?e.queryFn(s):e.queryFn),d=w.hashKey(s.queryKey),y=u.getQuery(d)??u.setQuery(s.queryKey,i(),s.signal);y.query$.pipe(n.take(1),n.delay(1)).subscribe({error:h=>a(h),complete:()=>{if((y==null?void 0:y.lastData)===void 0)return y.signal.aborted||(console.log(`cancelled due to stream completing without data for query ${d}`,y==null?void 0:y.lastData),r.cancelQueries({queryKey:s.queryKey,exact:!0})),l(void 0);l(y.lastData.value),(y==null?void 0:y.isCompleted)===!1&&setTimeout(()=>{r==null||r.refetchQueries({queryKey:s.queryKey,exact:!0})})}})});return w.useQuery({...e,queryFn:c},t)}function F(e,t){const r=I({status:"idle",isPending:!1,isError:!1,isSuccess:!1,isIdle:!0}),u=w.useMutation({...e,mutationFn:i=>{let d;return new Promise((y,b)=>{(typeof e.mutationFn=="function"?e.mutationFn(i):e.mutationFn).pipe(n.take(1)).subscribe({next:p=>{d={value:p}},error:p=>{b(p)},complete:()=>{if(d===void 0)return b(new Error("Stream completed without any data"));y(d.value)}})})}},t),{status:c,isPending:o,isError:s,isSuccess:l,isIdle:a}=u;return f.useEffect(()=>{r.current.next({status:c,isPending:o,isError:s,isSuccess:l,isIdle:a})},[c,o,s,l,a,r]),{...u,state$:r.current}}function pe(e,t){const[r,u]=A(),{mutate:c,mutateAsync:o,...s}=F({...e,mutationFn:i=>(typeof e.mutationFn=="function"?e.mutationFn(i):e.mutationFn).pipe(n.takeUntil(r),n.defaultIfEmpty(null))},t),l=f.useCallback(i=>(u(),c(i)),[c,u]),a=f.useCallback(i=>(u(),o(i)),[o,u]);return{...s,mutate:l,mutateAsync:a}}function be(e,t){const r=w.useQueryClient(t),u=e.mutationKey,{mutateAsync:c,...o}=F({...e,onMutate({variables:a}){var i;return(i=e.onMutate)==null?void 0:i.call(e,a)},onSuccess(a,i,d){var y;return(y=e.onSuccess)==null?void 0:y.call(e,a,i.variables,d)},onError(a,i,d){var y;return(y=e.onError)==null?void 0:y.call(e,a,i.variables,d)},onSettled(a,i,d,y){var b;return(b=e.onSettled)==null?void 0:b.call(e,a,i,d.variables,y)},mutationFn:({ready$:a,variables:i})=>{const d=typeof e.mutationFn=="function"?e.mutationFn(i):e.mutationFn;return a.pipe(n.filter(y=>y),n.first(),n.switchMap(()=>d))}},t),s=f.useCallback(async a=>{const i=r.getMutationCache().findAll({mutationKey:u,exact:!0}),d=new n.BehaviorSubject(!1),y=c({variables:a,ready$:d});return await Promise.all(i.map(b=>b.continue().catch(n.noop))),d.next(!0),await y.finally(()=>{d.complete()})},[c,r,u]),l=f.useCallback(a=>{s(a).catch(n.noop)},[s]);return{...o,mutate:l,mutateAsync:s}}exports.Context=x;exports.QueryClient$=H;exports.QueryClientProvider$=de;exports.SIGNAL_RESET=D;exports.arrayEqual=fe;exports.createLocalStorageAdapter=T;exports.createLocalforageAdapter=Z;exports.exponentialBackoffDelay=U;exports.getDelay=K;exports.isDefined=le;exports.isPromiseLike=$;exports.isServer=ye;exports.retryBackoff=ie;exports.signal=N;exports.useBehaviorSubject=I;exports.useContactMutation$=be;exports.useEffectOnce=_;exports.useLiveBehaviorSubject=k;exports.useLiveRef=g;exports.useMount=oe;exports.useMutation$=F;exports.useObservableCallback=A;exports.useObservableState=G;exports.useObserve=O;exports.usePersistSignals=ce;exports.useQuery$=me;exports.useQueryClient$=z;exports.useSignal=X;exports.useSignalValue=L;exports.useSubject=q;exports.useSubscribe=j;exports.useSubscribeEffect=W;exports.useSwitchMutation$=pe;exports.useUnmountObservable=ae;
2
+ //# sourceMappingURL=index.cjs.map