@tanstack/query-core 5.55.3 → 5.55.4

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.
@@ -34,22 +34,6 @@ function createNotifyManager() {
34
34
  callback();
35
35
  };
36
36
  let scheduleFn = (cb) => setTimeout(cb, 0);
37
- const setScheduler = (fn) => {
38
- scheduleFn = fn;
39
- };
40
- const batch = (callback) => {
41
- let result;
42
- transactions++;
43
- try {
44
- result = callback();
45
- } finally {
46
- transactions--;
47
- if (!transactions) {
48
- flush();
49
- }
50
- }
51
- return result;
52
- };
53
37
  const schedule = (callback) => {
54
38
  if (transactions) {
55
39
  queue.push(callback);
@@ -59,13 +43,6 @@ function createNotifyManager() {
59
43
  });
60
44
  }
61
45
  };
62
- const batchCalls = (callback) => {
63
- return (...args) => {
64
- schedule(() => {
65
- callback(...args);
66
- });
67
- };
68
- };
69
46
  const flush = () => {
70
47
  const originalQueue = queue;
71
48
  queue = [];
@@ -79,19 +56,48 @@ function createNotifyManager() {
79
56
  });
80
57
  }
81
58
  };
82
- const setNotifyFunction = (fn) => {
83
- notifyFn = fn;
84
- };
85
- const setBatchNotifyFunction = (fn) => {
86
- batchNotifyFn = fn;
87
- };
88
59
  return {
89
- batch,
90
- batchCalls,
60
+ batch: (callback) => {
61
+ let result;
62
+ transactions++;
63
+ try {
64
+ result = callback();
65
+ } finally {
66
+ transactions--;
67
+ if (!transactions) {
68
+ flush();
69
+ }
70
+ }
71
+ return result;
72
+ },
73
+ /**
74
+ * All calls to the wrapped function will be batched.
75
+ */
76
+ batchCalls: (callback) => {
77
+ return (...args) => {
78
+ schedule(() => {
79
+ callback(...args);
80
+ });
81
+ };
82
+ },
91
83
  schedule,
92
- setNotifyFunction,
93
- setBatchNotifyFunction,
94
- setScheduler
84
+ /**
85
+ * Use this method to set a custom notify function.
86
+ * This can be used to for example wrap notifications with `React.act` while running tests.
87
+ */
88
+ setNotifyFunction: (fn) => {
89
+ notifyFn = fn;
90
+ },
91
+ /**
92
+ * Use this method to set a custom function to batch notifications together into a single tick.
93
+ * By default React Query will use the batch function provided by ReactDOM or React Native.
94
+ */
95
+ setBatchNotifyFunction: (fn) => {
96
+ batchNotifyFn = fn;
97
+ },
98
+ setScheduler: (fn) => {
99
+ scheduleFn = fn;
100
+ }
95
101
  };
96
102
  }
97
103
  var notifyManager = createNotifyManager();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/notifyManager.ts"],"sourcesContent":["// TYPES\n\ntype NotifyCallback = () => void\n\ntype NotifyFunction = (callback: () => void) => void\n\ntype BatchNotifyFunction = (callback: () => void) => void\n\ntype BatchCallsCallback<T extends Array<unknown>> = (...args: T) => void\n\ntype ScheduleFunction = (callback: () => void) => void\n\nexport function createNotifyManager() {\n let queue: Array<NotifyCallback> = []\n let transactions = 0\n let notifyFn: NotifyFunction = (callback) => {\n callback()\n }\n let batchNotifyFn: BatchNotifyFunction = (callback: () => void) => {\n callback()\n }\n let scheduleFn: ScheduleFunction = (cb) => setTimeout(cb, 0)\n\n const setScheduler = (fn: ScheduleFunction) => {\n scheduleFn = fn\n }\n\n const batch = <T>(callback: () => T): T => {\n let result\n transactions++\n try {\n result = callback()\n } finally {\n transactions--\n if (!transactions) {\n flush()\n }\n }\n return result\n }\n\n const schedule = (callback: NotifyCallback): void => {\n if (transactions) {\n queue.push(callback)\n } else {\n scheduleFn(() => {\n notifyFn(callback)\n })\n }\n }\n\n /**\n * All calls to the wrapped function will be batched.\n */\n const batchCalls = <T extends Array<unknown>>(\n callback: BatchCallsCallback<T>,\n ): BatchCallsCallback<T> => {\n return (...args) => {\n schedule(() => {\n callback(...args)\n })\n }\n }\n\n const flush = (): void => {\n const originalQueue = queue\n queue = []\n if (originalQueue.length) {\n scheduleFn(() => {\n batchNotifyFn(() => {\n originalQueue.forEach((callback) => {\n notifyFn(callback)\n })\n })\n })\n }\n }\n\n /**\n * Use this method to set a custom notify function.\n * This can be used to for example wrap notifications with `React.act` while running tests.\n */\n const setNotifyFunction = (fn: NotifyFunction) => {\n notifyFn = fn\n }\n\n /**\n * Use this method to set a custom function to batch notifications together into a single tick.\n * By default React Query will use the batch function provided by ReactDOM or React Native.\n */\n const setBatchNotifyFunction = (fn: BatchNotifyFunction) => {\n batchNotifyFn = fn\n }\n\n return {\n batch,\n batchCalls,\n schedule,\n setNotifyFunction,\n setBatchNotifyFunction,\n setScheduler,\n } as const\n}\n\n// SINGLETON\nexport const notifyManager = createNotifyManager()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYO,SAAS,sBAAsB;AACpC,MAAI,QAA+B,CAAC;AACpC,MAAI,eAAe;AACnB,MAAI,WAA2B,CAAC,aAAa;AAC3C,aAAS;AAAA,EACX;AACA,MAAI,gBAAqC,CAAC,aAAyB;AACjE,aAAS;AAAA,EACX;AACA,MAAI,aAA+B,CAAC,OAAO,WAAW,IAAI,CAAC;AAE3D,QAAM,eAAe,CAAC,OAAyB;AAC7C,iBAAa;AAAA,EACf;AAEA,QAAM,QAAQ,CAAI,aAAyB;AACzC,QAAI;AACJ;AACA,QAAI;AACF,eAAS,SAAS;AAAA,IACpB,UAAE;AACA;AACA,UAAI,CAAC,cAAc;AACjB,cAAM;AAAA,MACR;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAEA,QAAM,WAAW,CAAC,aAAmC;AACnD,QAAI,cAAc;AAChB,YAAM,KAAK,QAAQ;AAAA,IACrB,OAAO;AACL,iBAAW,MAAM;AACf,iBAAS,QAAQ;AAAA,MACnB,CAAC;AAAA,IACH;AAAA,EACF;AAKA,QAAM,aAAa,CACjB,aAC0B;AAC1B,WAAO,IAAI,SAAS;AAClB,eAAS,MAAM;AACb,iBAAS,GAAG,IAAI;AAAA,MAClB,CAAC;AAAA,IACH;AAAA,EACF;AAEA,QAAM,QAAQ,MAAY;AACxB,UAAM,gBAAgB;AACtB,YAAQ,CAAC;AACT,QAAI,cAAc,QAAQ;AACxB,iBAAW,MAAM;AACf,sBAAc,MAAM;AAClB,wBAAc,QAAQ,CAAC,aAAa;AAClC,qBAAS,QAAQ;AAAA,UACnB,CAAC;AAAA,QACH,CAAC;AAAA,MACH,CAAC;AAAA,IACH;AAAA,EACF;AAMA,QAAM,oBAAoB,CAAC,OAAuB;AAChD,eAAW;AAAA,EACb;AAMA,QAAM,yBAAyB,CAAC,OAA4B;AAC1D,oBAAgB;AAAA,EAClB;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAGO,IAAM,gBAAgB,oBAAoB;","names":[]}
