@tanstack/query-broadcast-client-experimental 4.32.6 → 4.34.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/lib/index.d.ts +3 -1
- package/build/lib/index.esm.js +4 -2
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.js +4 -2
- package/build/lib/index.js.map +1 -1
- package/build/lib/index.mjs +4 -2
- package/build/lib/index.mjs.map +1 -1
- package/build/umd/index.development.js +4 -2
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +4 -0
- package/build/lib/index.d.ts.map +0 -1
package/build/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { BroadcastChannelOptions } from 'broadcast-channel';
|
|
1
2
|
import type { QueryClient } from '@tanstack/query-core';
|
|
2
3
|
interface BroadcastQueryClientOptions {
|
|
3
4
|
queryClient: QueryClient;
|
|
4
5
|
broadcastChannel?: string;
|
|
6
|
+
options?: BroadcastChannelOptions;
|
|
5
7
|
}
|
|
6
|
-
export declare function broadcastQueryClient({ queryClient, broadcastChannel, }: BroadcastQueryClientOptions): void;
|
|
8
|
+
export declare function broadcastQueryClient({ queryClient, broadcastChannel, options, }: BroadcastQueryClientOptions): void;
|
|
7
9
|
export {};
|
|
8
10
|
//# sourceMappingURL=index.d.ts.map
|
package/build/lib/index.esm.js
CHANGED
|
@@ -2,7 +2,8 @@ import { BroadcastChannel } from 'broadcast-channel';
|
|
|
2
2
|
|
|
3
3
|
function broadcastQueryClient({
|
|
4
4
|
queryClient,
|
|
5
|
-
broadcastChannel = 'tanstack-query'
|
|
5
|
+
broadcastChannel = 'tanstack-query',
|
|
6
|
+
options
|
|
6
7
|
}) {
|
|
7
8
|
let transaction = false;
|
|
8
9
|
|
|
@@ -13,7 +14,8 @@ function broadcastQueryClient({
|
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
const channel = new BroadcastChannel(broadcastChannel, {
|
|
16
|
-
webWorkerSupport: false
|
|
17
|
+
webWorkerSupport: false,
|
|
18
|
+
...options
|
|
17
19
|
});
|
|
18
20
|
const queryCache = queryClient.getQueryCache();
|
|
19
21
|
queryClient.getQueryCache().subscribe(queryEvent => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../../src/index.ts"],"sourcesContent":["import { BroadcastChannel } from 'broadcast-channel'\nimport type { QueryClient } from '@tanstack/query-core'\n\ninterface BroadcastQueryClientOptions {\n queryClient: QueryClient\n broadcastChannel?: string\n}\n\nexport function broadcastQueryClient({\n queryClient,\n broadcastChannel = 'tanstack-query',\n}: BroadcastQueryClientOptions) {\n let transaction = false\n const tx = (cb: () => void) => {\n transaction = true\n cb()\n transaction = false\n }\n\n const channel = new BroadcastChannel(broadcastChannel, {\n webWorkerSupport: false,\n })\n\n const queryCache = queryClient.getQueryCache()\n\n queryClient.getQueryCache().subscribe((queryEvent) => {\n if (transaction) {\n return\n }\n\n const {\n query: { queryHash, queryKey, state },\n } = queryEvent\n\n if (queryEvent.type === 'updated' && queryEvent.action.type === 'success') {\n channel.postMessage({\n type: 'updated',\n queryHash,\n queryKey,\n state,\n })\n }\n\n if (queryEvent.type === 'removed') {\n channel.postMessage({\n type: 'removed',\n queryHash,\n queryKey,\n })\n }\n })\n\n channel.onmessage = (action) => {\n if (!action?.type) {\n return\n }\n\n tx(() => {\n const { type, queryHash, queryKey, state } = action\n\n if (type === 'updated') {\n const query = queryCache.get(queryHash)\n\n if (query) {\n query.setState(state)\n return\n }\n\n queryCache.build(\n queryClient,\n {\n queryKey,\n queryHash,\n },\n state,\n )\n } else if (type === 'removed') {\n const query = queryCache.get(queryHash)\n\n if (query) {\n queryCache.remove(query)\n }\n }\n })\n }\n}\n"],"names":["broadcastQueryClient","queryClient","broadcastChannel","transaction","tx","cb","channel","BroadcastChannel","webWorkerSupport","queryCache","getQueryCache","subscribe","queryEvent","query","queryHash","queryKey","state","type","action","postMessage","onmessage","get","setState","build","remove"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../src/index.ts"],"sourcesContent":["import { BroadcastChannel } from 'broadcast-channel'\nimport type { BroadcastChannelOptions } from 'broadcast-channel'\nimport type { QueryClient } from '@tanstack/query-core'\n\ninterface BroadcastQueryClientOptions {\n queryClient: QueryClient\n broadcastChannel?: string\n options?: BroadcastChannelOptions\n}\n\nexport function broadcastQueryClient({\n queryClient,\n broadcastChannel = 'tanstack-query',\n options,\n}: BroadcastQueryClientOptions) {\n let transaction = false\n const tx = (cb: () => void) => {\n transaction = true\n cb()\n transaction = false\n }\n\n const channel = new BroadcastChannel(broadcastChannel, {\n webWorkerSupport: false,\n ...options,\n })\n\n const queryCache = queryClient.getQueryCache()\n\n queryClient.getQueryCache().subscribe((queryEvent) => {\n if (transaction) {\n return\n }\n\n const {\n query: { queryHash, queryKey, state },\n } = queryEvent\n\n if (queryEvent.type === 'updated' && queryEvent.action.type === 'success') {\n channel.postMessage({\n type: 'updated',\n queryHash,\n queryKey,\n state,\n })\n }\n\n if (queryEvent.type === 'removed') {\n channel.postMessage({\n type: 'removed',\n queryHash,\n queryKey,\n })\n }\n })\n\n channel.onmessage = (action) => {\n if (!action?.type) {\n return\n }\n\n tx(() => {\n const { type, queryHash, queryKey, state } = action\n\n if (type === 'updated') {\n const query = queryCache.get(queryHash)\n\n if (query) {\n query.setState(state)\n return\n }\n\n queryCache.build(\n queryClient,\n {\n queryKey,\n queryHash,\n },\n state,\n )\n } else if (type === 'removed') {\n const query = queryCache.get(queryHash)\n\n if (query) {\n queryCache.remove(query)\n }\n }\n })\n }\n}\n"],"names":["broadcastQueryClient","queryClient","broadcastChannel","options","transaction","tx","cb","channel","BroadcastChannel","webWorkerSupport","queryCache","getQueryCache","subscribe","queryEvent","query","queryHash","queryKey","state","type","action","postMessage","onmessage","get","setState","build","remove"],"mappings":";;AAUO,SAASA,oBAA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KD,KAAA;GAxBH,CAAA,CAAA;;AA2BAT,EAAAA,OAAO,CAACc,SAAR,GAAqBF,MAAD,IAAY;AAC9B,IAAA,IAAI,EAACA,MAAD,IAAA,IAAA,IAACA,MAAM,CAAED,IAAT,CAAJ,EAAmB;AACjB,MAAA,OAAA;AACD,KAAA;;AAEDb,IAAAA,EAAE,CAAC,MAAM;MACP,MAAM;QAAEa,IAAF;QAAQH,SAAR;QAAmBC,QAAnB;AAA6BC,QAAAA,KAAAA;AAA7B,OAAA,GAAuCE,MAA7C,CAAA;;MAEA,IAAID,IAAI,KAAK,SAAb,EAAwB;AACtB,QAAA,MAAMJ,KAAK,GAAGJ,UAAU,CAACY,GAAX,CAAeP,SAAf,CAAd,CAAA;;AAEA,QAAA,IAAID,KAAJ,EAAW;UACTA,KAAK,CAACS,QAAN,CAAeN,KAAf,CAAA,CAAA;AACA,UAAA,OAAA;AACD,SAAA;;AAEDP,QAAAA,UAAU,CAACc,KAAX,CACEvB,WADF,EAEE;UACEe,QADF;AAEED,UAAAA,SAAAA;AAFF,SAFF,EAMEE,KANF,CAAA,CAAA;AAQD,OAhBD,MAgBO,IAAIC,IAAI,KAAK,SAAb,EAAwB;AAC7B,QAAA,MAAMJ,KAAK,GAAGJ,UAAU,CAACY,GAAX,CAAeP,SAAf,CAAd,CAAA;;AAEA,QAAA,IAAID,KAAJ,EAAW;UACTJ,UAAU,CAACe,MAAX,CAAkBX,KAAlB,CAAA,CAAA;AACD,SAAA;AACF,OAAA;AACF,KA1BC,CAAF,CAAA;GALF,CAAA;AAiCD;;;;"}
|
package/build/lib/index.js
CHANGED
|
@@ -6,7 +6,8 @@ var broadcastChannel = require('broadcast-channel');
|
|
|
6
6
|
|
|
7
7
|
function broadcastQueryClient({
|
|
8
8
|
queryClient,
|
|
9
|
-
broadcastChannel: broadcastChannel$1 = 'tanstack-query'
|
|
9
|
+
broadcastChannel: broadcastChannel$1 = 'tanstack-query',
|
|
10
|
+
options
|
|
10
11
|
}) {
|
|
11
12
|
let transaction = false;
|
|
12
13
|
|
|
@@ -17,7 +18,8 @@ function broadcastQueryClient({
|
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
const channel = new broadcastChannel.BroadcastChannel(broadcastChannel$1, {
|
|
20
|
-
webWorkerSupport: false
|
|
21
|
+
webWorkerSupport: false,
|
|
22
|
+
...options
|
|
21
23
|
});
|
|
22
24
|
const queryCache = queryClient.getQueryCache();
|
|
23
25
|
queryClient.getQueryCache().subscribe(queryEvent => {
|
package/build/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import { BroadcastChannel } from 'broadcast-channel'\nimport type { QueryClient } from '@tanstack/query-core'\n\ninterface BroadcastQueryClientOptions {\n queryClient: QueryClient\n broadcastChannel?: string\n}\n\nexport function broadcastQueryClient({\n queryClient,\n broadcastChannel = 'tanstack-query',\n}: BroadcastQueryClientOptions) {\n let transaction = false\n const tx = (cb: () => void) => {\n transaction = true\n cb()\n transaction = false\n }\n\n const channel = new BroadcastChannel(broadcastChannel, {\n webWorkerSupport: false,\n })\n\n const queryCache = queryClient.getQueryCache()\n\n queryClient.getQueryCache().subscribe((queryEvent) => {\n if (transaction) {\n return\n }\n\n const {\n query: { queryHash, queryKey, state },\n } = queryEvent\n\n if (queryEvent.type === 'updated' && queryEvent.action.type === 'success') {\n channel.postMessage({\n type: 'updated',\n queryHash,\n queryKey,\n state,\n })\n }\n\n if (queryEvent.type === 'removed') {\n channel.postMessage({\n type: 'removed',\n queryHash,\n queryKey,\n })\n }\n })\n\n channel.onmessage = (action) => {\n if (!action?.type) {\n return\n }\n\n tx(() => {\n const { type, queryHash, queryKey, state } = action\n\n if (type === 'updated') {\n const query = queryCache.get(queryHash)\n\n if (query) {\n query.setState(state)\n return\n }\n\n queryCache.build(\n queryClient,\n {\n queryKey,\n queryHash,\n },\n state,\n )\n } else if (type === 'removed') {\n const query = queryCache.get(queryHash)\n\n if (query) {\n queryCache.remove(query)\n }\n }\n })\n }\n}\n"],"names":["broadcastQueryClient","queryClient","broadcastChannel","transaction","tx","cb","channel","BroadcastChannel","webWorkerSupport","queryCache","getQueryCache","subscribe","queryEvent","query","queryHash","queryKey","state","type","action","postMessage","onmessage","get","setState","build","remove"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import { BroadcastChannel } from 'broadcast-channel'\nimport type { BroadcastChannelOptions } from 'broadcast-channel'\nimport type { QueryClient } from '@tanstack/query-core'\n\ninterface BroadcastQueryClientOptions {\n queryClient: QueryClient\n broadcastChannel?: string\n options?: BroadcastChannelOptions\n}\n\nexport function broadcastQueryClient({\n queryClient,\n broadcastChannel = 'tanstack-query',\n options,\n}: BroadcastQueryClientOptions) {\n let transaction = false\n const tx = (cb: () => void) => {\n transaction = true\n cb()\n transaction = false\n }\n\n const channel = new BroadcastChannel(broadcastChannel, {\n webWorkerSupport: false,\n ...options,\n })\n\n const queryCache = queryClient.getQueryCache()\n\n queryClient.getQueryCache().subscribe((queryEvent) => {\n if (transaction) {\n return\n }\n\n const {\n query: { queryHash, queryKey, state },\n } = queryEvent\n\n if (queryEvent.type === 'updated' && queryEvent.action.type === 'success') {\n channel.postMessage({\n type: 'updated',\n queryHash,\n queryKey,\n state,\n })\n }\n\n if (queryEvent.type === 'removed') {\n channel.postMessage({\n type: 'removed',\n queryHash,\n queryKey,\n })\n }\n })\n\n channel.onmessage = (action) => {\n if (!action?.type) {\n return\n }\n\n tx(() => {\n const { type, queryHash, queryKey, state } = action\n\n if (type === 'updated') {\n const query = queryCache.get(queryHash)\n\n if (query) {\n query.setState(state)\n return\n }\n\n queryCache.build(\n queryClient,\n {\n queryKey,\n queryHash,\n },\n state,\n )\n } else if (type === 'removed') {\n const query = queryCache.get(queryHash)\n\n if (query) {\n queryCache.remove(query)\n }\n }\n })\n }\n}\n"],"names":["broadcastQueryClient","queryClient","broadcastChannel","options","transaction","tx","cb","channel","BroadcastChannel","webWorkerSupport","queryCache","getQueryCache","subscribe","queryEvent","query","queryHash","queryKey","state","type","action","postMessage","onmessage","get","setState","build","remove"],"mappings":";;;;;;AAUO,SAASA,oBAAT,CAA8B;EACnCC,WADmC;AAEnCC,oBAAAA,kBAAgB,GAAG,gBAFgB;AAGnCC,EAAAA,OAAAA;AAHmC,CAA9B,EAIyB;EAC9B,IAAIC,WAAW,GAAG,KAAlB,CAAA;;EACA,MAAMC,EAAE,GAAIC,EAAD,IAAoB;AAC7BF,IAAAA,WAAW,GAAG,IAAd,CAAA;IACAE,EAAE,EAAA,CAAA;AACFF,IAAAA,WAAW,GAAG,KAAd,CAAA;GAHF,CAAA;;AAMA,EAAA,MAAMG,OAAO,GAAG,IAAIC,iCAAJ,CAAqBN,kBAArB,EAAuC;AACrDO,IAAAA,gBAAgB,EAAE,KADmC;IAErD,GAAGN,OAAAA;AAFkD,GAAvC,CAAhB,CAAA;AAKA,EAAA,MAAMO,UAAU,GAAGT,WAAW,CAACU,aAAZ,EAAnB,CAAA;AAEAV,EAAAA,WAAW,CAACU,aAAZ,EAAA,CAA4BC,SAA5B,CAAuCC,UAAD,IAAgB;AACpD,IAAA,IAAIT,WAAJ,EAAiB;AACf,MAAA,OAAA;AACD,KAAA;;IAED,MAAM;AACJU,MAAAA,KAAK,EAAE;QAAEC,SAAF;QAAaC,QAAb;AAAuBC,QAAAA,KAAAA;AAAvB,OAAA;AADH,KAAA,GAEFJ,UAFJ,CAAA;;AAIA,IAAA,IAAIA,UAAU,CAACK,IAAX,KAAoB,SAApB,IAAiCL,UAAU,CAACM,MAAX,CAAkBD,IAAlB,KAA2B,SAAhE,EAA2E;MACzEX,OAAO,CAACa,WAAR,CAAoB;AAClBF,QAAAA,IAAI,EAAE,SADY;QAElBH,SAFkB;QAGlBC,QAHkB;AAIlBC,QAAAA,KAAAA;OAJF,CAAA,CAAA;AAMD,KAAA;;AAED,IAAA,IAAIJ,UAAU,CAACK,IAAX,KAAoB,SAA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
queryClient,
|
|
5
|
-
broadcastChannel = 'tanstack-query'
|
|
5
|
+
broadcastChannel = 'tanstack-query',
|
|
6
|
+
options
|
|
6
7
|
}) {
|
|
7
8
|
let transaction = false;
|
|
8
9
|
|
|
@@ -13,7 +14,8 @@ function broadcastQueryClient({
|
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
const channel = new BroadcastChannel(broadcastChannel, {
|
|
16
|
-
webWorkerSupport: false
|
|
17
|
+
webWorkerSupport: false,
|
|
18
|
+
...options
|
|
17
19
|
});
|
|
18
20
|
const queryCache = queryClient.getQueryCache();
|
|
19
21
|
queryClient.getQueryCache().subscribe(queryEvent => {
|
package/build/lib/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/index.ts"],"sourcesContent":["import { BroadcastChannel } from 'broadcast-channel'\nimport type { QueryClient } from '@tanstack/query-core'\n\ninterface BroadcastQueryClientOptions {\n queryClient: QueryClient\n broadcastChannel?: string\n}\n\nexport function broadcastQueryClient({\n queryClient,\n broadcastChannel = 'tanstack-query',\n}: BroadcastQueryClientOptions) {\n let transaction = false\n const tx = (cb: () => void) => {\n transaction = true\n cb()\n transaction = false\n }\n\n const channel = new BroadcastChannel(broadcastChannel, {\n webWorkerSupport: false,\n })\n\n const queryCache = queryClient.getQueryCache()\n\n queryClient.getQueryCache().subscribe((queryEvent) => {\n if (transaction) {\n return\n }\n\n const {\n query: { queryHash, queryKey, state },\n } = queryEvent\n\n if (queryEvent.type === 'updated' && queryEvent.action.type === 'success') {\n channel.postMessage({\n type: 'updated',\n queryHash,\n queryKey,\n state,\n })\n }\n\n if (queryEvent.type === 'removed') {\n channel.postMessage({\n type: 'removed',\n queryHash,\n queryKey,\n })\n }\n })\n\n channel.onmessage = (action) => {\n if (!action?.type) {\n return\n }\n\n tx(() => {\n const { type, queryHash, queryKey, state } = action\n\n if (type === 'updated') {\n const query = queryCache.get(queryHash)\n\n if (query) {\n query.setState(state)\n return\n }\n\n queryCache.build(\n queryClient,\n {\n queryKey,\n queryHash,\n },\n state,\n )\n } else if (type === 'removed') {\n const query = queryCache.get(queryHash)\n\n if (query) {\n queryCache.remove(query)\n }\n }\n })\n }\n}\n"],"names":["broadcastQueryClient","queryClient","broadcastChannel","transaction","tx","cb","channel","BroadcastChannel","webWorkerSupport","queryCache","getQueryCache","subscribe","queryEvent","query","queryHash","queryKey","state","type","action","postMessage","onmessage","get","setState","build","remove"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/index.ts"],"sourcesContent":["import { BroadcastChannel } from 'broadcast-channel'\nimport type { BroadcastChannelOptions } from 'broadcast-channel'\nimport type { QueryClient } from '@tanstack/query-core'\n\ninterface BroadcastQueryClientOptions {\n queryClient: QueryClient\n broadcastChannel?: string\n options?: BroadcastChannelOptions\n}\n\nexport function broadcastQueryClient({\n queryClient,\n broadcastChannel = 'tanstack-query',\n options,\n}: BroadcastQueryClientOptions) {\n let transaction = false\n const tx = (cb: () => void) => {\n transaction = true\n cb()\n transaction = false\n }\n\n const channel = new BroadcastChannel(broadcastChannel, {\n webWorkerSupport: false,\n ...options,\n })\n\n const queryCache = queryClient.getQueryCache()\n\n queryClient.getQueryCache().subscribe((queryEvent) => {\n if (transaction) {\n return\n }\n\n const {\n query: { queryHash, queryKey, state },\n } = queryEvent\n\n if (queryEvent.type === 'updated' && queryEvent.action.type === 'success') {\n channel.postMessage({\n type: 'updated',\n queryHash,\n queryKey,\n state,\n })\n }\n\n if (queryEvent.type === 'removed') {\n channel.postMessage({\n type: 'removed',\n queryHash,\n queryKey,\n })\n }\n })\n\n channel.onmessage = (action) => {\n if (!action?.type) {\n return\n }\n\n tx(() => {\n const { type, queryHash, queryKey, state } = action\n\n if (type === 'updated') {\n const query = queryCache.get(queryHash)\n\n if (query) {\n query.setState(state)\n return\n }\n\n queryCache.build(\n queryClient,\n {\n queryKey,\n queryHash,\n },\n state,\n )\n } else if (type === 'removed') {\n const query = queryCache.get(queryHash)\n\n if (query) {\n queryCache.remove(query)\n }\n }\n })\n }\n}\n"],"names":["broadcastQueryClient","queryClient","broadcastChannel","options","transaction","tx","cb","channel","BroadcastChannel","webWorkerSupport","queryCache","getQueryCache","subscribe","queryEvent","query","queryHash","queryKey","state","type","action","postMessage","onmessage","get","setState","build","remove"],"mappings":";;AAUO,SAASA,oBAAT,CAA8B;EACnCC,WADmC;AAEnCC,EAAAA,gBAAgB,GAAG,gBAFgB;AAGnCC,EAAAA,OAAAA;AAHmC,CAA9B,EAIyB;EAC9B,IAAIC,WAAW,GAAG,KAAlB,CAAA;;EACA,MAAMC,EAAE,GAAIC,EAAD,IAAoB;AAC7BF,IAAAA,WAAW,GAAG,IAAd,CAAA;IACAE,EAAE,EAAA,CAAA;AACFF,IAAAA,WAAW,GAAG,KAAd,CAAA;GAHF,CAAA;;AAMA,EAAA,MAAMG,OAAO,GAAG,IAAIC,gBAAJ,CAAqBN,gBAArB,EAAuC;AACrDO,IAAAA,gBAAgB,EAAE,KADmC;IAErD,GAAGN,OAAAA;AAFkD,GAAvC,CAAhB,CAAA;AAKA,EAAA,MAAMO,UAAU,GAAGT,WAAW,CAACU,aAAZ,EAAnB,CAAA;AAEAV,EAAAA,WAAW,CAACU,aAAZ,EAAA,CAA4BC,SAA5B,CAAuCC,UAAD,IAAgB;AACpD,IAAA,IAAIT,WAAJ,EAAiB;AACf,MAAA,OAAA;AACD,KAAA;;IAED,MAAM;AACJU,MAAAA,KAAK,EAAE;QAAEC,SAAF;QAAaC,QAAb;AAAuBC,QAAAA,KAAAA;AAAvB,OAAA;AADH,KAAA,GAEFJ,UAFJ,CAAA;;AAIA,IAAA,IAAIA,UAAU,CAACK,IAAX,KAAoB,SAApB,IAAiCL,UAAU,CAACM,MAAX,CAAkBD,IAAlB,KAA2B,SAAhE,EAA2E;MACzEX,OAAO,CAACa,WAAR,CAAoB;AAClBF,QAAAA,IAAI,EAAE,SADY;QAElBH,SAFkB;QAGlBC,QAHkB;AAIlB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
6
6
|
|
|
7
7
|
function broadcastQueryClient({
|
|
8
8
|
queryClient,
|
|
9
|
-
broadcastChannel: broadcastChannel$1 = 'tanstack-query'
|
|
9
|
+
broadcastChannel: broadcastChannel$1 = 'tanstack-query',
|
|
10
|
+
options
|
|
10
11
|
}) {
|
|
11
12
|
let transaction = false;
|
|
12
13
|
|
|
@@ -17,7 +18,8 @@
|
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
const channel = new broadcastChannel.BroadcastChannel(broadcastChannel$1, {
|
|
20
|
-
webWorkerSupport: false
|
|
21
|
+
webWorkerSupport: false,
|
|
22
|
+
...options
|
|
21
23
|
});
|
|
22
24
|
const queryCache = queryClient.getQueryCache();
|
|
23
25
|
queryClient.getQueryCache().subscribe(queryEvent => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.development.js","sources":["../../src/index.ts"],"sourcesContent":["import { BroadcastChannel } from 'broadcast-channel'\nimport type { QueryClient } from '@tanstack/query-core'\n\ninterface BroadcastQueryClientOptions {\n queryClient: QueryClient\n broadcastChannel?: string\n}\n\nexport function broadcastQueryClient({\n queryClient,\n broadcastChannel = 'tanstack-query',\n}: BroadcastQueryClientOptions) {\n let transaction = false\n const tx = (cb: () => void) => {\n transaction = true\n cb()\n transaction = false\n }\n\n const channel = new BroadcastChannel(broadcastChannel, {\n webWorkerSupport: false,\n })\n\n const queryCache = queryClient.getQueryCache()\n\n queryClient.getQueryCache().subscribe((queryEvent) => {\n if (transaction) {\n return\n }\n\n const {\n query: { queryHash, queryKey, state },\n } = queryEvent\n\n if (queryEvent.type === 'updated' && queryEvent.action.type === 'success') {\n channel.postMessage({\n type: 'updated',\n queryHash,\n queryKey,\n state,\n })\n }\n\n if (queryEvent.type === 'removed') {\n channel.postMessage({\n type: 'removed',\n queryHash,\n queryKey,\n })\n }\n })\n\n channel.onmessage = (action) => {\n if (!action?.type) {\n return\n }\n\n tx(() => {\n const { type, queryHash, queryKey, state } = action\n\n if (type === 'updated') {\n const query = queryCache.get(queryHash)\n\n if (query) {\n query.setState(state)\n return\n }\n\n queryCache.build(\n queryClient,\n {\n queryKey,\n queryHash,\n },\n state,\n )\n } else if (type === 'removed') {\n const query = queryCache.get(queryHash)\n\n if (query) {\n queryCache.remove(query)\n }\n }\n })\n }\n}\n"],"names":["broadcastQueryClient","queryClient","broadcastChannel","transaction","tx","cb","channel","BroadcastChannel","webWorkerSupport","queryCache","getQueryCache","subscribe","queryEvent","query","queryHash","queryKey","state","type","action","postMessage","onmessage","get","setState","build","remove"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"index.development.js","sources":["../../src/index.ts"],"sourcesContent":["import { BroadcastChannel } from 'broadcast-channel'\nimport type { BroadcastChannelOptions } from 'broadcast-channel'\nimport type { QueryClient } from '@tanstack/query-core'\n\ninterface BroadcastQueryClientOptions {\n queryClient: QueryClient\n broadcastChannel?: string\n options?: BroadcastChannelOptions\n}\n\nexport function broadcastQueryClient({\n queryClient,\n broadcastChannel = 'tanstack-query',\n options,\n}: BroadcastQueryClientOptions) {\n let transaction = false\n const tx = (cb: () => void) => {\n transaction = true\n cb()\n transaction = false\n }\n\n const channel = new BroadcastChannel(broadcastChannel, {\n webWorkerSupport: false,\n ...options,\n })\n\n const queryCache = queryClient.getQueryCache()\n\n queryClient.getQueryCache().subscribe((queryEvent) => {\n if (transaction) {\n return\n }\n\n const {\n query: { queryHash, queryKey, state },\n } = queryEvent\n\n if (queryEvent.type === 'updated' && queryEvent.action.type === 'success') {\n channel.postMessage({\n type: 'updated',\n queryHash,\n queryKey,\n state,\n })\n }\n\n if (queryEvent.type === 'removed') {\n channel.postMessage({\n type: 'removed',\n queryHash,\n queryKey,\n })\n }\n })\n\n channel.onmessage = (action) => {\n if (!action?.type) {\n return\n }\n\n tx(() => {\n const { type, queryHash, queryKey, state } = action\n\n if (type === 'updated') {\n const query = queryCache.get(queryHash)\n\n if (query) {\n query.setState(state)\n return\n }\n\n queryCache.build(\n queryClient,\n {\n queryKey,\n queryHash,\n },\n state,\n )\n } else if (type === 'removed') {\n const query = queryCache.get(queryHash)\n\n if (query) {\n queryCache.remove(query)\n }\n }\n })\n }\n}\n"],"names":["broadcastQueryClient","queryClient","broadcastChannel","options","transaction","tx","cb","channel","BroadcastChannel","webWorkerSupport","queryCache","getQueryCache","subscribe","queryEvent","query","queryHash","queryKey","state","type","action","postMessage","onmessage","get","setState","build","remove"],"mappings":";;;;;;EAUO,SAASA,oBAAT,CAA8B;IACnCC,WADmC;EAEnCC,oBAAAA,kBAAgB,GAAG,gBAFgB;EAGnCC,EAAAA,OAAAA;EAHmC,CAA9B,EAIyB;IAC9B,IAAIC,WAAW,GAAG,KAAlB,CAAA;;IACA,MAAMC,EAAE,GAAIC,EAAD,IAAoB;EAC7BF,IAAAA,WAAW,GAAG,IAAd,CAAA;MACAE,EAAE,EAAA,CAAA;EACFF,IAAAA,WAAW,GAAG,KAAd,CAAA;KAHF,CAAA;;EAMA,EAAA,MAAMG,OAAO,GAAG,IAAIC,iCAAJ,CAAqBN,kBAArB,EAAuC;EACrDO,IAAAA,gBAAgB,EAAE,KADmC;MAErD,GAAGN,OAAAA;EAFkD,GAAvC,CAAhB,CAAA;EAKA,EAAA,MAAMO,UAAU,GAAGT,WAAW,CAACU,aAAZ,EAAnB,CAAA;EAEAV,EAAAA,WAAW,CAACU,aAAZ,EAAA,CAA4BC,SAA5B,CAAuCC,UAAD,IAAgB;EACpD,IAAA,IAAIT,WAAJ,EAAiB;EACf,MAAA,OAAA;EACD,KAAA;;MAED,MAAM;EACJU,MAAAA,KAAK,EAAE;UAAEC,SAAF;UAAaC,QAAb;EAAuBC,QAAAA,KAAAA;EAAvB,OAAA;EADH,KAAA,GAEFJ,UAFJ,CAAA;;EAIA,IAAA,IAAIA,UAAU,CAACK,IAAX,KAAoB,SAApB,IAAiCL,UAAU,CAACM,MAAX,CAAkBD,IAAlB,KAA2B,SAAhE,EAA2E;QACzEX,OAAO,CAACa,WAAR,CAAoB;EAClBF,QAAA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KALF,CAAA;EAiCD;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("broadcast-channel")):"function"==typeof define&&define.amd?define(["exports","broadcast-channel"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).QueryBroadcastClient={},e.BroadcastChannel)}(this,(function(e,t){"use strict";e.broadcastQueryClient=function({queryClient:e,broadcastChannel:s="tanstack-query"}){let
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("broadcast-channel")):"function"==typeof define&&define.amd?define(["exports","broadcast-channel"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).QueryBroadcastClient={},e.BroadcastChannel)}(this,(function(e,t){"use strict";e.broadcastQueryClient=function({queryClient:e,broadcastChannel:s="tanstack-query",options:r}){let a=!1;const n=new t.BroadcastChannel(s,{webWorkerSupport:!1,...r}),o=e.getQueryCache();e.getQueryCache().subscribe((e=>{if(a)return;const{query:{queryHash:t,queryKey:s,state:r}}=e;"updated"===e.type&&"success"===e.action.type&&n.postMessage({type:"updated",queryHash:t,queryKey:s,state:r}),"removed"===e.type&&n.postMessage({type:"removed",queryHash:t,queryKey:s})})),n.onmessage=t=>{null!=t&&t.type&&(a=!0,(()=>{const{type:s,queryHash:r,queryKey:a,state:n}=t;if("updated"===s){const t=o.get(r);if(t)return void t.setState(n);o.build(e,{queryKey:a,queryHash:r},n)}else if("removed"===s){const e=o.get(r);e&&o.remove(e)}})(),a=!1)}},Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
2
2
|
//# sourceMappingURL=index.production.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.production.js","sources":["../../src/index.ts"],"sourcesContent":["import { BroadcastChannel } from 'broadcast-channel'\nimport type { QueryClient } from '@tanstack/query-core'\n\ninterface BroadcastQueryClientOptions {\n queryClient: QueryClient\n broadcastChannel?: string\n}\n\nexport function broadcastQueryClient({\n queryClient,\n broadcastChannel = 'tanstack-query',\n}: BroadcastQueryClientOptions) {\n let transaction = false\n const tx = (cb: () => void) => {\n transaction = true\n cb()\n transaction = false\n }\n\n const channel = new BroadcastChannel(broadcastChannel, {\n webWorkerSupport: false,\n })\n\n const queryCache = queryClient.getQueryCache()\n\n queryClient.getQueryCache().subscribe((queryEvent) => {\n if (transaction) {\n return\n }\n\n const {\n query: { queryHash, queryKey, state },\n } = queryEvent\n\n if (queryEvent.type === 'updated' && queryEvent.action.type === 'success') {\n channel.postMessage({\n type: 'updated',\n queryHash,\n queryKey,\n state,\n })\n }\n\n if (queryEvent.type === 'removed') {\n channel.postMessage({\n type: 'removed',\n queryHash,\n queryKey,\n })\n }\n })\n\n channel.onmessage = (action) => {\n if (!action?.type) {\n return\n }\n\n tx(() => {\n const { type, queryHash, queryKey, state } = action\n\n if (type === 'updated') {\n const query = queryCache.get(queryHash)\n\n if (query) {\n query.setState(state)\n return\n }\n\n queryCache.build(\n queryClient,\n {\n queryKey,\n queryHash,\n },\n state,\n )\n } else if (type === 'removed') {\n const query = queryCache.get(queryHash)\n\n if (query) {\n queryCache.remove(query)\n }\n }\n })\n }\n}\n"],"names":["queryClient","broadcastChannel","transaction","channel","BroadcastChannel","webWorkerSupport","queryCache","getQueryCache","subscribe","queryEvent","query","queryHash","queryKey","state","type","action","postMessage","onmessage","get","setState","build","remove","cb"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.production.js","sources":["../../src/index.ts"],"sourcesContent":["import { BroadcastChannel } from 'broadcast-channel'\nimport type { BroadcastChannelOptions } from 'broadcast-channel'\nimport type { QueryClient } from '@tanstack/query-core'\n\ninterface BroadcastQueryClientOptions {\n queryClient: QueryClient\n broadcastChannel?: string\n options?: BroadcastChannelOptions\n}\n\nexport function broadcastQueryClient({\n queryClient,\n broadcastChannel = 'tanstack-query',\n options,\n}: BroadcastQueryClientOptions) {\n let transaction = false\n const tx = (cb: () => void) => {\n transaction = true\n cb()\n transaction = false\n }\n\n const channel = new BroadcastChannel(broadcastChannel, {\n webWorkerSupport: false,\n ...options,\n })\n\n const queryCache = queryClient.getQueryCache()\n\n queryClient.getQueryCache().subscribe((queryEvent) => {\n if (transaction) {\n return\n }\n\n const {\n query: { queryHash, queryKey, state },\n } = queryEvent\n\n if (queryEvent.type === 'updated' && queryEvent.action.type === 'success') {\n channel.postMessage({\n type: 'updated',\n queryHash,\n queryKey,\n state,\n })\n }\n\n if (queryEvent.type === 'removed') {\n channel.postMessage({\n type: 'removed',\n queryHash,\n queryKey,\n })\n }\n })\n\n channel.onmessage = (action) => {\n if (!action?.type) {\n return\n }\n\n tx(() => {\n const { type, queryHash, queryKey, state } = action\n\n if (type === 'updated') {\n const query = queryCache.get(queryHash)\n\n if (query) {\n query.setState(state)\n return\n }\n\n queryCache.build(\n queryClient,\n {\n queryKey,\n queryHash,\n },\n state,\n )\n } else if (type === 'removed') {\n const query = queryCache.get(queryHash)\n\n if (query) {\n queryCache.remove(query)\n }\n }\n })\n }\n}\n"],"names":["queryClient","broadcastChannel","options","transaction","channel","BroadcastChannel","webWorkerSupport","queryCache","getQueryCache","subscribe","queryEvent","query","queryHash","queryKey","state","type","action","postMessage","onmessage","get","setState","build","remove","cb"],"mappings":"yVAUO,UAA8BA,YACnCA,EACAC,iBAAAA,EAAmB,iBAFgBC,QAGnCA,IAEA,IAAIC,GAAc,EAClB,MAMMC,EAAU,IAAIC,EAAJA,iBAAqBJ,EAAkB,CACrDK,kBAAkB,KACfJ,IAGCK,EAAaP,EAAYQ,gBAE/BR,EAAYQ,gBAAgBC,WAAWC,IACrC,GAAIP,EACF,OAGF,MACEQ,OAAOC,UAAEA,EAAFC,SAAaA,EAAbC,MAAuBA,IAC5BJ,EAEoB,YAApBA,EAAWK,MAAiD,YAA3BL,EAAWM,OAAOD,MACrDX,EAAQa,YAAY,CAClBF,KAAM,UACNH,YACAC,WACAC,UAIoB,YAApBJ,EAAWK,MACbX,EAAQa,YAAY,CAClBF,KAAM,UACNH,YACAC,gBAKNT,EAAQc,UAAaF,IACf,MAACA,GAAAA,EAAQD,OAxCbZ,GAAc,EA4CX,MACD,MAAMY,KAAEA,EAAFH,UAAQA,EAARC,SAAmBA,EAAnBC,MAA6BA,GAAUE,EAE7C,GAAa,YAATD,EAAoB,CACtB,MAAMJ,EAAQJ,EAAWY,IAAIP,GAE7B,GAAID,EAEF,YADAA,EAAMS,SAASN,GAIjBP,EAAWc,MACTrB,EACA,CACEa,WACAD,aAEFE,QAEG,GAAa,YAATC,EAAoB,CAC7B,MAAMJ,EAAQJ,EAAWY,IAAIP,GAEzBD,GACFJ,EAAWe,OAAOX,KAlExBY,GACApB,GAAc"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/query-broadcast-client-experimental",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.34.2",
|
|
4
4
|
"description": "An experimental plugin to for broadcasting the state of your queryClient between browser tabs/windows",
|
|
5
5
|
"author": "tannerlinsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"broadcast-channel": "^4.14.0",
|
|
36
|
-
"@tanstack/query-core": "4.
|
|
36
|
+
"@tanstack/query-core": "4.33.0"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"clean": "rimraf ./build",
|
package/src/index.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { BroadcastChannel } from 'broadcast-channel'
|
|
2
|
+
import type { BroadcastChannelOptions } from 'broadcast-channel'
|
|
2
3
|
import type { QueryClient } from '@tanstack/query-core'
|
|
3
4
|
|
|
4
5
|
interface BroadcastQueryClientOptions {
|
|
5
6
|
queryClient: QueryClient
|
|
6
7
|
broadcastChannel?: string
|
|
8
|
+
options?: BroadcastChannelOptions
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
export function broadcastQueryClient({
|
|
10
12
|
queryClient,
|
|
11
13
|
broadcastChannel = 'tanstack-query',
|
|
14
|
+
options,
|
|
12
15
|
}: BroadcastQueryClientOptions) {
|
|
13
16
|
let transaction = false
|
|
14
17
|
const tx = (cb: () => void) => {
|
|
@@ -19,6 +22,7 @@ export function broadcastQueryClient({
|
|
|
19
22
|
|
|
20
23
|
const channel = new BroadcastChannel(broadcastChannel, {
|
|
21
24
|
webWorkerSupport: false,
|
|
25
|
+
...options,
|
|
22
26
|
})
|
|
23
27
|
|
|
24
28
|
const queryCache = queryClient.getQueryCache()
|
package/build/lib/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAEvD,UAAU,2BAA2B;IACnC,WAAW,EAAE,WAAW,CAAA;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED,wBAAgB,oBAAoB,CAAC,EACnC,WAAW,EACX,gBAAmC,GACpC,EAAE,2BAA2B,QA0E7B"}
|