@tanstack/query-broadcast-client-experimental 4.2.1 → 4.3.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/build/{types/query-broadcast-client-experimental/src → lib}/index.d.ts +0 -0
  2. package/build/{cjs → lib}/index.js +0 -0
  3. package/build/{cjs → lib}/index.js.map +0 -0
  4. package/build/{esm/index.js → lib/index.mjs} +1 -1
  5. package/build/lib/index.mjs.map +1 -0
  6. package/build/umd/index.development.js +1 -1
  7. package/build/umd/index.production.js +1 -1
  8. package/package.json +16 -6
  9. package/build/esm/index.js.map +0 -1
  10. package/build/stats-html.html +0 -2689
  11. package/build/stats.json +0 -60
  12. package/build/types/query-core/src/focusManager.d.ts +0 -16
  13. package/build/types/query-core/src/hydration.d.ts +0 -34
  14. package/build/types/query-core/src/index.d.ts +0 -20
  15. package/build/types/query-core/src/infiniteQueryBehavior.d.ts +0 -15
  16. package/build/types/query-core/src/infiniteQueryObserver.d.ts +0 -18
  17. package/build/types/query-core/src/logger.d.ts +0 -8
  18. package/build/types/query-core/src/mutation.d.ts +0 -70
  19. package/build/types/query-core/src/mutationCache.d.ts +0 -57
  20. package/build/types/query-core/src/mutationObserver.d.ts +0 -23
  21. package/build/types/query-core/src/notifyManager.d.ts +0 -18
  22. package/build/types/query-core/src/onlineManager.d.ts +0 -16
  23. package/build/types/query-core/src/queriesObserver.d.ts +0 -23
  24. package/build/types/query-core/src/query.d.ts +0 -119
  25. package/build/types/query-core/src/queryCache.d.ts +0 -64
  26. package/build/types/query-core/src/queryClient.d.ts +0 -65
  27. package/build/types/query-core/src/queryObserver.d.ts +0 -61
  28. package/build/types/query-core/src/removable.d.ts +0 -9
  29. package/build/types/query-core/src/retryer.d.ts +0 -33
  30. package/build/types/query-core/src/subscribable.d.ts +0 -10
  31. package/build/types/query-core/src/types.d.ts +0 -419
  32. package/build/types/query-core/src/utils.d.ts +0 -99
File without changes
File without changes
@@ -94,4 +94,4 @@ function broadcastQueryClient({
94
94
  }
95
95
 
96
96
  export { broadcastQueryClient };
97
- //# sourceMappingURL=index.js.map
97
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +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":";;;;;;;;;;;;AAQO,SAASA,oBA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,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,CACEtB,WADF,EAEE;UACEc,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;;;;"}
@@ -11,7 +11,7 @@
11
11
  (function (global, factory) {
12
12
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('broadcast-channel')) :
13
13
  typeof define === 'function' && define.amd ? define(['exports', 'broadcast-channel'], factory) :
14
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.QueryBroadcastClient = {}, global.broadcastChannel));
14
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.QueryBroadcastClient = {}, global.BroadcastChannel));
15
15
  })(this, (function (exports, broadcastChannel) { 'use strict';
16
16
 
17
17
  function broadcastQueryClient({
@@ -8,5 +8,5 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- !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 r=!1;const a=new t.BroadcastChannel(s,{webWorkerSupport:!1}),n=e.getQueryCache();e.getQueryCache().subscribe((e=>{if(r)return;const{query:{queryHash:t,queryKey:s,state:n}}=e;"updated"===e.type&&"success"===e.action.type&&a.postMessage({type:"updated",queryHash:t,queryKey:s,state:n}),"removed"===e.type&&a.postMessage({type:"removed",queryHash:t,queryKey:s})})),a.onmessage=t=>{null!=t&&t.type&&(r=!0,(()=>{const{type:s,queryHash:r,queryKey:a,state:o}=t;if("updated"===s){const t=n.get(r);if(t)return void t.setState(o);n.build(e,{queryKey:a,queryHash:r},o)}else if("removed"===s){const e=n.get(r);e&&n.remove(e)}})(),r=!1)}},Object.defineProperty(e,"__esModule",{value:!0})}));
11
+ !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 r=!1;const a=new t.BroadcastChannel(s,{webWorkerSupport:!1}),n=e.getQueryCache();e.getQueryCache().subscribe((e=>{if(r)return;const{query:{queryHash:t,queryKey:s,state:n}}=e;"updated"===e.type&&"success"===e.action.type&&a.postMessage({type:"updated",queryHash:t,queryKey:s,state:n}),"removed"===e.type&&a.postMessage({type:"removed",queryHash:t,queryKey:s})})),a.onmessage=t=>{null!=t&&t.type&&(r=!0,(()=>{const{type:s,queryHash:r,queryKey:a,state:o}=t;if("updated"===s){const t=n.get(r);if(t)return void t.setState(o);n.build(e,{queryKey:a,queryHash:r},o)}else if("removed"===s){const e=n.get(r);e&&n.remove(e)}})(),r=!1)}},Object.defineProperty(e,"__esModule",{value:!0})}));
12
12
  //# sourceMappingURL=index.production.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/query-broadcast-client-experimental",
3
- "version": "4.2.1",
3
+ "version": "4.3.0-beta.0",
4
4
  "description": "TODO",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -10,19 +10,29 @@
10
10
  "type": "github",
11
11
  "url": "https://github.com/sponsors/tannerlinsley"
12
12
  },
13
- "module": "build/esm/index.js",
14
- "main": "build/cjs/index.js",
15
- "browser": "build/umd/index.production.js",
16
- "types": "build/types/query-broadcast-client-experimental/src/index.d.ts",
13
+ "types": "build/lib/index.d.ts",
14
+ "module": "build/lib/index.mjs",
15
+ "main": "build/lib/index.js",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./build/lib/index.d.ts",
19
+ "import": "./build/lib/index.mjs",
20
+ "default": "./build/lib/index.js"
21
+ },
22
+ "./package.json": "./package.json"
23
+ },
17
24
  "files": [
18
- "build/*",
25
+ "build/lib/*",
26
+ "build/umd/*",
19
27
  "src"
20
28
  ],
21
29
  "scripts": {
30
+ "clean": "rm -rf ./build",
22
31
  "test:eslint": "../../node_modules/.bin/eslint --ext .ts,.tsx ./src",
23
32
  "compile": "../../node_modules/.bin/tsc -p tsconfig.json --noEmit --emitDeclarationOnly false"
24
33
  },
25
34
  "dependencies": {
35
+ "@tanstack/query-core": "4.3.0-beta.0",
26
36
  "broadcast-channel": "^4.14.0"
27
37
  }
28
38
  }
@@ -1 +0,0 @@
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":";;;;;;;;;;;;AAQO,SAASA,oBAAT,CAA8B;EACnCC,WADmC;AAEnCC,EAAAA,gBAAgB,GAAG,gBAAA;AAFgB,CAA9B,EAGyB;EAC9B,IAAIC,WAAW,GAAG,KAAlB,CAAA;;EACA,MAAMC,EAAE,GAAIC,EAAD,IAAoB;AAC7BF,IAAAA,WAAW,GAAG,IAAd,CAAA;IACAE,EAAE,EAA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