1
+ {"version":3,"sources":["../../src/notifyManager.ts"],"sourcesContent":["// TYPES\n\ntype NotifyCallback = () => void\n\ntype NotifyFunction = (callback: () => void) => void\n\ntype BatchNotifyFunction = (callback: () => void) => void\n\ntype BatchCallsCallback<T extends Array<unknown>> = (...args: T) => void\n\ntype ScheduleFunction = (callback: () => void) => void\n\nexport function createNotifyManager() {\n let queue: Array<NotifyCallback> = []\n let transactions = 0\n let notifyFn: NotifyFunction = (callback) => {\n callback()\n }\n let batchNotifyFn: BatchNotifyFunction = (callback: () => void) => {\n callback()\n }\n let scheduleFn: ScheduleFunction = (cb) => setTimeout(cb, 0)\n\n const schedule = (callback: NotifyCallback): void => {\n if (transactions) {\n queue.push(callback)\n } else {\n scheduleFn(() => {\n notifyFn(callback)\n })\n }\n }\n const flush = (): void => {\n const originalQueue = queue\n queue = []\n if (originalQueue.length) {\n scheduleFn(() => {\n batchNotifyFn(() => {\n originalQueue.forEach((callback) => {\n notifyFn(callback)\n })\n })\n })\n }\n }\n\n return {\n batch: <T>(callback: () => T): T => {\n let result\n transactions++\n try {\n result = callback()\n } finally {\n transactions--\n if (!transactions) {\n flush()\n }\n }\n return result\n },\n /**\n * All calls to the wrapped function will be batched.\n */\n batchCalls: <T extends Array<unknown>>(\n callback: BatchCallsCallback<T>,\n ): BatchCallsCallback<T> => {\n return (...args) => {\n schedule(() => {\n callback(...args)\n })\n }\n },\n schedule,\n /**\n * Use this method to set a custom notify function.\n * This can be used to for example wrap notifications with `React.act` while running tests.\n */\n setNotifyFunction: (fn: NotifyFunction) => {\n notifyFn = fn\n },\n /**\n * Use this method to set a custom function to batch notifications together into a single tick.\n * By default React Query will use the batch function provided by ReactDOM or React Native.\n */\n setBatchNotifyFunction: (fn: BatchNotifyFunction) => {\n batchNotifyFn = fn\n },\n setScheduler: (fn: ScheduleFunction) => {\n scheduleFn = fn\n },\n } as const\n}\n\n// SINGLETON\nexport const notifyManager = createNotifyManager()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYO,SAAS,sBAAsB;AACpC,MAAI,QAA+B,CAAC;AACpC,MAAI,eAAe;AACnB,MAAI,WAA2B,CAAC,aAAa;AAC3C,aAAS;AAAA,EACX;AACA,MAAI,gBAAqC,CAAC,aAAyB;AACjE,aAAS;AAAA,EACX;AACA,MAAI,aAA+B,CAAC,OAAO,WAAW,IAAI,CAAC;AAE3D,QAAM,WAAW,CAAC,aAAmC;AACnD,QAAI,cAAc;AAChB,YAAM,KAAK,QAAQ;AAAA,IACrB,OAAO;AACL,iBAAW,MAAM;AACf,iBAAS,QAAQ;AAAA,MACnB,CAAC;AAAA,IACH;AAAA,EACF;AACA,QAAM,QAAQ,MAAY;AACxB,UAAM,gBAAgB;AACtB,YAAQ,CAAC;AACT,QAAI,cAAc,QAAQ;AACxB,iBAAW,MAAM;AACf,sBAAc,MAAM;AAClB,wBAAc,QAAQ,CAAC,aAAa;AAClC,qBAAS,QAAQ;AAAA,UACnB,CAAC;AAAA,QACH,CAAC;AAAA,MACH,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AAAA,IACL,OAAO,CAAI,aAAyB;AAClC,UAAI;AACJ;AACA,UAAI;AACF,iBAAS,SAAS;AAAA,MACpB,UAAE;AACA;AACA,YAAI,CAAC,cAAc;AACjB,gBAAM;AAAA,QACR;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAIA,YAAY,CACV,aAC0B;AAC1B,aAAO,IAAI,SAAS;AAClB,iBAAS,MAAM;AACb,mBAAS,GAAG,IAAI;AAAA,QAClB,CAAC;AAAA,MACH;AAAA,IACF;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKA,mBAAmB,CAAC,OAAuB;AACzC,iBAAW;AAAA,IACb;AAAA;AAAA;AAAA;AAAA;AAAA,IAKA,wBAAwB,CAAC,OAA4B;AACnD,sBAAgB;AAAA,IAClB;AAAA,IACA,cAAc,CAAC,OAAyB;AACtC,mBAAa;AAAA,IACf;AAAA,EACF;AACF;AAGO,IAAM,gBAAgB,oBAAoB;","names":[]}
@@ -5,17 +5,39 @@ type BatchCallsCallback<T extends Array<unknown>> = (...args: T) => void;
5
5
  type ScheduleFunction = (callback: () => void) => void;
6
6
  declare function createNotifyManager(): {
7
7
  readonly batch: <T>(callback: () => T) => T;
8
+ /**
9
+ * All calls to the wrapped function will be batched.
10
+ */
8
11
  readonly batchCalls: <T_1 extends unknown[]>(callback: BatchCallsCallback<T_1>) => BatchCallsCallback<T_1>;
9
12
  readonly schedule: (callback: NotifyCallback) => void;
13
+ /**
14
+ * Use this method to set a custom notify function.
15
+ * This can be used to for example wrap notifications with `React.act` while running tests.
16
+ */
10
17
  readonly setNotifyFunction: (fn: NotifyFunction) => void;
18
+ /**
19
+ * Use this method to set a custom function to batch notifications together into a single tick.
20
+ * By default React Query will use the batch function provided by ReactDOM or React Native.
21
+ */
11
22
  readonly setBatchNotifyFunction: (fn: BatchNotifyFunction) => void;
12
23
  readonly setScheduler: (fn: ScheduleFunction) => void;
13
24
  };
14
25
  declare const notifyManager: {
15
26
  readonly batch: <T>(callback: () => T) => T;
27
+ /**
28
+ * All calls to the wrapped function will be batched.
29
+ */
16
30
  readonly batchCalls: <T_1 extends unknown[]>(callback: BatchCallsCallback<T_1>) => BatchCallsCallback<T_1>;
17
31
  readonly schedule: (callback: NotifyCallback) => void;
32
+ /**
33
+ * Use this method to set a custom notify function.
34
+ * This can be used to for example wrap notifications with `React.act` while running tests.
35
+ */
18
36
  readonly setNotifyFunction: (fn: NotifyFunction) => void;
37
+ /**
38
+ * Use this method to set a custom function to batch notifications together into a single tick.
39
+ * By default React Query will use the batch function provided by ReactDOM or React Native.
40
+ */
19
41
  readonly setBatchNotifyFunction: (fn: BatchNotifyFunction) => void;
20
42
  readonly setScheduler: (fn: ScheduleFunction) => void;
21
43
  };
@@ -5,17 +5,39 @@ type BatchCallsCallback<T extends Array<unknown>> = (...args: T) => void;
5
5
  type ScheduleFunction = (callback: () => void) => void;
6
6
  declare function createNotifyManager(): {
7
7
  readonly batch: <T>(callback: () => T) => T;
8
+ /**
9
+ * All calls to the wrapped function will be batched.
10
+ */
8
11
  readonly batchCalls: <T_1 extends unknown[]>(callback: BatchCallsCallback<T_1>) => BatchCallsCallback<T_1>;
9
12
  readonly schedule: (callback: NotifyCallback) => void;
13
+ /**
14
+ * Use this method to set a custom notify function.
15
+ * This can be used to for example wrap notifications with `React.act` while running tests.
16
+ */
10
17
  readonly setNotifyFunction: (fn: NotifyFunction) => void;
18
+ /**
19
+ * Use this method to set a custom function to batch notifications together into a single tick.
20
+ * By default React Query will use the batch function provided by ReactDOM or React Native.
21
+ */
11
22
  readonly setBatchNotifyFunction: (fn: BatchNotifyFunction) => void;
12
23
  readonly setScheduler: (fn: ScheduleFunction) => void;
13
24
  };
14
25
  declare const notifyManager: {
15
26
  readonly batch: <T>(callback: () => T) => T;
27
+ /**
28
+ * All calls to the wrapped function will be batched.
29
+ */
16
30
  readonly batchCalls: <T_1 extends unknown[]>(callback: BatchCallsCallback<T_1>) => BatchCallsCallback<T_1>;
17
31
  readonly schedule: (callback: NotifyCallback) => void;
32
+ /**
33
+ * Use this method to set a custom notify function.
34
+ * This can be used to for example wrap notifications with `React.act` while running tests.
35
+ */
18
36
  readonly setNotifyFunction: (fn: NotifyFunction) => void;
37
+ /**
38
+ * Use this method to set a custom function to batch notifications together into a single tick.
39
+ * By default React Query will use the batch function provided by ReactDOM or React Native.
40
+ */
19
41
  readonly setBatchNotifyFunction: (fn: BatchNotifyFunction) => void;
20
42
  readonly setScheduler: (fn: ScheduleFunction) => void;
21
43
  };
@@ -11,22 +11,6 @@ function createNotifyManager() {
11
11
  callback();
12
12
  };
13
13
  let scheduleFn = (cb) => setTimeout(cb, 0);
14
- const setScheduler = (fn) => {
15
- scheduleFn = fn;
16
- };
17
- const batch = (callback) => {
18
- let result;
19
- transactions++;
20
- try {
21
- result = callback();
22
- } finally {
23
- transactions--;
24
- if (!transactions) {
25
- flush();
26
- }
27
- }
28
- return result;
29
- };
30
14
  const schedule = (callback) => {
31
15
  if (transactions) {
32
16
  queue.push(callback);
@@ -36,13 +20,6 @@ function createNotifyManager() {
36
20
  });
37
21
  }
38
22
  };
