@tanstack/query-broadcast-client-experimental 5.0.0-beta.18 → 5.0.0-beta.23

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.
@@ -26,7 +26,8 @@ module.exports = __toCommonJS(src_exports);
26
26
  var import_broadcast_channel = require("broadcast-channel");
27
27
  function broadcastQueryClient({
28
28
  queryClient,
29
- broadcastChannel = "tanstack-query"
29
+ broadcastChannel = "tanstack-query",
30
+ options
30
31
  }) {
31
32
  let transaction = false;
32
33
  const tx = (cb) => {
@@ -35,7 +36,8 @@ function broadcastQueryClient({
35
36
  transaction = false;
36
37
  };
37
38
  const channel = new import_broadcast_channel.BroadcastChannel(broadcastChannel, {
38
- webWorkerSupport: false
39
+ webWorkerSupport: false,
40
+ ...options
39
41
  });
40
42
  const queryCache = queryClient.getQueryCache();
41
43
  queryClient.getQueryCache().subscribe((queryEvent) => {
@@ -1 +1 @@
1
- {"version":3,"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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAiC;AAQ1B,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA,mBAAmB;AACrB,GAAgC;AAC9B,MAAI,cAAc;AAClB,QAAM,KAAK,CAAC,OAAmB;AAC7B,kBAAc;AACd,OAAG;AACH,kBAAc;AAAA,EAChB;AAEA,QAAM,UAAU,IAAI,0CAAiB,kBAAkB;AAAA,IACrD,kBAAkB;AAAA,EACpB,CAAC;AAED,QAAM,aAAa,YAAY,cAAc;AAE7C,cAAY,cAAc,EAAE,UAAU,CAAC,eAAe;AACpD,QAAI,aAAa;AACf;AAAA,IACF;AAEA,UAAM;AAAA,MACJ,OAAO,EAAE,WAAW,UAAU,MAAM;AAAA,IACtC,IAAI;AAEJ,QAAI,WAAW,SAAS,aAAa,WAAW,OAAO,SAAS,WAAW;AACzE,cAAQ,YAAY;AAAA,QAClB,MAAM;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAEA,QAAI,WAAW,SAAS,WAAW;AACjC,cAAQ,YAAY;AAAA,QAClB,MAAM;AAAA,QACN;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AAED,UAAQ,YAAY,CAAC,WAAW;AAC9B,QAAI,EAAC,iCAAQ,OAAM;AACjB;AAAA,IACF;AAEA,OAAG,MAAM;AACP,YAAM,EAAE,MAAM,WAAW,UAAU,MAAM,IAAI;AAE7C,UAAI,SAAS,WAAW;AACtB,cAAM,QAAQ,WAAW,IAAI,SAAS;AAEtC,YAAI,OAAO;AACT,gBAAM,SAAS,KAAK;AACpB;AAAA,QACF;AAEA,mBAAW;AAAA,UACT;AAAA,UACA;AAAA,YACE;AAAA,YACA;AAAA,UACF;AAAA,UACA;AAAA,QACF;AAAA,MACF,WAAW,SAAS,WAAW;AAC7B,cAAM,QAAQ,WAAW,IAAI,SAAS;AAEtC,YAAI,OAAO;AACT,qBAAW,OAAO,KAAK;AAAA,QACzB;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACF;","names":[]}
1
+ {"version":3,"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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAiC;AAU1B,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA,mBAAmB;AAAA,EACnB;AACF,GAAgC;AAC9B,MAAI,cAAc;AAClB,QAAM,KAAK,CAAC,OAAmB;AAC7B,kBAAc;AACd,OAAG;AACH,kBAAc;AAAA,EAChB;AAEA,QAAM,UAAU,IAAI,0CAAiB,kBAAkB;AAAA,IACrD,kBAAkB;AAAA,IAClB,GAAG;AAAA,EACL,CAAC;AAED,QAAM,aAAa,YAAY,cAAc;AAE7C,cAAY,cAAc,EAAE,UAAU,CAAC,eAAe;AACpD,QAAI,aAAa;AACf;AAAA,IACF;AAEA,UAAM;AAAA,MACJ,OAAO,EAAE,WAAW,UAAU,MAAM;AAAA,IACtC,IAAI;AAEJ,QAAI,WAAW,SAAS,aAAa,WAAW,OAAO,SAAS,WAAW;AACzE,cAAQ,YAAY;AAAA,QAClB,MAAM;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAEA,QAAI,WAAW,SAAS,WAAW;AACjC,cAAQ,YAAY;AAAA,QAClB,MAAM;AAAA,QACN;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AAED,UAAQ,YAAY,CAAC,WAAW;AAC9B,QAAI,EAAC,iCAAQ,OAAM;AACjB;AAAA,IACF;AAEA,OAAG,MAAM;AACP,YAAM,EAAE,MAAM,WAAW,UAAU,MAAM,IAAI;AAE7C,UAAI,SAAS,WAAW;AACtB,cAAM,QAAQ,WAAW,IAAI,SAAS;AAEtC,YAAI,OAAO;AACT,gBAAM,SAAS,KAAK;AACpB;AAAA,QACF;AAEA,mBAAW;AAAA,UACT;AAAA,UACA;AAAA,YACE;AAAA,YACA;AAAA,UACF;AAAA,UACA;AAAA,QACF;AAAA,MACF,WAAW,SAAS,WAAW;AAC7B,cAAM,QAAQ,WAAW,IAAI,SAAS;AAEtC,YAAI,OAAO;AACT,qBAAW,OAAO,KAAK;AAAA,QACzB;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACF;","names":[]}
@@ -1,9 +1,11 @@
1
+ import { BroadcastChannelOptions } from 'broadcast-channel';
1
2
  import { QueryClient } from '@tanstack/query-core';
2
3
 
3
4
  interface BroadcastQueryClientOptions {
4
5
  queryClient: QueryClient;
5
6
  broadcastChannel?: string;
7
+ options?: BroadcastChannelOptions;
6
8
  }
7
- declare function broadcastQueryClient({ queryClient, broadcastChannel, }: BroadcastQueryClientOptions): void;
9
+ declare function broadcastQueryClient({ queryClient, broadcastChannel, options, }: BroadcastQueryClientOptions): void;
8
10
 
9
11
  export { broadcastQueryClient };
@@ -1,9 +1,11 @@
1
+ import { BroadcastChannelOptions } from 'broadcast-channel';
1
2
  import { QueryClient } from '@tanstack/query-core';
2
3
 
3
4
  interface BroadcastQueryClientOptions {
4
5
  queryClient: QueryClient;
5
6
  broadcastChannel?: string;
7
+ options?: BroadcastChannelOptions;
6
8
  }
7
- declare function broadcastQueryClient({ queryClient, broadcastChannel, }: BroadcastQueryClientOptions): void;
9
+ declare function broadcastQueryClient({ queryClient, broadcastChannel, options, }: BroadcastQueryClientOptions): void;
8
10
 
9
11
  export { broadcastQueryClient };
@@ -2,7 +2,8 @@
2
2
  import { BroadcastChannel } from "broadcast-channel";
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
  const tx = (cb) => {
@@ -11,7 +12,8 @@ function broadcastQueryClient({
11
12
  transaction = false;
12
13
  };
13
14
  const channel = new BroadcastChannel(broadcastChannel, {
14
- webWorkerSupport: false
15
+ webWorkerSupport: false,
16
+ ...options
15
17
  });
16
18
  const queryCache = queryClient.getQueryCache();
17
19
  queryClient.getQueryCache().subscribe((queryEvent) => {
@@ -1 +1 @@
1
- {"version":3,"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"],"mappings":";AAAA,SAAS,wBAAwB;AAQ1B,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA,mBAAmB;AACrB,GAAgC;AAC9B,MAAI,cAAc;AAClB,QAAM,KAAK,CAAC,OAAmB;AAC7B,kBAAc;AACd,OAAG;AACH,kBAAc;AAAA,EAChB;AAEA,QAAM,UAAU,IAAI,iBAAiB,kBAAkB;AAAA,IACrD,kBAAkB;AAAA,EACpB,CAAC;AAED,QAAM,aAAa,YAAY,cAAc;AAE7C,cAAY,cAAc,EAAE,UAAU,CAAC,eAAe;AACpD,QAAI,aAAa;AACf;AAAA,IACF;AAEA,UAAM;AAAA,MACJ,OAAO,EAAE,WAAW,UAAU,MAAM;AAAA,IACtC,IAAI;AAEJ,QAAI,WAAW,SAAS,aAAa,WAAW,OAAO,SAAS,WAAW;AACzE,cAAQ,YAAY;AAAA,QAClB,MAAM;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAEA,QAAI,WAAW,SAAS,WAAW;AACjC,cAAQ,YAAY;AAAA,QAClB,MAAM;AAAA,QACN;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AAED,UAAQ,YAAY,CAAC,WAAW;AAC9B,QAAI,EAAC,iCAAQ,OAAM;AACjB;AAAA,IACF;AAEA,OAAG,MAAM;AACP,YAAM,EAAE,MAAM,WAAW,UAAU,MAAM,IAAI;AAE7C,UAAI,SAAS,WAAW;AACtB,cAAM,QAAQ,WAAW,IAAI,SAAS;AAEtC,YAAI,OAAO;AACT,gBAAM,SAAS,KAAK;AACpB;AAAA,QACF;AAEA,mBAAW;AAAA,UACT;AAAA,UACA;AAAA,YACE;AAAA,YACA;AAAA,UACF;AAAA,UACA;AAAA,QACF;AAAA,MACF,WAAW,SAAS,WAAW;AAC7B,cAAM,QAAQ,WAAW,IAAI,SAAS;AAEtC,YAAI,OAAO;AACT,qBAAW,OAAO,KAAK;AAAA,QACzB;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACF;","names":[]}
1
+ {"version":3,"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"],"mappings":";AAAA,SAAS,wBAAwB;AAU1B,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA,mBAAmB;AAAA,EACnB;AACF,GAAgC;AAC9B,MAAI,cAAc;AAClB,QAAM,KAAK,CAAC,OAAmB;AAC7B,kBAAc;AACd,OAAG;AACH,kBAAc;AAAA,EAChB;AAEA,QAAM,UAAU,IAAI,iBAAiB,kBAAkB;AAAA,IACrD,kBAAkB;AAAA,IAClB,GAAG;AAAA,EACL,CAAC;AAED,QAAM,aAAa,YAAY,cAAc;AAE7C,cAAY,cAAc,EAAE,UAAU,CAAC,eAAe;AACpD,QAAI,aAAa;AACf;AAAA,IACF;AAEA,UAAM;AAAA,MACJ,OAAO,EAAE,WAAW,UAAU,MAAM;AAAA,IACtC,IAAI;AAEJ,QAAI,WAAW,SAAS,aAAa,WAAW,OAAO,SAAS,WAAW;AACzE,cAAQ,YAAY;AAAA,QAClB,MAAM;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAEA,QAAI,WAAW,SAAS,WAAW;AACjC,cAAQ,YAAY;AAAA,QAClB,MAAM;AAAA,QACN;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AAED,UAAQ,YAAY,CAAC,WAAW;AAC9B,QAAI,EAAC,iCAAQ,OAAM;AACjB;AAAA,IACF;AAEA,OAAG,MAAM;AACP,YAAM,EAAE,MAAM,WAAW,UAAU,MAAM,IAAI;AAE7C,UAAI,SAAS,WAAW;AACtB,cAAM,QAAQ,WAAW,IAAI,SAAS;AAEtC,YAAI,OAAO;AACT,gBAAM,SAAS,KAAK;AACpB;AAAA,QACF;AAEA,mBAAW;AAAA,UACT;AAAA,UACA;AAAA,YACE;AAAA,YACA;AAAA,UACF;AAAA,UACA;AAAA,QACF;AAAA,MACF,WAAW,SAAS,WAAW;AAC7B,cAAM,QAAQ,WAAW,IAAI,SAAS;AAEtC,YAAI,OAAO;AACT,qBAAW,OAAO,KAAK;AAAA,QACzB;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACF;","names":[]}
@@ -26,7 +26,8 @@ module.exports = __toCommonJS(src_exports);
26
26
  var import_broadcast_channel = require("broadcast-channel");
27
27
  function broadcastQueryClient({
28
28
  queryClient,
29
- broadcastChannel = "tanstack-query"
29
+ broadcastChannel = "tanstack-query",
30
+ options
30
31
  }) {
31
32
  let transaction = false;
32
33
  const tx = (cb) => {
@@ -35,7 +36,8 @@ function broadcastQueryClient({
35
36
  transaction = false;
36
37
  };
37
38
  const channel = new import_broadcast_channel.BroadcastChannel(broadcastChannel, {
38
- webWorkerSupport: false
39
+ webWorkerSupport: false,
40
+ ...options
39
41
  });
40
42
  const queryCache = queryClient.getQueryCache();
41
43
  queryClient.getQueryCache().subscribe((queryEvent) => {
@@ -1 +1 @@
1
- {"version":3,"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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAiC;AAQ1B,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA,mBAAmB;AACrB,GAAgC;AAC9B,MAAI,cAAc;AAClB,QAAM,KAAK,CAAC,OAAmB;AAC7B,kBAAc;AACd,OAAG;AACH,kBAAc;AAAA,EAChB;AAEA,QAAM,UAAU,IAAI,0CAAiB,kBAAkB;AAAA,IACrD,kBAAkB;AAAA,EACpB,CAAC;AAED,QAAM,aAAa,YAAY,cAAc;AAE7C,cAAY,cAAc,EAAE,UAAU,CAAC,eAAe;AACpD,QAAI,aAAa;AACf;AAAA,IACF;AAEA,UAAM;AAAA,MACJ,OAAO,EAAE,WAAW,UAAU,MAAM;AAAA,IACtC,IAAI;AAEJ,QAAI,WAAW,SAAS,aAAa,WAAW,OAAO,SAAS,WAAW;AACzE,cAAQ,YAAY;AAAA,QAClB,MAAM;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAEA,QAAI,WAAW,SAAS,WAAW;AACjC,cAAQ,YAAY;AAAA,QAClB,MAAM;AAAA,QACN;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AAED,UAAQ,YAAY,CAAC,WAAW;AAC9B,QAAI,CAAC,QAAQ,MAAM;AACjB;AAAA,IACF;AAEA,OAAG,MAAM;AACP,YAAM,EAAE,MAAM,WAAW,UAAU,MAAM,IAAI;AAE7C,UAAI,SAAS,WAAW;AACtB,cAAM,QAAQ,WAAW,IAAI,SAAS;AAEtC,YAAI,OAAO;AACT,gBAAM,SAAS,KAAK;AACpB;AAAA,QACF;AAEA,mBAAW;AAAA,UACT;AAAA,UACA;AAAA,YACE;AAAA,YACA;AAAA,UACF;AAAA,UACA;AAAA,QACF;AAAA,MACF,WAAW,SAAS,WAAW;AAC7B,cAAM,QAAQ,WAAW,IAAI,SAAS;AAEtC,YAAI,OAAO;AACT,qBAAW,OAAO,KAAK;AAAA,QACzB;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACF;","names":[]}
1
+ {"version":3,"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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAiC;AAU1B,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA,mBAAmB;AAAA,EACnB;AACF,GAAgC;AAC9B,MAAI,cAAc;AAClB,QAAM,KAAK,CAAC,OAAmB;AAC7B,kBAAc;AACd,OAAG;AACH,kBAAc;AAAA,EAChB;AAEA,QAAM,UAAU,IAAI,0CAAiB,kBAAkB;AAAA,IACrD,kBAAkB;AAAA,IAClB,GAAG;AAAA,EACL,CAAC;AAED,QAAM,aAAa,YAAY,cAAc;AAE7C,cAAY,cAAc,EAAE,UAAU,CAAC,eAAe;AACpD,QAAI,aAAa;AACf;AAAA,IACF;AAEA,UAAM;AAAA,MACJ,OAAO,EAAE,WAAW,UAAU,MAAM;AAAA,IACtC,IAAI;AAEJ,QAAI,WAAW,SAAS,aAAa,WAAW,OAAO,SAAS,WAAW;AACzE,cAAQ,YAAY;AAAA,QAClB,MAAM;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAEA,QAAI,WAAW,SAAS,WAAW;AACjC,cAAQ,YAAY;AAAA,QAClB,MAAM;AAAA,QACN;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AAED,UAAQ,YAAY,CAAC,WAAW;AAC9B,QAAI,CAAC,QAAQ,MAAM;AACjB;AAAA,IACF;AAEA,OAAG,MAAM;AACP,YAAM,EAAE,MAAM,WAAW,UAAU,MAAM,IAAI;AAE7C,UAAI,SAAS,WAAW;AACtB,cAAM,QAAQ,WAAW,IAAI,SAAS;AAEtC,YAAI,OAAO;AACT,gBAAM,SAAS,KAAK;AACpB;AAAA,QACF;AAEA,mBAAW;AAAA,UACT;AAAA,UACA;AAAA,YACE;AAAA,YACA;AAAA,UACF;AAAA,UACA;AAAA,QACF;AAAA,MACF,WAAW,SAAS,WAAW;AAC7B,cAAM,QAAQ,WAAW,IAAI,SAAS;AAEtC,YAAI,OAAO;AACT,qBAAW,OAAO,KAAK;AAAA,QACzB;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACF;","names":[]}
@@ -1,9 +1,11 @@
1
+ import { BroadcastChannelOptions } from 'broadcast-channel';
1
2
  import { QueryClient } from '@tanstack/query-core';
2
3
 
3
4
  interface BroadcastQueryClientOptions {
4
5
  queryClient: QueryClient;
5
6
  broadcastChannel?: string;
7
+ options?: BroadcastChannelOptions;
6
8
  }
7
- declare function broadcastQueryClient({ queryClient, broadcastChannel, }: BroadcastQueryClientOptions): void;
9
+ declare function broadcastQueryClient({ queryClient, broadcastChannel, options, }: BroadcastQueryClientOptions): void;
8
10
 
9
11
  export { broadcastQueryClient };
@@ -1,9 +1,11 @@
1
+ import { BroadcastChannelOptions } from 'broadcast-channel';
1
2
  import { QueryClient } from '@tanstack/query-core';
2
3
 
3
4
  interface BroadcastQueryClientOptions {
4
5
  queryClient: QueryClient;
5
6
  broadcastChannel?: string;
7
+ options?: BroadcastChannelOptions;
6
8
  }
7
- declare function broadcastQueryClient({ queryClient, broadcastChannel, }: BroadcastQueryClientOptions): void;
9
+ declare function broadcastQueryClient({ queryClient, broadcastChannel, options, }: BroadcastQueryClientOptions): void;
8
10
 
9
11
  export { broadcastQueryClient };
@@ -2,7 +2,8 @@
2
2
  import { BroadcastChannel } from "broadcast-channel";
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
  const tx = (cb) => {
@@ -11,7 +12,8 @@ function broadcastQueryClient({
11
12
  transaction = false;
12
13
  };
13
14
  const channel = new BroadcastChannel(broadcastChannel, {
14
- webWorkerSupport: false
15
+ webWorkerSupport: false,
16
+ ...options
15
17
  });
16
18
  const queryCache = queryClient.getQueryCache();
17
19
  queryClient.getQueryCache().subscribe((queryEvent) => {
@@ -1 +1 @@
1
- {"version":3,"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"],"mappings":";AAAA,SAAS,wBAAwB;AAQ1B,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA,mBAAmB;AACrB,GAAgC;AAC9B,MAAI,cAAc;AAClB,QAAM,KAAK,CAAC,OAAmB;AAC7B,kBAAc;AACd,OAAG;AACH,kBAAc;AAAA,EAChB;AAEA,QAAM,UAAU,IAAI,iBAAiB,kBAAkB;AAAA,IACrD,kBAAkB;AAAA,EACpB,CAAC;AAED,QAAM,aAAa,YAAY,cAAc;AAE7C,cAAY,cAAc,EAAE,UAAU,CAAC,eAAe;AACpD,QAAI,aAAa;AACf;AAAA,IACF;AAEA,UAAM;AAAA,MACJ,OAAO,EAAE,WAAW,UAAU,MAAM;AAAA,IACtC,IAAI;AAEJ,QAAI,WAAW,SAAS,aAAa,WAAW,OAAO,SAAS,WAAW;AACzE,cAAQ,YAAY;AAAA,QAClB,MAAM;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAEA,QAAI,WAAW,SAAS,WAAW;AACjC,cAAQ,YAAY;AAAA,QAClB,MAAM;AAAA,QACN;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AAED,UAAQ,YAAY,CAAC,WAAW;AAC9B,QAAI,CAAC,QAAQ,MAAM;AACjB;AAAA,IACF;AAEA,OAAG,MAAM;AACP,YAAM,EAAE,MAAM,WAAW,UAAU,MAAM,IAAI;AAE7C,UAAI,SAAS,WAAW;AACtB,cAAM,QAAQ,WAAW,IAAI,SAAS;AAEtC,YAAI,OAAO;AACT,gBAAM,SAAS,KAAK;AACpB;AAAA,QACF;AAEA,mBAAW;AAAA,UACT;AAAA,UACA;AAAA,YACE;AAAA,YACA;AAAA,UACF;AAAA,UACA;AAAA,QACF;AAAA,MACF,WAAW,SAAS,WAAW;AAC7B,cAAM,QAAQ,WAAW,IAAI,SAAS;AAEtC,YAAI,OAAO;AACT,qBAAW,OAAO,KAAK;AAAA,QACzB;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACF;","names":[]}
1
+ {"version":3,"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"],"mappings":";AAAA,SAAS,wBAAwB;AAU1B,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA,mBAAmB;AAAA,EACnB;AACF,GAAgC;AAC9B,MAAI,cAAc;AAClB,QAAM,KAAK,CAAC,OAAmB;AAC7B,kBAAc;AACd,OAAG;AACH,kBAAc;AAAA,EAChB;AAEA,QAAM,UAAU,IAAI,iBAAiB,kBAAkB;AAAA,IACrD,kBAAkB;AAAA,IAClB,GAAG;AAAA,EACL,CAAC;AAED,QAAM,aAAa,YAAY,cAAc;AAE7C,cAAY,cAAc,EAAE,UAAU,CAAC,eAAe;AACpD,QAAI,aAAa;AACf;AAAA,IACF;AAEA,UAAM;AAAA,MACJ,OAAO,EAAE,WAAW,UAAU,MAAM;AAAA,IACtC,IAAI;AAEJ,QAAI,WAAW,SAAS,aAAa,WAAW,OAAO,SAAS,WAAW;AACzE,cAAQ,YAAY;AAAA,QAClB,MAAM;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAEA,QAAI,WAAW,SAAS,WAAW;AACjC,cAAQ,YAAY;AAAA,QAClB,MAAM;AAAA,QACN;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AAED,UAAQ,YAAY,CAAC,WAAW;AAC9B,QAAI,CAAC,QAAQ,MAAM;AACjB;AAAA,IACF;AAEA,OAAG,MAAM;AACP,YAAM,EAAE,MAAM,WAAW,UAAU,MAAM,IAAI;AAE7C,UAAI,SAAS,WAAW;AACtB,cAAM,QAAQ,WAAW,IAAI,SAAS;AAEtC,YAAI,OAAO;AACT,gBAAM,SAAS,KAAK;AACpB;AAAA,QACF;AAEA,mBAAW;AAAA,UACT;AAAA,UACA;AAAA,YACE;AAAA,YACA;AAAA,UACF;AAAA,UACA;AAAA,QACF;AAAA,MACF,WAAW,SAAS,WAAW;AAC7B,cAAM,QAAQ,WAAW,IAAI,SAAS;AAEtC,YAAI,OAAO;AACT,qBAAW,OAAO,KAAK;AAAA,QACzB;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/query-broadcast-client-experimental",
3
- "version": "5.0.0-beta.18",
3
+ "version": "5.0.0-beta.23",
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",
@@ -38,7 +38,7 @@
38
38
  ],
39
39
  "dependencies": {
40
40
  "broadcast-channel": "^5.1.0",
41
- "@tanstack/query-core": "5.0.0-beta.18"
41
+ "@tanstack/query-core": "5.0.0-beta.23"
42
42
  },
43
43
  "scripts": {
44
44
  "clean": "rimraf ./build && rimraf ./coverage",
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()