39
- const batchCalls = (callback) => {
40
- return (...args) => {
41
- schedule(() => {
42
- callback(...args);
43
- });
44
- };
45
- };
46
23
  const flush = () => {
47
24
  const originalQueue = queue;
48
25
  queue = [];
@@ -56,19 +33,48 @@ function createNotifyManager() {
56
33
  });
57
34
  }
58
35
  };
59
- const setNotifyFunction = (fn) => {
60
- notifyFn = fn;
61
- };
62
- const setBatchNotifyFunction = (fn) => {
63
- batchNotifyFn = fn;
64
- };
65
36
  return {
66
- batch,
67
- batchCalls,
37
+ batch: (callback) => {
38
+ let result;
39
+ transactions++;
40
+ try {
41
+ result = callback();
42
+ } finally {
43
+ transactions--;
44
+ if (!transactions) {
45
+ flush();
46
+ }
47
+ }
48
+ return result;
49
+ },
50
+ /**
51
+ * All calls to the wrapped function will be batched.
52
+ */
53
+ batchCalls: (callback) => {
54
+ return (...args) => {
55
+ schedule(() => {
56
+ callback(...args);
57
+ });
58
+ };
59
+ },
68
60
  schedule,
69
- setNotifyFunction,
70
- setBatchNotifyFunction,
71
- setScheduler
61
+ /**
62
+ * Use this method to set a custom notify function.
63
+ * This can be used to for example wrap notifications with `React.act` while running tests.
64
+ */
65
+ setNotifyFunction: (fn) => {
66
+ notifyFn = fn;
67
+ },
68
+ /**
69
+ * Use this method to set a custom function to batch notifications together into a single tick.
70
+ * By default React Query will use the batch function provided by ReactDOM or React Native.
71
+ */
72
+ setBatchNotifyFunction: (fn) => {
73
+ batchNotifyFn = fn;
74
+ },
75
+ setScheduler: (fn) => {
76
+ scheduleFn = fn;
77
+ }
72
78
  };
73
79
  }
74
80
  var notifyManager = createNotifyManager();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/notifyManager.ts"],"sourcesContent":["// TYPES\n\ntype NotifyCallback = () => void\n\ntype NotifyFunction = (callback: () => void) => void\n\ntype BatchNotifyFunction = (callback: () => void) => void\n\ntype BatchCallsCallback<T extends Array<unknown>> = (...args: T) => void\n\ntype ScheduleFunction = (callback: () => void) => void\n\nexport function createNotifyManager() {\n let queue: Array<NotifyCallback> = []\n let transactions = 0\n let notifyFn: NotifyFunction = (callback) => {\n callback()\n }\n let batchNotifyFn: BatchNotifyFunction = (callback: () => void) => {\n callback()\n }\n let scheduleFn: ScheduleFunction = (cb) => setTimeout(cb, 0)\n\n const setScheduler = (fn: ScheduleFunction) => {\n scheduleFn = fn\n }\n\n const batch = <T>(callback: () => T): T => {\n let result\n transactions++\n try {\n result = callback()\n } finally {\n transactions--\n if (!transactions) {\n flush()\n }\n }\n return result\n }\n\n const schedule = (callback: NotifyCallback): void => {\n if (transactions) {\n queue.push(callback)\n } else {\n scheduleFn(() => {\n notifyFn(callback)\n })\n }\n }\n\n /**\n * All calls to the wrapped function will be batched.\n */\n const batchCalls = <T extends Array<unknown>>(\n callback: BatchCallsCallback<T>,\n ): BatchCallsCallback<T> => {\n return (...args) => {\n schedule(() => {\n callback(...args)\n })\n }\n }\n\n const flush = (): void => {\n const originalQueue = queue\n queue = []\n if (originalQueue.length) {\n scheduleFn(() => {\n batchNotifyFn(() => {\n originalQueue.forEach((callback) => {\n notifyFn(callback)\n })\n })\n })\n }\n }\n\n /**\n * Use this method to set a custom notify function.\n * This can be used to for example wrap notifications with `React.act` while running tests.\n */\n const setNotifyFunction = (fn: NotifyFunction) => {\n notifyFn = fn\n }\n\n /**\n * Use this method to set a custom function to batch notifications together into a single tick.\n * By default React Query will use the batch function provided by ReactDOM or React Native.\n */\n const setBatchNotifyFunction = (fn: BatchNotifyFunction) => {\n batchNotifyFn = fn\n }\n\n return {\n batch,\n batchCalls,\n schedule,\n setNotifyFunction,\n setBatchNotifyFunction,\n setScheduler,\n } as const\n}\n\n// SINGLETON\nexport const notifyManager = createNotifyManager()\n"],"mappings":";;;AAYO,SAAS,sBAAsB;AACpC,MAAI,QAA+B,CAAC;AACpC,MAAI,eAAe;AACnB,MAAI,WAA2B,CAAC,aAAa;AAC3C,aAAS;AAAA,EACX;AACA,MAAI,gBAAqC,CAAC,aAAyB;AACjE,aAAS;AAAA,EACX;AACA,MAAI,aAA+B,CAAC,OAAO,WAAW,IAAI,CAAC;AAE3D,QAAM,eAAe,CAAC,OAAyB;AAC7C,iBAAa;AAAA,EACf;AAEA,QAAM,QAAQ,CAAI,aAAyB;AACzC,QAAI;AACJ;AACA,QAAI;AACF,eAAS,SAAS;AAAA,IACpB,UAAE;AACA;AACA,UAAI,CAAC,cAAc;AACjB,cAAM;AAAA,MACR;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAEA,QAAM,WAAW,CAAC,aAAmC;AACnD,QAAI,cAAc;AAChB,YAAM,KAAK,QAAQ;AAAA,IACrB,OAAO;AACL,iBAAW,MAAM;AACf,iBAAS,QAAQ;AAAA,MACnB,CAAC;AAAA,IACH;AAAA,EACF;AAKA,QAAM,aAAa,CACjB,aAC0B;AAC1B,WAAO,IAAI,SAAS;AAClB,eAAS,MAAM;AACb,iBAAS,GAAG,IAAI;AAAA,MAClB,CAAC;AAAA,IACH;AAAA,EACF;AAEA,QAAM,QAAQ,MAAY;AACxB,UAAM,gBAAgB;AACtB,YAAQ,CAAC;AACT,QAAI,cAAc,QAAQ;AACxB,iBAAW,MAAM;AACf,sBAAc,MAAM;AAClB,wBAAc,QAAQ,CAAC,aAAa;AAClC,qBAAS,QAAQ;AAAA,UACnB,CAAC;AAAA,QACH,CAAC;AAAA,MACH,CAAC;AAAA,IACH;AAAA,EACF;AAMA,QAAM,oBAAoB,CAAC,OAAuB;AAChD,eAAW;AAAA,EACb;AAMA,QAAM,yBAAyB,CAAC,OAA4B;AAC1D,oBAAgB;AAAA,EAClB;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAGO,IAAM,gBAAgB,oBAAoB;","names":[]}
1
+ {"version":3,"sources":["../../src/notifyManager.ts"],"sourcesContent":["// TYPES\n\ntype NotifyCallback = () => void\n\ntype NotifyFunction = (callback: () => void) => void\n\ntype BatchNotifyFunction = (callback: () => void) => void\n\ntype BatchCallsCallback<T extends Array<unknown>> = (...args: T) => void\n\ntype ScheduleFunction = (callback: () => void) => void\n\nexport function createNotifyManager() {\n let queue: Array<NotifyCallback> = []\n let transactions = 0\n let notifyFn: NotifyFunction = (callback) => {\n callback()\n }\n let batchNotifyFn: BatchNotifyFunction = (callback: () => void) => {\n callback()\n }\n let scheduleFn: ScheduleFunction = (cb) => setTimeout(cb, 0)\n\n const schedule = (callback: NotifyCallback): void => {\n if (transactions) {\n queue.push(callback)\n } else {\n scheduleFn(() => {\n notifyFn(callback)\n })\n }\n }\n const flush = (): void => {\n const originalQueue = queue\n queue = []\n if (originalQueue.length) {\n scheduleFn(() => {\n batchNotifyFn(() => {\n originalQueue.forEach((callback) => {\n notifyFn(callback)\n })\n })\n })\n }\n }\n\n return {\n batch: <T>(callback: () => T): T => {\n let result\n transactions++\n try {\n result = callback()\n } finally {\n transactions--\n if (!transactions) {\n flush()\n }\n }\n return result\n },\n /**\n * All calls to the wrapped function will be batched.\n */\n batchCalls: <T extends Array<unknown>>(\n callback: BatchCallsCallback<T>,\n ): BatchCallsCallback<T> => {\n return (...args) => {\n schedule(() => {\n callback(...args)\n })\n }\n },\n schedule,\n /**\n * Use this method to set a custom notify function.\n * This can be used to for example wrap notifications with `React.act` while running tests.\n */\n setNotifyFunction: (fn: NotifyFunction) => {\n notifyFn = fn\n },\n /**\n * Use this method to set a custom function to batch notifications together into a single tick.\n * By default React Query will use the batch function provided by ReactDOM or React Native.\n */\n setBatchNotifyFunction: (fn: BatchNotifyFunction) => {\n batchNotifyFn = fn\n },\n setScheduler: (fn: ScheduleFunction) => {\n scheduleFn = fn\n },\n } as const\n}\n\n// SINGLETON\nexport const notifyManager = createNotifyManager()\n"],"mappings":";;;AAYO,SAAS,sBAAsB;AACpC,MAAI,QAA+B,CAAC;AACpC,MAAI,eAAe;AACnB,MAAI,WAA2B,CAAC,aAAa;AAC3C,aAAS;AAAA,EACX;AACA,MAAI,gBAAqC,CAAC,aAAyB;AACjE,aAAS;AAAA,EACX;AACA,MAAI,aAA+B,CAAC,OAAO,WAAW,IAAI,CAAC;AAE3D,QAAM,WAAW,CAAC,aAAmC;AACnD,QAAI,cAAc;AAChB,YAAM,KAAK,QAAQ;AAAA,IACrB,OAAO;AACL,iBAAW,MAAM;AACf,iBAAS,QAAQ;AAAA,MACnB,CAAC;AAAA,IACH;AAAA,EACF;AACA,QAAM,QAAQ,MAAY;AACxB,UAAM,gBAAgB;AACtB,YAAQ,CAAC;AACT,QAAI,cAAc,QAAQ;AACxB,iBAAW,MAAM;AACf,sBAAc,MAAM;AAClB,wBAAc,QAAQ,CAAC,aAAa;AAClC,qBAAS,QAAQ;AAAA,UACnB,CAAC;AAAA,QACH,CAAC;AAAA,MACH,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AAAA,IACL,OAAO,CAAI,aAAyB;AAClC,UAAI;AACJ;AACA,UAAI;AACF,iBAAS,SAAS;AAAA,MACpB,UAAE;AACA;AACA,YAAI,CAAC,cAAc;AACjB,gBAAM;AAAA,QACR;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAIA,YAAY,CACV,aAC0B;AAC1B,aAAO,IAAI,SAAS;AAClB,iBAAS,MAAM;AACb,mBAAS,GAAG,IAAI;AAAA,QAClB,CAAC;AAAA,MACH;AAAA,IACF;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKA,mBAAmB,CAAC,OAAuB;AACzC,iBAAW;AAAA,IACb;AAAA;AAAA;AAAA;AAAA;AAAA,IAKA,wBAAwB,CAAC,OAA4B;AACnD,sBAAgB;AAAA,IAClB;AAAA,IACA,cAAc,CAAC,OAAyB;AACtC,mBAAa;AAAA,IACf;AAAA,EACF;AACF;AAGO,IAAM,gBAAgB,oBAAoB;","names":[]}
@@ -34,22 +34,6 @@ function createNotifyManager() {
34
34
  callback();
35
35
  };
36
36
  let scheduleFn = (cb) => setTimeout(cb, 0);
37
- const setScheduler = (fn) => {
38
- scheduleFn = fn;
39
- };
40
- const batch = (callback) => {
41
- let result;
42
- transactions++;
43
- try {
44
- result = callback();
45
- } finally {
46
- transactions--;
47
- if (!transactions) {
48
- flush();
49
- }
50
- }
51
- return result;
52
- };
53
37
  const schedule = (callback) => {
54
38
  if (transactions) {
55
39
  queue.push(callback);
@@ -59,13 +43,6 @@ function createNotifyManager() {
59
43
  });
60
44
  }
61
45
  };
62
- const batchCalls = (callback) => {
63
- return (...args) => {
64
- schedule(() => {
65
- callback(...args);
66
- });
67
- };
68
- };
69
46
  const flush = () => {
70
47
  const originalQueue = queue;
71
48
  queue = [];
@@ -79,19 +56,48 @@ function createNotifyManager() {
79
56
  });
80
57
  }
81
58
  };
82
- const setNotifyFunction = (fn) => {
83
- notifyFn = fn;
84
- };
85
- const setBatchNotifyFunction = (fn) => {
86
- batchNotifyFn = fn;
87
- };
88
59
  return {
89
- batch,
90
- batchCalls,
60
+ batch: (callback) => {
61
+ let result;
62
+ transactions++;
63
+ try {
64
+ result = callback();
65
+ } finally {
66
+ transactions--;
67
+ if (!transactions) {
68
+ flush();
69
+ }
70
+ }
71
+ return result;
72
+ },
73
+ /**
74
+ * All calls to the wrapped function will be batched.
75
+ */
76
+ batchCalls: (callback) => {
77
+ return (...args) => {
78
+ schedule(() => {
79
+ callback(...args);
80
+ });
81
+ };
82
+ },
91
83
  schedule,
92
- setNotifyFunction,
93
- setBatchNotifyFunction,
94
- setScheduler
84
+ /**
85
+ * Use this method to set a custom notify function.
86
+ * This can be used to for example wrap notifications with `React.act` while running tests.
87
+ */
88
+ setNotifyFunction: (fn) => {
89
+ notifyFn = fn;
90
+ },
91
+ /**
92
+ * Use this method to set a custom function to batch notifications together into a single tick.
93
+ * By default React Query will use the batch function provided by ReactDOM or React Native.
94
+ */
95
+ setBatchNotifyFunction: (fn) => {
96
+ batchNotifyFn = fn;
97
+ },
98
+ setScheduler: (fn) => {
99
+ scheduleFn = fn;
100
+ }
95
101
  };
96
102
  }
97
103
  var notifyManager = createNotifyManager();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/notifyManager.ts"],"sourcesContent":["// TYPES\n\ntype NotifyCallback = () => void\n\ntype NotifyFunction = (callback: () => void) => void\n\ntype BatchNotifyFunction = (callback: () => void) => void\n\ntype BatchCallsCallback<T extends Array<unknown>> = (...args: T) => void\n\ntype ScheduleFunction = (callback: () => void) => void\n\nexport function createNotifyManager() {\n let queue: Array<NotifyCallback> = []\n let transactions = 0\n let notifyFn: NotifyFunction = (callback) => {\n callback()\n }\n let batchNotifyFn: BatchNotifyFunction = (callback: () => void) => {\n callback()\n }\n let scheduleFn: ScheduleFunction = (cb) => setTimeout(cb, 0)\n\n const setScheduler = (fn: ScheduleFunction) => {\n scheduleFn = fn\n }\n\n const batch = <T>(callback: () => T): T => {\n let result\n transactions++\n try {\n result = callback()\n } finally {\n transactions--\n if (!transactions) {\n flush()\n }\n }\n return result\n }\n\n const schedule = (callback: NotifyCallback): void => {\n if (transactions) {\n queue.push(callback)\n } else {\n scheduleFn(() => {\n notifyFn(callback)\n })\n }\n }\n\n /**\n * All calls to the wrapped function will be batched.\n */\n const batchCalls = <T extends Array<unknown>>(\n callback: BatchCallsCallback<T>,\n ): BatchCallsCallback<T> => {\n return (...args) => {\n schedule(() => {\n callback(...args)\n })\n }\n }\n\n const flush = (): void => {\n const originalQueue = queue\n queue = []\n if (originalQueue.length) {\n scheduleFn(() => {\n batchNotifyFn(() => {\n originalQueue.forEach((callback) => {\n notifyFn(callback)\n })\n })\n })\n }\n }\n\n /**\n * Use this method to set a custom notify function.\n * This can be used to for example wrap notifications with `React.act` while running tests.\n */\n const setNotifyFunction = (fn: NotifyFunction) => {\n notifyFn = fn\n }\n\n /**\n * Use this method to set a custom function to batch notifications together into a single tick.\n * By default React Query will use the batch function provided by ReactDOM or React Native.\n */\n const setBatchNotifyFunction = (fn: BatchNotifyFunction) => {\n batchNotifyFn = fn\n }\n\n return {\n batch,\n batchCalls,\n schedule,\n setNotifyFunction,\n setBatchNotifyFunction,\n setScheduler,\n } as const\n}\n\n// SINGLETON\nexport const notifyManager = createNotifyManager()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYO,SAAS,sBAAsB;AACpC,MAAI,QAA+B,CAAC;AACpC,MAAI,eAAe;AACnB,MAAI,WAA2B,CAAC,aAAa;AAC3C,aAAS;AAAA,EACX;AACA,MAAI,gBAAqC,CAAC,aAAyB;AACjE,aAAS;AAAA,EACX;AACA,MAAI,aAA+B,CAAC,OAAO,WAAW,IAAI,CAAC;AAE3D,QAAM,eAAe,CAAC,OAAyB;AAC7C,iBAAa;AAAA,EACf;AAEA,QAAM,QAAQ,CAAI,aAAyB;AACzC,QAAI;AACJ;AACA,QAAI;AACF,eAAS,SAAS;AAAA,IACpB,UAAE;AACA;AACA,UAAI,CAAC,cAAc;AACjB,cAAM;AAAA,MACR;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAEA,QAAM,WAAW,CAAC,aAAmC;AACnD,QAAI,cAAc;AAChB,YAAM,KAAK,QAAQ;AAAA,IACrB,OAAO;AACL,iBAAW,MAAM;AACf,iBAAS,QAAQ;AAAA,MACnB,CAAC;AAAA,IACH;AAAA,EACF;AAKA,QAAM,aAAa,CACjB,aAC0B;AAC1B,WAAO,IAAI,SAAS;AAClB,eAAS,MAAM;AACb,iBAAS,GAAG,IAAI;AAAA,MAClB,CAAC;AAAA,IACH;AAAA,EACF;AAEA,QAAM,QAAQ,MAAY;AACxB,UAAM,gBAAgB;AACtB,YAAQ,CAAC;AACT,QAAI,cAAc,QAAQ;AACxB,iBAAW,MAAM;AACf,sBAAc,MAAM;AAClB,wBAAc,QAAQ,CAAC,aAAa;AAClC,qBAAS,QAAQ;AAAA,UACnB,CAAC;AAAA,QACH,CAAC;AAAA,MACH,CAAC;AAAA,IACH;AAAA,EACF;AAMA,QAAM,oBAAoB,CAAC,OAAuB;AAChD,eAAW;AAAA,EACb;AAMA,QAAM,yBAAyB,CAAC,OAA4B;AAC1D,oBAAgB;AAAA,EAClB;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAGO,IAAM,gBAAgB,oBAAoB;","names":[]}
1
+ {"version":3,"sources":["../../src/notifyManager.ts"],"sourcesContent":["// TYPES\n\ntype NotifyCallback = () => void\n\ntype NotifyFunction = (callback: () => void) => void\n\ntype BatchNotifyFunction = (callback: () => void) => void\n\ntype BatchCallsCallback<T extends Array<unknown>> = (...args: T) => void\n\ntype ScheduleFunction = (callback: () => void) => void\n\nexport function createNotifyManager() {\n let queue: Array<NotifyCallback> = []\n let transactions = 0\n let notifyFn: NotifyFunction = (callback) => {\n callback()\n }\n let batchNotifyFn: BatchNotifyFunction = (callback: () => void) => {\n callback()\n }\n let scheduleFn: ScheduleFunction = (cb) => setTimeout(cb, 0)\n\n const schedule = (callback: NotifyCallback): void => {\n if (transactions) {\n queue.push(callback)\n } else {\n scheduleFn(() => {\n notifyFn(callback)\n })\n }\n }\n const flush = (): void => {\n const originalQueue = queue\n queue = []\n if (originalQueue.length) {\n scheduleFn(() => {\n batchNotifyFn(() => {\n originalQueue.forEach((callback) => {\n notifyFn(callback)\n })\n })\n })\n }\n }\n\n return {\n batch: <T>(callback: () => T): T => {\n let result\n transactions++\n try {\n result = callback()\n } finally {\n transactions--\n if (!transactions) {\n flush()\n }\n }\n return result\n },\n /**\n * All calls to the wrapped function will be batched.\n */\n batchCalls: <T extends Array<unknown>>(\n callback: BatchCallsCallback<T>,\n ): BatchCallsCallback<T> => {\n return (...args) => {\n schedule(() => {\n callback(...args)\n })\n }\n },\n schedule,\n /**\n * Use this method to set a custom notify function.\n * This can be used to for example wrap notifications with `React.act` while running tests.\n */\n setNotifyFunction: (fn: NotifyFunction) => {\n notifyFn = fn\n },\n /**\n * Use this method to set a custom function to batch notifications together into a single tick.\n * By default React Query will use the batch function provided by ReactDOM or React Native.\n */\n setBatchNotifyFunction: (fn: BatchNotifyFunction) => {\n batchNotifyFn = fn\n },\n setScheduler: (fn: ScheduleFunction) => {\n scheduleFn = fn\n },\n } as const\n}\n\n// SINGLETON\nexport const notifyManager = createNotifyManager()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYO,SAAS,sBAAsB;AACpC,MAAI,QAA+B,CAAC;AACpC,MAAI,eAAe;AACnB,MAAI,WAA2B,CAAC,aAAa;AAC3C,aAAS;AAAA,EACX;AACA,MAAI,gBAAqC,CAAC,aAAyB;AACjE,aAAS;AAAA,EACX;AACA,MAAI,aAA+B,CAAC,OAAO,WAAW,IAAI,CAAC;AAE3D,QAAM,WAAW,CAAC,aAAmC;AACnD,QAAI,cAAc;AAChB,YAAM,KAAK,QAAQ;AAAA,IACrB,OAAO;AACL,iBAAW,MAAM;AACf,iBAAS,QAAQ;AAAA,MACnB,CAAC;AAAA,IACH;AAAA,EACF;AACA,QAAM,QAAQ,MAAY;AACxB,UAAM,gBAAgB;AACtB,YAAQ,CAAC;AACT,QAAI,cAAc,QAAQ;AACxB,iBAAW,MAAM;AACf,sBAAc,MAAM;AAClB,wBAAc,QAAQ,CAAC,aAAa;AAClC,qBAAS,QAAQ;AAAA,UACnB,CAAC;AAAA,QACH,CAAC;AAAA,MACH,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AAAA,IACL,OAAO,CAAI,aAAyB;AAClC,UAAI;AACJ;AACA,UAAI;AACF,iBAAS,SAAS;AAAA,MACpB,UAAE;AACA;AACA,YAAI,CAAC,cAAc;AACjB,gBAAM;AAAA,QACR;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAIA,YAAY,CACV,aAC0B;AAC1B,aAAO,IAAI,SAAS;AAClB,iBAAS,MAAM;AACb,mBAAS,GAAG,IAAI;AAAA,QAClB,CAAC;AAAA,MACH;AAAA,IACF;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKA,mBAAmB,CAAC,OAAuB;AACzC,iBAAW;AAAA,IACb;AAAA;AAAA;AAAA;AAAA;AAAA,IAKA,wBAAwB,CAAC,OAA4B;AACnD,sBAAgB;AAAA,IAClB;AAAA,IACA,cAAc,CAAC,OAAyB;AACtC,mBAAa;AAAA,IACf;AAAA,EACF;AACF;AAGO,IAAM,gBAAgB,oBAAoB;","names":[]}
@@ -5,17 +5,39 @@ type BatchCallsCallback<T extends Array<unknown>> = (...args: T) => void;
5
5
  type ScheduleFunction = (callback: () => void) => void;
6
6
  declare function createNotifyManager(): {
7
7
  readonly batch: <T>(callback: () => T) => T;
8
+ /**
9
+ * All calls to the wrapped function will be batched.
10
+ */
8
11
  readonly batchCalls: <T_1 extends unknown[]>(callback: BatchCallsCallback<T_1>) => BatchCallsCallback<T_1>;
9
12
  readonly schedule: (callback: NotifyCallback) => void;
13
+ /**
14
+ * Use this method to set a custom notify function.
15
+ * This can be used to for example wrap notifications with `React.act` while running tests.
16
+ */
10
17
  readonly setNotifyFunction: (fn: NotifyFunction) => void;
18
+ /**
19
+ * Use this method to set a custom function to batch notifications together into a single tick.
20
+ * By default React Query will use the batch function provided by ReactDOM or React Native.
21
+ */
11
22
  readonly setBatchNotifyFunction: (fn: BatchNotifyFunction) => void;
12
23
  readonly setScheduler: (fn: ScheduleFunction) => void;
13
24
  };
14
25
  declare const notifyManager: {
15
26
  readonly batch: <T>(callback: () => T) => T;
27
+ /**
28
+ * All calls to the wrapped function will be batched.
29
+ */
16
30
  readonly batchCalls: <T_1 extends unknown[]>(callback: BatchCallsCallback<T_1>) => BatchCallsCallback<T_1>;
17
31
  readonly schedule: (callback: NotifyCallback) => void;
32
+ /**
33
+ * Use this method to set a custom notify function.
34
+ * This can be used to for example wrap notifications with `React.act` while running tests.
35
+ */
18
36
  readonly setNotifyFunction: (fn: NotifyFunction) => void;
37
+ /**
38
+ * Use this method to set a custom function to batch notifications together into a single tick.
39
+ * By default React Query will use the batch function provided by ReactDOM or React Native.
40
+ */
19
41
  readonly setBatchNotifyFunction: (fn: BatchNotifyFunction) => void;
20
42
  readonly setScheduler: (fn: ScheduleFunction) => void;
21
43
  };
@@ -5,17 +5,39 @@ type BatchCallsCallback<T extends Array<unknown>> = (...args: T) => void;
5
5
  type ScheduleFunction = (callback: () => void) => void;
6
6
  declare function createNotifyManager(): {
7
7
  readonly batch: <T>(callback: () => T) => T;
8
+ /**
9
+ * All calls to the wrapped function will be batched.
10
+ */
8
11
  readonly batchCalls: <T_1 extends unknown[]>(callback: BatchCallsCallback<T_1>) => BatchCallsCallback<T_1>;
9
12
  readonly schedule: (callback: NotifyCallback) => void;
13
+ /**
14
+ * Use this method to set a custom notify function.
15
+ * This can be used to for example wrap notifications with `React.act` while running tests.
16
+ */
10
17
  readonly setNotifyFunction: (fn: NotifyFunction) => void;
18
+ /**
19
+ * Use this method to set a custom function to batch notifications together into a single tick.
20
+ * By default React Query will use the batch function provided by ReactDOM or React Native.
21
+ */
11
22
  readonly setBatchNotifyFunction: (fn: BatchNotifyFunction) => void;
12
23
  readonly setScheduler: (fn: ScheduleFunction) => void;
13
24
  };
14
25
  declare const notifyManager: {
15
26
  readonly batch: <T>(callback: () => T) => T;
27
+ /**
28
+ * All calls to the wrapped function will be batched.
29
+ */
16
30
  readonly batchCalls: <T_1 extends unknown[]>(callback: BatchCallsCallback<T_1>) => BatchCallsCallback<T_1>;
17
31
  readonly schedule: (callback: NotifyCallback) => void;
32
+ /**
33
+ * Use this method to set a custom notify function.
34
+ * This can be used to for example wrap notifications with `React.act` while running tests.
35
+ */
18
36
  readonly setNotifyFunction: (fn: NotifyFunction) => void;
37
+ /**
38
+ * Use this method to set a custom function to batch notifications together into a single tick.
39
+ * By default React Query will use the batch function provided by ReactDOM or React Native.
40
+ */
19
41
  readonly setBatchNotifyFunction: (fn: BatchNotifyFunction) => void;
20
42
  readonly setScheduler: (fn: ScheduleFunction) => void;
21
43
  };
@@ -9,22 +9,6 @@ function createNotifyManager() {
9
9
  callback();
10
10
  };
11
11
  let scheduleFn = (cb) => setTimeout(cb, 0);
12
- const setScheduler = (fn) => {
13
- scheduleFn = fn;
14
- };
15
- const batch = (callback) => {
16
- let result;
17
- transactions++;
18
- try {
19
- result = callback();
20
- } finally {
21
- transactions--;
22
- if (!transactions) {
23
- flush();
24
- }
25
- }
26
- return result;
27
- };
28
12
  const schedule = (callback) => {
29
13
  if (transactions) {
30
14
  queue.push(callback);
@@ -34,13 +18,6 @@ function createNotifyManager() {
34
18
  });
35
19
  }
36
20
  };
37
- const batchCalls = (callback) => {
38
- return (...args) => {
39
- schedule(() => {
40
- callback(...args);
41
- });
42
- };
43
- };
44
21
  const flush = () => {
45
22
  const originalQueue = queue;
46
23
  queue = [];
@@ -54,19 +31,48 @@ function createNotifyManager() {
54
31
  });
55
32
  }
56
33
  };
57
- const setNotifyFunction = (fn) => {
58
- notifyFn = fn;
59
- };
60
- const setBatchNotifyFunction = (fn) => {
61
- batchNotifyFn = fn;
62
- };
63
34
  return {
64
- batch,
65
- batchCalls,
35
+ batch: (callback) => {
36
+ let result;
37
+ transactions++;
38
+ try {
39
+ result = callback();
40
+ } finally {
41
+ transactions--;
42
+ if (!transactions) {
43
+ flush();
44
+ }
45
+ }
46
+ return result;
47
+ },
48
+ /**
49
+ * All calls to the wrapped function will be batched.
50
+ */
51
+ batchCalls: (callback) => {
52
+ return (...args) => {
53
+ schedule(() => {
54
+ callback(...args);
55
+ });
56
+ };
57
+ },
66
58
  schedule,
67
- setNotifyFunction,
68
- setBatchNotifyFunction,
69
- setScheduler
59
+ /**
60
+ * Use this method to set a custom notify function.
61
+ * This can be used to for example wrap notifications with `React.act` while running tests.
62
+ */
63
+ setNotifyFunction: (fn) => {
64
+ notifyFn = fn;
65
+ },
66
+ /**
67
+ * Use this method to set a custom function to batch notifications together into a single tick.
68
+ * By default React Query will use the batch function provided by ReactDOM or React Native.
69
+ */
70
+ setBatchNotifyFunction: (fn) => {
71
+ batchNotifyFn = fn;
72
+ },
73
+ setScheduler: (fn) => {
74
+ scheduleFn = fn;
75
+ }
70
76
  };
71
77
  }
72
78
  var notifyManager = createNotifyManager();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/notifyManager.ts"],"sourcesContent":["// TYPES\n\ntype NotifyCallback = () => void\n\ntype NotifyFunction = (callback: () => void) => void\n\ntype BatchNotifyFunction = (callback: () => void) => void\n\ntype BatchCallsCallback<T extends Array<unknown>> = (...args: T) => void\n\ntype ScheduleFunction = (callback: () => void) => void\n\nexport function createNotifyManager() {\n let queue: Array<NotifyCallback> = []\n let transactions = 0\n let notifyFn: NotifyFunction = (callback) => {\n callback()\n }\n let batchNotifyFn: BatchNotifyFunction = (callback: () => void) => {\n callback()\n }\n let scheduleFn: ScheduleFunction = (cb) => setTimeout(cb, 0)\n\n const setScheduler = (fn: ScheduleFunction) => {\n scheduleFn = fn\n }\n\n const batch = <T>(callback: () => T): T => {\n let result\n transactions++\n try {\n result = callback()\n } finally {\n transactions--\n if (!transactions) {\n flush()\n }\n }\n return result\n }\n\n const schedule = (callback: NotifyCallback): void => {\n if (transactions) {\n queue.push(callback)\n } else {\n scheduleFn(() => {\n notifyFn(callback)\n })\n }\n }\n\n /**\n * All calls to the wrapped function will be batched.\n */\n const batchCalls = <T extends Array<unknown>>(\n callback: BatchCallsCallback<T>,\n ): BatchCallsCallback<T> => {\n return (...args) => {\n schedule(() => {\n callback(...args)\n })\n }\n }\n\n const flush = (): void => {\n const originalQueue = queue\n queue = []\n if (originalQueue.length) {\n scheduleFn(() => {\n batchNotifyFn(() => {\n originalQueue.forEach((callback) => {\n notifyFn(callback)\n })\n })\n })\n }\n }\n\n /**\n * Use this method to set a custom notify function.\n * This can be used to for example wrap notifications with `React.act` while running tests.\n */\n const setNotifyFunction = (fn: NotifyFunction) => {\n notifyFn = fn\n }\n\n /**\n * Use this method to set a custom function to batch notifications together into a single tick.\n * By default React Query will use the batch function provided by ReactDOM or React Native.\n */\n const setBatchNotifyFunction = (fn: BatchNotifyFunction) => {\n batchNotifyFn = fn\n }\n\n return {\n batch,\n batchCalls,\n schedule,\n setNotifyFunction,\n setBatchNotifyFunction,\n setScheduler,\n } as const\n}\n\n// SINGLETON\nexport const notifyManager = createNotifyManager()\n"],"mappings":";AAYO,SAAS,sBAAsB;AACpC,MAAI,QAA+B,CAAC;AACpC,MAAI,eAAe;AACnB,MAAI,WAA2B,CAAC,aAAa;AAC3C,aAAS;AAAA,EACX;AACA,MAAI,gBAAqC,CAAC,aAAyB;AACjE,aAAS;AAAA,EACX;AACA,MAAI,aAA+B,CAAC,OAAO,WAAW,IAAI,CAAC;AAE3D,QAAM,eAAe,CAAC,OAAyB;AAC7C,iBAAa;AAAA,EACf;AAEA,QAAM,QAAQ,CAAI,aAAyB;AACzC,QAAI;AACJ;AACA,QAAI;AACF,eAAS,SAAS;AAAA,IACpB,UAAE;AACA;AACA,UAAI,CAAC,cAAc;AACjB,cAAM;AAAA,MACR;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAEA,QAAM,WAAW,CAAC,aAAmC;AACnD,QAAI,cAAc;AAChB,YAAM,KAAK,QAAQ;AAAA,IACrB,OAAO;AACL,iBAAW,MAAM;AACf,iBAAS,QAAQ;AAAA,MACnB,CAAC;AAAA,IACH;AAAA,EACF;AAKA,QAAM,aAAa,CACjB,aAC0B;AAC1B,WAAO,IAAI,SAAS;AAClB,eAAS,MAAM;AACb,iBAAS,GAAG,IAAI;AAAA,MAClB,CAAC;AAAA,IACH;AAAA,EACF;AAEA,QAAM,QAAQ,MAAY;AACxB,UAAM,gBAAgB;AACtB,YAAQ,CAAC;AACT,QAAI,cAAc,QAAQ;AACxB,iBAAW,MAAM;AACf,sBAAc,MAAM;AAClB,wBAAc,QAAQ,CAAC,aAAa;AAClC,qBAAS,QAAQ;AAAA,UACnB,CAAC;AAAA,QACH,CAAC;AAAA,MACH,CAAC;AAAA,IACH;AAAA,EACF;AAMA,QAAM,oBAAoB,CAAC,OAAuB;AAChD,eAAW;AAAA,EACb;AAMA,QAAM,yBAAyB,CAAC,OAA4B;AAC1D,oBAAgB;AAAA,EAClB;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAGO,IAAM,gBAAgB,oBAAoB;","names":[]}
1
+ {"version":3,"sources":["../../src/notifyManager.ts"],"sourcesContent":["// TYPES\n\ntype NotifyCallback = () => void\n\ntype NotifyFunction = (callback: () => void) => void\n\ntype BatchNotifyFunction = (callback: () => void) => void\n\ntype BatchCallsCallback<T extends Array<unknown>> = (...args: T) => void\n\ntype ScheduleFunction = (callback: () => void) => void\n\nexport function createNotifyManager() {\n let queue: Array<NotifyCallback> = []\n let transactions = 0\n let notifyFn: NotifyFunction = (callback) => {\n callback()\n }\n let batchNotifyFn: BatchNotifyFunction = (callback: () => void) => {\n callback()\n }\n let scheduleFn: ScheduleFunction = (cb) => setTimeout(cb, 0)\n\n const schedule = (callback: NotifyCallback): void => {\n if (transactions) {\n queue.push(callback)\n } else {\n scheduleFn(() => {\n notifyFn(callback)\n })\n }\n }\n const flush = (): void => {\n const originalQueue = queue\n queue = []\n if (originalQueue.length) {\n scheduleFn(() => {\n batchNotifyFn(() => {\n originalQueue.forEach((callback) => {\n notifyFn(callback)\n })\n })\n })\n }\n }\n\n return {\n batch: <T>(callback: () => T): T => {\n let result\n transactions++\n try {\n result = callback()\n } finally {\n transactions--\n if (!transactions) {\n flush()\n }\n }\n return result\n },\n /**\n * All calls to the wrapped function will be batched.\n */\n batchCalls: <T extends Array<unknown>>(\n callback: BatchCallsCallback<T>,\n ): BatchCallsCallback<T> => {\n return (...args) => {\n schedule(() => {\n callback(...args)\n })\n }\n },\n schedule,\n /**\n * Use this method to set a custom notify function.\n * This can be used to for example wrap notifications with `React.act` while running tests.\n */\n setNotifyFunction: (fn: NotifyFunction) => {\n notifyFn = fn\n },\n /**\n * Use this method to set a custom function to batch notifications together into a single tick.\n * By default React Query will use the batch function provided by ReactDOM or React Native.\n */\n setBatchNotifyFunction: (fn: BatchNotifyFunction) => {\n batchNotifyFn = fn\n },\n setScheduler: (fn: ScheduleFunction) => {\n scheduleFn = fn\n },\n } as const\n}\n\n// SINGLETON\nexport const notifyManager = createNotifyManager()\n"],"mappings":";AAYO,SAAS,sBAAsB;AACpC,MAAI,QAA+B,CAAC;AACpC,MAAI,eAAe;AACnB,MAAI,WAA2B,CAAC,aAAa;AAC3C,aAAS;AAAA,EACX;AACA,MAAI,gBAAqC,CAAC,aAAyB;AACjE,aAAS;AAAA,EACX;AACA,MAAI,aAA+B,CAAC,OAAO,WAAW,IAAI,CAAC;AAE3D,QAAM,WAAW,CAAC,aAAmC;AACnD,QAAI,cAAc;AAChB,YAAM,KAAK,QAAQ;AAAA,IACrB,OAAO;AACL,iBAAW,MAAM;AACf,iBAAS,QAAQ;AAAA,MACnB,CAAC;AAAA,IACH;AAAA,EACF;AACA,QAAM,QAAQ,MAAY;AACxB,UAAM,gBAAgB;AACtB,YAAQ,CAAC;AACT,QAAI,cAAc,QAAQ;AACxB,iBAAW,MAAM;AACf,sBAAc,MAAM;AAClB,wBAAc,QAAQ,CAAC,aAAa;AAClC,qBAAS,QAAQ;AAAA,UACnB,CAAC;AAAA,QACH,CAAC;AAAA,MACH,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AAAA,IACL,OAAO,CAAI,aAAyB;AAClC,UAAI;AACJ;AACA,UAAI;AACF,iBAAS,SAAS;AAAA,MACpB,UAAE;AACA;AACA,YAAI,CAAC,cAAc;AACjB,gBAAM;AAAA,QACR;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAIA,YAAY,CACV,aAC0B;AAC1B,aAAO,IAAI,SAAS;AAClB,iBAAS,MAAM;AACb,mBAAS,GAAG,IAAI;AAAA,QAClB,CAAC;AAAA,MACH;AAAA,IACF;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKA,mBAAmB,CAAC,OAAuB;AACzC,iBAAW;AAAA,IACb;AAAA;AAAA;AAAA;AAAA;AAAA,IAKA,wBAAwB,CAAC,OAA4B;AACnD,sBAAgB;AAAA,IAClB;AAAA,IACA,cAAc,CAAC,OAAyB;AACtC,mBAAa;AAAA,IACf;AAAA,EACF;AACF;AAGO,IAAM,gBAAgB,oBAAoB;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/query-core",
3
- "version": "5.55.3",
3
+ "version": "5.55.4",
4
4
  "description": "The framework agnostic core that powers TanStack Query",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -21,24 +21,6 @@ export function createNotifyManager() {
21
21
  }
22
22
  let scheduleFn: ScheduleFunction = (cb) => setTimeout(cb, 0)
23
23
 
24
- const setScheduler = (fn: ScheduleFunction) => {
25
- scheduleFn = fn
26
- }
27
-
28
- const batch = <T>(callback: () => T): T => {
29
- let result
30
- transactions++
31
- try {
32
- result = callback()
33
- } finally {
34
- transactions--
35
- if (!transactions) {
36
- flush()
37
- }
38
- }
39
- return result
40
- }
41
-
42
24
  const schedule = (callback: NotifyCallback): void => {
43
25
  if (transactions) {
44
26
  queue.push(callback)
@@ -48,20 +30,6 @@ export function createNotifyManager() {
48
30
  })
49
31
  }
50
32
  }
51
-
52
- /**
53
- * All calls to the wrapped function will be batched.
54
- */
55
- const batchCalls = <T extends Array<unknown>>(
56
- callback: BatchCallsCallback<T>,
57
- ): BatchCallsCallback<T> => {
58
- return (...args) => {
59
- schedule(() => {
60
- callback(...args)
61
- })
62
- }
63
- }
64
-
65
33
  const flush = (): void => {
66
34
  const originalQueue = queue
67
35
  queue = []
@@ -76,29 +44,50 @@ export function createNotifyManager() {
76
44
  }
77
45
  }
78
46
 
79
- /**
80
- * Use this method to set a custom notify function.
81
- * This can be used to for example wrap notifications with `React.act` while running tests.
82
- */
83
- const setNotifyFunction = (fn: NotifyFunction) => {
84
- notifyFn = fn
85
- }
86
-
87
- /**
88
- * Use this method to set a custom function to batch notifications together into a single tick.
89
- * By default React Query will use the batch function provided by ReactDOM or React Native.
90
- */
91
- const setBatchNotifyFunction = (fn: BatchNotifyFunction) => {
92
- batchNotifyFn = fn
93
- }
94
-
95
47
  return {
96
- batch,
97
- batchCalls,
48
+ batch: <T>(callback: () => T): T => {
49
+ let result
50
+ transactions++
51
+ try {
52
+ result = callback()
53
+ } finally {
54
+ transactions--
55
+ if (!transactions) {
56
+ flush()
57
+ }
58
+ }
59
+ return result
60
+ },
61
+ /**
62
+ * All calls to the wrapped function will be batched.
63
+ */
64
+ batchCalls: <T extends Array<unknown>>(
65
+ callback: BatchCallsCallback<T>,
66
+ ): BatchCallsCallback<T> => {
67
+ return (...args) => {
68
+ schedule(() => {
69
+ callback(...args)
70
+ })
71
+ }
72
+ },
98
73
  schedule,
99
- setNotifyFunction,
100
- setBatchNotifyFunction,
101
- setScheduler,
74
+ /**
75
+ * Use this method to set a custom notify function.
76
+ * This can be used to for example wrap notifications with `React.act` while running tests.
77
+ */
78
+ setNotifyFunction: (fn: NotifyFunction) => {
79
+ notifyFn = fn
80
+ },
81
+ /**
82
+ * Use this method to set a custom function to batch notifications together into a single tick.
83
+ * By default React Query will use the batch function provided by ReactDOM or React Native.
84
+ */
85
+ setBatchNotifyFunction: (fn: BatchNotifyFunction) => {
86
+ batchNotifyFn = fn
87
+ },
88
+ setScheduler: (fn: ScheduleFunction) => {
89
+ scheduleFn = fn
90
+ },
102
91
  } as const
103
92
  }
104
93