@tanstack/query-broadcast-client-experimental 4.0.8 → 4.2.1
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/cjs/{packages/query-broadcast-client-experimental/src/index.js → index.js} +1 -1
- package/build/cjs/index.js.map +1 -0
- package/build/esm/index.js +2 -1011
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats.json +13 -380
- package/build/types/query-core/src/mutationCache.d.ts +6 -1
- package/build/types/query-core/src/queryCache.d.ts +6 -1
- package/build/types/query-core/src/types.d.ts +10 -8
- package/build/umd/index.development.js +6 -1017
- 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 +3 -3
- package/build/cjs/node_modules/broadcast-channel/dist/es/broadcast-channel.js +0 -260
- package/build/cjs/node_modules/broadcast-channel/dist/es/broadcast-channel.js.map +0 -1
- package/build/cjs/node_modules/broadcast-channel/dist/es/method-chooser.js +0 -83
- package/build/cjs/node_modules/broadcast-channel/dist/es/method-chooser.js.map +0 -1
- package/build/cjs/node_modules/broadcast-channel/dist/es/methods/indexed-db.js +0 -325
- package/build/cjs/node_modules/broadcast-channel/dist/es/methods/indexed-db.js.map +0 -1
- package/build/cjs/node_modules/broadcast-channel/dist/es/methods/localstorage.js +0 -193
- package/build/cjs/node_modules/broadcast-channel/dist/es/methods/localstorage.js.map +0 -1
- package/build/cjs/node_modules/broadcast-channel/dist/es/methods/native.js +0 -88
- package/build/cjs/node_modules/broadcast-channel/dist/es/methods/native.js.map +0 -1
- package/build/cjs/node_modules/broadcast-channel/dist/es/methods/simulate.js +0 -77
- package/build/cjs/node_modules/broadcast-channel/dist/es/methods/simulate.js.map +0 -1
- package/build/cjs/node_modules/broadcast-channel/dist/es/options.js +0 -41
- package/build/cjs/node_modules/broadcast-channel/dist/es/options.js.map +0 -1
- package/build/cjs/node_modules/broadcast-channel/dist/es/util.js +0 -77
- package/build/cjs/node_modules/broadcast-channel/dist/es/util.js.map +0 -1
- package/build/cjs/node_modules/oblivious-set/dist/es/index.js +0 -83
- package/build/cjs/node_modules/oblivious-set/dist/es/index.js.map +0 -1
- package/build/cjs/packages/query-broadcast-client-experimental/src/index.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"localstorage.js","sources":["../../../../../../../../../node_modules/broadcast-channel/dist/es/methods/localstorage.js"],"sourcesContent":["/**\n * A localStorage-only method which uses localstorage and its 'storage'-event\n * This does not work inside of webworkers because they have no access to locastorage\n * This is basically implemented to support IE9 or your grandmothers toaster.\n * @link https://caniuse.com/#feat=namevalue-storage\n * @link https://caniuse.com/#feat=indexeddb\n */\nimport { ObliviousSet } from 'oblivious-set';\nimport { fillOptionsWithDefaults } from '../options';\nimport { sleep, randomToken, microSeconds as micro, isNode } from '../util';\nexport var microSeconds = micro;\nvar KEY_PREFIX = 'pubkey.broadcastChannel-';\nexport var type = 'localstorage';\n/**\n * copied from crosstab\n * @link https://github.com/tejacques/crosstab/blob/master/src/crosstab.js#L32\n */\n\nexport function getLocalStorage() {\n var localStorage;\n if (typeof window === 'undefined') return null;\n\n try {\n localStorage = window.localStorage;\n localStorage = window['ie8-eventlistener/storage'] || window.localStorage;\n } catch (e) {// New versions of Firefox throw a Security exception\n // if cookies are disabled. See\n // https://bugzilla.mozilla.org/show_bug.cgi?id=1028153\n }\n\n return localStorage;\n}\nexport function storageKey(channelName) {\n return KEY_PREFIX + channelName;\n}\n/**\n* writes the new message to the storage\n* and fires the storage-event so other readers can find it\n*/\n\nexport function postMessage(channelState, messageJson) {\n return new Promise(function (res) {\n sleep().then(function () {\n var key = storageKey(channelState.channelName);\n var writeObj = {\n token: randomToken(),\n time: new Date().getTime(),\n data: messageJson,\n uuid: channelState.uuid\n };\n var value = JSON.stringify(writeObj);\n getLocalStorage().setItem(key, value);\n /**\n * StorageEvent does not fire the 'storage' event\n * in the window that changes the state of the local storage.\n * So we fire it manually\n */\n\n var ev = document.createEvent('Event');\n ev.initEvent('storage', true, true);\n ev.key = key;\n ev.newValue = value;\n window.dispatchEvent(ev);\n res();\n });\n });\n}\nexport function addStorageEventListener(channelName, fn) {\n var key = storageKey(channelName);\n\n var listener = function listener(ev) {\n if (ev.key === key) {\n fn(JSON.parse(ev.newValue));\n }\n };\n\n window.addEventListener('storage', listener);\n return listener;\n}\nexport function removeStorageEventListener(listener) {\n window.removeEventListener('storage', listener);\n}\nexport function create(channelName, options) {\n options = fillOptionsWithDefaults(options);\n\n if (!canBeUsed()) {\n throw new Error('BroadcastChannel: localstorage cannot be used');\n }\n\n var uuid = randomToken();\n /**\n * eMIs\n * contains all messages that have been emitted before\n * @type {ObliviousSet}\n */\n\n var eMIs = new ObliviousSet(options.localstorage.removeTimeout);\n var state = {\n channelName: channelName,\n uuid: uuid,\n eMIs: eMIs // emittedMessagesIds\n\n };\n state.listener = addStorageEventListener(channelName, function (msgObj) {\n if (!state.messagesCallback) return; // no listener\n\n if (msgObj.uuid === uuid) return; // own message\n\n if (!msgObj.token || eMIs.has(msgObj.token)) return; // already emitted\n\n if (msgObj.data.time && msgObj.data.time < state.messagesCallbackTime) return; // too old\n\n eMIs.add(msgObj.token);\n state.messagesCallback(msgObj.data);\n });\n return state;\n}\nexport function close(channelState) {\n removeStorageEventListener(channelState.listener);\n}\nexport function onMessage(channelState, fn, time) {\n channelState.messagesCallbackTime = time;\n channelState.messagesCallback = fn;\n}\nexport function canBeUsed() {\n if (isNode) return false;\n var ls = getLocalStorage();\n if (!ls) return false;\n\n try {\n var key = '__broadcastchannel_check';\n ls.setItem(key, 'works');\n ls.removeItem(key);\n } catch (e) {\n // Safari 10 in private mode will not allow write access to local\n // storage and fail with a QuotaExceededError. See\n // https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API#Private_Browsing_Incognito_modes\n return false;\n }\n\n return true;\n}\nexport function averageResponseTime() {\n var defaultTime = 120;\n var userAgent = navigator.userAgent.toLowerCase();\n\n if (userAgent.includes('safari') && !userAgent.includes('chrome')) {\n // safari is much slower so this time is higher\n return defaultTime * 2;\n }\n\n return defaultTime;\n}\nexport default {\n create: create,\n close: close,\n onMessage: onMessage,\n postMessage: postMessage,\n canBeUsed: canBeUsed,\n type: type,\n averageResponseTime: averageResponseTime,\n microSeconds: microSeconds\n};"],"names":["micro","sleep","randomToken","options","fillOptionsWithDefaults","ObliviousSet","isNode"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAIU,IAAC,YAAY,GAAGA,kBAAM;AAChC,IAAI,UAAU,GAAG,0BAA0B,CAAC;AAClC,IAAC,IAAI,GAAG,eAAe;AACjC;AACA;AACA;AACA;AACA;AACO,SAAS,eAAe,GAAG;AAClC,EAAE,IAAI,YAAY,CAAC;AACnB,EAAE,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,OAAO,IAAI,CAAC;AACjD;AACA,EAAE,IAAI;AACN,IAAI,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;AACvC,IAAI,YAAY,GAAG,MAAM,CAAC,2BAA2B,CAAC,IAAI,MAAM,CAAC,YAAY,CAAC;AAC9E,GAAG,CAAC,OAAO,CAAC,EAAE;AACd;AACA;AACA,GAAG;AACH;AACA,EAAE,OAAO,YAAY,CAAC;AACtB,CAAC;AACM,SAAS,UAAU,CAAC,WAAW,EAAE;AACxC,EAAE,OAAO,UAAU,GAAG,WAAW,CAAC;AAClC,CAAC;AACD;AACA;AACA;AACA;AACA;AACO,SAAS,WAAW,CAAC,YAAY,EAAE,WAAW,EAAE;AACvD,EAAE,OAAO,IAAI,OAAO,CAAC,UAAU,GAAG,EAAE;AACpC,IAAIC,UAAK,EAAE,CAAC,IAAI,CAAC,YAAY;AAC7B,MAAM,IAAI,GAAG,GAAG,UAAU,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;AACrD,MAAM,IAAI,QAAQ,GAAG;AACrB,QAAQ,KAAK,EAAEC,gBAAW,EAAE;AAC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,KAAK,EAAE,KAAK;AACd,EAAE,SAAS,EAAE,SAAS;AACtB,EAAE,WAAW,EAAE,WAAW;AAC1B,EAAE,SAAS,EAAE,SAAS;AACtB,EAAE,IAAI,EAAE,IAAI;AACZ,EAAE,mBAAmB,EAAE,mBAAmB;AAC1C,EAAE,YAAY,EAAE,YAAY;AAC5B,CAAC;;;;;;;;;;;;;;;;"}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* query-broadcast-client-experimental
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
var util = require('../util.js');
|
|
16
|
-
|
|
17
|
-
var microSeconds = util.microSeconds;
|
|
18
|
-
var type = 'native';
|
|
19
|
-
function create(channelName) {
|
|
20
|
-
var state = {
|
|
21
|
-
messagesCallback: null,
|
|
22
|
-
bc: new BroadcastChannel(channelName),
|
|
23
|
-
subFns: [] // subscriberFunctions
|
|
24
|
-
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
state.bc.onmessage = function (msg) {
|
|
28
|
-
if (state.messagesCallback) {
|
|
29
|
-
state.messagesCallback(msg.data);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
return state;
|
|
34
|
-
}
|
|
35
|
-
function close(channelState) {
|
|
36
|
-
channelState.bc.close();
|
|
37
|
-
channelState.subFns = [];
|
|
38
|
-
}
|
|
39
|
-
function postMessage(channelState, messageJson) {
|
|
40
|
-
try {
|
|
41
|
-
channelState.bc.postMessage(messageJson, false);
|
|
42
|
-
return Promise.resolve();
|
|
43
|
-
} catch (err) {
|
|
44
|
-
return Promise.reject(err);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function onMessage(channelState, fn) {
|
|
48
|
-
channelState.messagesCallback = fn;
|
|
49
|
-
}
|
|
50
|
-
function canBeUsed() {
|
|
51
|
-
/**
|
|
52
|
-
* in the electron-renderer, isNode will be true even if we are in browser-context
|
|
53
|
-
* so we also check if window is undefined
|
|
54
|
-
*/
|
|
55
|
-
if (util.isNode && typeof window === 'undefined') return false;
|
|
56
|
-
|
|
57
|
-
if (typeof BroadcastChannel === 'function') {
|
|
58
|
-
if (BroadcastChannel._pubkey) {
|
|
59
|
-
throw new Error('BroadcastChannel: Do not overwrite window.BroadcastChannel with this module, this is not a polyfill');
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return true;
|
|
63
|
-
} else return false;
|
|
64
|
-
}
|
|
65
|
-
function averageResponseTime() {
|
|
66
|
-
return 150;
|
|
67
|
-
}
|
|
68
|
-
var NativeMethod = {
|
|
69
|
-
create: create,
|
|
70
|
-
close: close,
|
|
71
|
-
onMessage: onMessage,
|
|
72
|
-
postMessage: postMessage,
|
|
73
|
-
canBeUsed: canBeUsed,
|
|
74
|
-
type: type,
|
|
75
|
-
averageResponseTime: averageResponseTime,
|
|
76
|
-
microSeconds: microSeconds
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
exports.averageResponseTime = averageResponseTime;
|
|
80
|
-
exports.canBeUsed = canBeUsed;
|
|
81
|
-
exports.close = close;
|
|
82
|
-
exports.create = create;
|
|
83
|
-
exports["default"] = NativeMethod;
|
|
84
|
-
exports.microSeconds = microSeconds;
|
|
85
|
-
exports.onMessage = onMessage;
|
|
86
|
-
exports.postMessage = postMessage;
|
|
87
|
-
exports.type = type;
|
|
88
|
-
//# sourceMappingURL=native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"native.js","sources":["../../../../../../../../../node_modules/broadcast-channel/dist/es/methods/native.js"],"sourcesContent":["import { microSeconds as micro, isNode } from '../util';\nexport var microSeconds = micro;\nexport var type = 'native';\nexport function create(channelName) {\n var state = {\n messagesCallback: null,\n bc: new BroadcastChannel(channelName),\n subFns: [] // subscriberFunctions\n\n };\n\n state.bc.onmessage = function (msg) {\n if (state.messagesCallback) {\n state.messagesCallback(msg.data);\n }\n };\n\n return state;\n}\nexport function close(channelState) {\n channelState.bc.close();\n channelState.subFns = [];\n}\nexport function postMessage(channelState, messageJson) {\n try {\n channelState.bc.postMessage(messageJson, false);\n return Promise.resolve();\n } catch (err) {\n return Promise.reject(err);\n }\n}\nexport function onMessage(channelState, fn) {\n channelState.messagesCallback = fn;\n}\nexport function canBeUsed() {\n /**\n * in the electron-renderer, isNode will be true even if we are in browser-context\n * so we also check if window is undefined\n */\n if (isNode && typeof window === 'undefined') return false;\n\n if (typeof BroadcastChannel === 'function') {\n if (BroadcastChannel._pubkey) {\n throw new Error('BroadcastChannel: Do not overwrite window.BroadcastChannel with this module, this is not a polyfill');\n }\n\n return true;\n } else return false;\n}\nexport function averageResponseTime() {\n return 150;\n}\nexport default {\n create: create,\n close: close,\n onMessage: onMessage,\n postMessage: postMessage,\n canBeUsed: canBeUsed,\n type: type,\n averageResponseTime: averageResponseTime,\n microSeconds: microSeconds\n};"],"names":["micro","isNode"],"mappings":";;;;;;;;;;;;;;;;AACU,IAAC,YAAY,GAAGA,kBAAM;AACtB,IAAC,IAAI,GAAG,SAAS;AACpB,SAAS,MAAM,CAAC,WAAW,EAAE;AACpC,EAAE,IAAI,KAAK,GAAG;AACd,IAAI,gBAAgB,EAAE,IAAI;AAC1B,IAAI,EAAE,EAAE,IAAI,gBAAgB,CAAC,WAAW,CAAC;AACzC,IAAI,MAAM,EAAE,EAAE;AACd;AACA,GAAG,CAAC;AACJ;AACA,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,GAAG,UAAU,GAAG,EAAE;AACtC,IAAI,IAAI,KAAK,CAAC,gBAAgB,EAAE;AAChC,MAAM,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,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;AAC1B,EAAE,SAAS,EAAE,SAAS;AACtB,EAAE,IAAI,EAAE,IAAI;AACZ,EAAE,mBAAmB,EAAE,mBAAmB;AAC1C,EAAE,YAAY,EAAE,YAAY;AAC5B,CAAC;;;;;;;;;;;;"}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* query-broadcast-client-experimental
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
var util = require('../util.js');
|
|
16
|
-
|
|
17
|
-
var microSeconds = util.microSeconds;
|
|
18
|
-
var type = 'simulate';
|
|
19
|
-
var SIMULATE_CHANNELS = new Set();
|
|
20
|
-
function create(channelName) {
|
|
21
|
-
var state = {
|
|
22
|
-
name: channelName,
|
|
23
|
-
messagesCallback: null
|
|
24
|
-
};
|
|
25
|
-
SIMULATE_CHANNELS.add(state);
|
|
26
|
-
return state;
|
|
27
|
-
}
|
|
28
|
-
function close(channelState) {
|
|
29
|
-
SIMULATE_CHANNELS["delete"](channelState);
|
|
30
|
-
}
|
|
31
|
-
function postMessage(channelState, messageJson) {
|
|
32
|
-
return new Promise(function (res) {
|
|
33
|
-
return setTimeout(function () {
|
|
34
|
-
var channelArray = Array.from(SIMULATE_CHANNELS);
|
|
35
|
-
channelArray.filter(function (channel) {
|
|
36
|
-
return channel.name === channelState.name;
|
|
37
|
-
}).filter(function (channel) {
|
|
38
|
-
return channel !== channelState;
|
|
39
|
-
}).filter(function (channel) {
|
|
40
|
-
return !!channel.messagesCallback;
|
|
41
|
-
}).forEach(function (channel) {
|
|
42
|
-
return channel.messagesCallback(messageJson);
|
|
43
|
-
});
|
|
44
|
-
res();
|
|
45
|
-
}, 5);
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
function onMessage(channelState, fn) {
|
|
49
|
-
channelState.messagesCallback = fn;
|
|
50
|
-
}
|
|
51
|
-
function canBeUsed() {
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
function averageResponseTime() {
|
|
55
|
-
return 5;
|
|
56
|
-
}
|
|
57
|
-
var SimulateMethod = {
|
|
58
|
-
create: create,
|
|
59
|
-
close: close,
|
|
60
|
-
onMessage: onMessage,
|
|
61
|
-
postMessage: postMessage,
|
|
62
|
-
canBeUsed: canBeUsed,
|
|
63
|
-
type: type,
|
|
64
|
-
averageResponseTime: averageResponseTime,
|
|
65
|
-
microSeconds: microSeconds
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
exports.averageResponseTime = averageResponseTime;
|
|
69
|
-
exports.canBeUsed = canBeUsed;
|
|
70
|
-
exports.close = close;
|
|
71
|
-
exports.create = create;
|
|
72
|
-
exports["default"] = SimulateMethod;
|
|
73
|
-
exports.microSeconds = microSeconds;
|
|
74
|
-
exports.onMessage = onMessage;
|
|
75
|
-
exports.postMessage = postMessage;
|
|
76
|
-
exports.type = type;
|
|
77
|
-
//# sourceMappingURL=simulate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"simulate.js","sources":["../../../../../../../../../node_modules/broadcast-channel/dist/es/methods/simulate.js"],"sourcesContent":["import { microSeconds as micro } from '../util';\nexport var microSeconds = micro;\nexport var type = 'simulate';\nvar SIMULATE_CHANNELS = new Set();\nexport function create(channelName) {\n var state = {\n name: channelName,\n messagesCallback: null\n };\n SIMULATE_CHANNELS.add(state);\n return state;\n}\nexport function close(channelState) {\n SIMULATE_CHANNELS[\"delete\"](channelState);\n}\nexport function postMessage(channelState, messageJson) {\n return new Promise(function (res) {\n return setTimeout(function () {\n var channelArray = Array.from(SIMULATE_CHANNELS);\n channelArray.filter(function (channel) {\n return channel.name === channelState.name;\n }).filter(function (channel) {\n return channel !== channelState;\n }).filter(function (channel) {\n return !!channel.messagesCallback;\n }).forEach(function (channel) {\n return channel.messagesCallback(messageJson);\n });\n res();\n }, 5);\n });\n}\nexport function onMessage(channelState, fn) {\n channelState.messagesCallback = fn;\n}\nexport function canBeUsed() {\n return true;\n}\nexport function averageResponseTime() {\n return 5;\n}\nexport default {\n create: create,\n close: close,\n onMessage: onMessage,\n postMessage: postMessage,\n canBeUsed: canBeUsed,\n type: type,\n averageResponseTime: averageResponseTime,\n microSeconds: microSeconds\n};"],"names":["micro"],"mappings":";;;;;;;;;;;;;;;;AACU,IAAC,YAAY,GAAGA,kBAAM;AACtB,IAAC,IAAI,GAAG,WAAW;AAC7B,IAAI,iBAAiB,GAAG,IAAI,GAAG,EAAE,CAAC;AAC3B,SAAS,MAAM,CAAC,WAAW,EAAE;AACpC,EAAE,IAAI,KAAK,GAAG;AACd,IAAI,IAAI,EAAE,WAAW;AACrB,IAAI,gBAAgB,EAAE,IAAI;AAC1B,GAAG,CAAC;AACJ,EAAE,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAC/B,EAAE,OAAO,KAAK,CAAC;AACf,CAAC;AACM,SAAS,KAAK,CAAC,YAAY,EAAE;AACpC,EAAE,iBAAiB,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC;AAC5C,CAAC;AACM,SAAS,WAAW,CAAC,YAAY,EAAE,WAAW,EAAE;AACvD,EAAE,OAAO,IAAI,OAAO,CAAC,UAAU,GAAG,EAAE;AACpC,IAAI,OAAO,UAAU,CAAC,YAAY;AAClC,MAAM,IAAI,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;AACvD,MAAM,YAAY,CAAC,MAAM,CAAC,UAAU,OAAO,EAAE;AAC7C,QAAQ,OAAO,OAAO,CAAC,IAAI,KAAK,YAAY,CAAC,IAAI,CAAC;AAClD,OAAO,CAAC,CAAC,MAAM,CAAC,UAAU,OAAO,EAAE;AACnC,QAAQ,OAAO,OAAO,KAAK,YAAY,CAAC;AACxC,OAAO,CAAC,CAAC,MAAM,CAAC,UAAU,OAAO,EAAE;AACnC,QAAQ,OAAO,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC;AAC1C,OAAO,CAAC,CAAC,OAAO,CAAC,UAAU,OAAO,EAAE;AACpC,QAAQ,OAAO,OAAO,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;AACrD,OAAO,CAAC,CAAC;AACT,MAAM,GAAG,EAAE,CAAC;AACZ,KAAK,EAAE,CAAC,CAAC,CAAC;AACV,GAAG,CAAC,CAAC;AACL,CAAC;AACM,SAAS,SAAS,CAAC,YAAY,EAAE,EAAE,EAAE;AAC5C,EAAE,YAAY,CAAC,gBAAgB,GAAG,EAAE,CAAC;AACrC,CAAC;AACM,SAAS,SAAS,GAAG;AAC5B,EAAE,OAAO,IAAI,CAAC;AACd,CAAC;AACM,SAAS,mBAAmB,GAAG;AACtC,EAAE,OAAO,CAAC,CAAC;AACX,CAAC;AACD,qBAAe;AACf,EAAE,MAAM,EAAE,MAAM;AAChB,EAAE,KAAK,EAAE,KAAK;AACd,EAAE,SAAS,EAAE,SAAS;AACtB,EAAE,WAAW,EAAE,WAAW;AAC1B,EAAE,SAAS,EAAE,SAAS;AACtB,EAAE,IAAI,EAAE,IAAI;AACZ,EAAE,mBAAmB,EAAE,mBAAmB;AAC1C,EAAE,YAAY,EAAE,YAAY;AAC5B,CAAC;;;;;;;;;;;;"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* query-broadcast-client-experimental
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
function fillOptionsWithDefaults() {
|
|
16
|
-
var originalOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
17
|
-
var options = JSON.parse(JSON.stringify(originalOptions)); // main
|
|
18
|
-
|
|
19
|
-
if (typeof options.webWorkerSupport === 'undefined') options.webWorkerSupport = true; // indexed-db
|
|
20
|
-
|
|
21
|
-
if (!options.idb) options.idb = {}; // after this time the messages get deleted
|
|
22
|
-
|
|
23
|
-
if (!options.idb.ttl) options.idb.ttl = 1000 * 45;
|
|
24
|
-
if (!options.idb.fallbackInterval) options.idb.fallbackInterval = 150; // handles abrupt db onclose events.
|
|
25
|
-
|
|
26
|
-
if (originalOptions.idb && typeof originalOptions.idb.onclose === 'function') options.idb.onclose = originalOptions.idb.onclose; // localstorage
|
|
27
|
-
|
|
28
|
-
if (!options.localstorage) options.localstorage = {};
|
|
29
|
-
if (!options.localstorage.removeTimeout) options.localstorage.removeTimeout = 1000 * 60; // custom methods
|
|
30
|
-
|
|
31
|
-
if (originalOptions.methods) options.methods = originalOptions.methods; // node
|
|
32
|
-
|
|
33
|
-
if (!options.node) options.node = {};
|
|
34
|
-
if (!options.node.ttl) options.node.ttl = 1000 * 60 * 2; // 2 minutes;
|
|
35
|
-
|
|
36
|
-
if (typeof options.node.useFastPath === 'undefined') options.node.useFastPath = true;
|
|
37
|
-
return options;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
exports.fillOptionsWithDefaults = fillOptionsWithDefaults;
|
|
41
|
-
//# sourceMappingURL=options.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sources":["../../../../../../../../node_modules/broadcast-channel/dist/es/options.js"],"sourcesContent":["export function fillOptionsWithDefaults() {\n var originalOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n var options = JSON.parse(JSON.stringify(originalOptions)); // main\n\n if (typeof options.webWorkerSupport === 'undefined') options.webWorkerSupport = true; // indexed-db\n\n if (!options.idb) options.idb = {}; // after this time the messages get deleted\n\n if (!options.idb.ttl) options.idb.ttl = 1000 * 45;\n if (!options.idb.fallbackInterval) options.idb.fallbackInterval = 150; // handles abrupt db onclose events.\n\n if (originalOptions.idb && typeof originalOptions.idb.onclose === 'function') options.idb.onclose = originalOptions.idb.onclose; // localstorage\n\n if (!options.localstorage) options.localstorage = {};\n if (!options.localstorage.removeTimeout) options.localstorage.removeTimeout = 1000 * 60; // custom methods\n\n if (originalOptions.methods) options.methods = originalOptions.methods; // node\n\n if (!options.node) options.node = {};\n if (!options.node.ttl) options.node.ttl = 1000 * 60 * 2; // 2 minutes;\n\n if (typeof options.node.useFastPath === 'undefined') options.node.useFastPath = true;\n return options;\n}"],"names":[],"mappings":";;;;;;;;;;;;;;AAAO,SAAS,uBAAuB,GAAG;AAC1C,EAAE,IAAI,eAAe,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;AAC/F,EAAE,IAAI,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,CAAC;AAC5D;AACA,EAAE,IAAI,OAAO,OAAO,CAAC,gBAAgB,KAAK,WAAW,EAAE,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;AACvF;AACA,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,GAAG,EAAE,CAAC;AACrC;AACA,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;AACpD,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,GAAG,GAAG,CAAC;AACxE;AACA,EAAE,IAAI,eAAe,CAAC,GAAG,IAAI,OAAO,eAAe,CAAC,GAAG,CAAC,OAAO,KAAK,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO,GAAG,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC;AAClI;AACA,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,YAAY,GAAG,EAAE,CAAC;AACvD,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,aAAa,EAAE,OAAO,CAAC,YAAY,CAAC,aAAa,GAAG,IAAI,GAAG,EAAE,CAAC;AAC1F;AACA,EAAE,IAAI,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,GAAG,eAAe,CAAC,OAAO,CAAC;AACzE;AACA,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,GAAG,EAAE,CAAC;AACvC,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,EAAE,GAAG,CAAC,CAAC;AAC1D;AACA,EAAE,IAAI,OAAO,OAAO,CAAC,IAAI,CAAC,WAAW,KAAK,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;AACvF,EAAE,OAAO,OAAO,CAAC;AACjB;;;;"}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* query-broadcast-client-experimental
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* returns true if the given object is a promise
|
|
17
|
-
*/
|
|
18
|
-
function isPromise(obj) {
|
|
19
|
-
if (obj && typeof obj.then === 'function') {
|
|
20
|
-
return true;
|
|
21
|
-
} else {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function sleep(time) {
|
|
26
|
-
if (!time) time = 0;
|
|
27
|
-
return new Promise(function (res) {
|
|
28
|
-
return setTimeout(res, time);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
function randomInt(min, max) {
|
|
32
|
-
return Math.floor(Math.random() * (max - min + 1) + min);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* https://stackoverflow.com/a/8084248
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
function randomToken() {
|
|
39
|
-
return Math.random().toString(36).substring(2);
|
|
40
|
-
}
|
|
41
|
-
var lastMs = 0;
|
|
42
|
-
var additional = 0;
|
|
43
|
-
/**
|
|
44
|
-
* returns the current time in micro-seconds,
|
|
45
|
-
* WARNING: This is a pseudo-function
|
|
46
|
-
* Performance.now is not reliable in webworkers, so we just make sure to never return the same time.
|
|
47
|
-
* This is enough in browsers, and this function will not be used in nodejs.
|
|
48
|
-
* The main reason for this hack is to ensure that BroadcastChannel behaves equal to production when it is used in fast-running unit tests.
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
function microSeconds() {
|
|
52
|
-
var ms = new Date().getTime();
|
|
53
|
-
|
|
54
|
-
if (ms === lastMs) {
|
|
55
|
-
additional++;
|
|
56
|
-
return ms * 1000 + additional;
|
|
57
|
-
} else {
|
|
58
|
-
lastMs = ms;
|
|
59
|
-
additional = 0;
|
|
60
|
-
return ms * 1000;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* copied from the 'detect-node' npm module
|
|
65
|
-
* We cannot use the module directly because it causes problems with rollup
|
|
66
|
-
* @link https://github.com/iliakan/detect-node/blob/master/index.js
|
|
67
|
-
*/
|
|
68
|
-
|
|
69
|
-
var isNode = Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]';
|
|
70
|
-
|
|
71
|
-
exports.isNode = isNode;
|
|
72
|
-
exports.isPromise = isPromise;
|
|
73
|
-
exports.microSeconds = microSeconds;
|
|
74
|
-
exports.randomInt = randomInt;
|
|
75
|
-
exports.randomToken = randomToken;
|
|
76
|
-
exports.sleep = sleep;
|
|
77
|
-
//# sourceMappingURL=util.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sources":["../../../../../../../../node_modules/broadcast-channel/dist/es/util.js"],"sourcesContent":["/**\n * returns true if the given object is a promise\n */\nexport function isPromise(obj) {\n if (obj && typeof obj.then === 'function') {\n return true;\n } else {\n return false;\n }\n}\nexport function sleep(time) {\n if (!time) time = 0;\n return new Promise(function (res) {\n return setTimeout(res, time);\n });\n}\nexport function randomInt(min, max) {\n return Math.floor(Math.random() * (max - min + 1) + min);\n}\n/**\n * https://stackoverflow.com/a/8084248\n */\n\nexport function randomToken() {\n return Math.random().toString(36).substring(2);\n}\nvar lastMs = 0;\nvar additional = 0;\n/**\n * returns the current time in micro-seconds,\n * WARNING: This is a pseudo-function\n * Performance.now is not reliable in webworkers, so we just make sure to never return the same time.\n * This is enough in browsers, and this function will not be used in nodejs.\n * The main reason for this hack is to ensure that BroadcastChannel behaves equal to production when it is used in fast-running unit tests.\n */\n\nexport function microSeconds() {\n var ms = new Date().getTime();\n\n if (ms === lastMs) {\n additional++;\n return ms * 1000 + additional;\n } else {\n lastMs = ms;\n additional = 0;\n return ms * 1000;\n }\n}\n/**\n * copied from the 'detect-node' npm module\n * We cannot use the module directly because it causes problems with rollup\n * @link https://github.com/iliakan/detect-node/blob/master/index.js\n */\n\nexport var isNode = Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]';"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;AACA;AACA;AACO,SAAS,SAAS,CAAC,GAAG,EAAE;AAC/B,EAAE,IAAI,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GAAG;AACH,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACU,IAAC,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,OAAO,KAAK,WAAW,GAAG,OAAO,GAAG,CAAC,CAAC,KAAK;;;;;;;;;"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* query-broadcast-client-experimental
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* this is a set which automatically forgets
|
|
17
|
-
* a given entry when a new entry is set and the ttl
|
|
18
|
-
* of the old one is over
|
|
19
|
-
*/
|
|
20
|
-
var ObliviousSet = /** @class */ (function () {
|
|
21
|
-
function ObliviousSet(ttl) {
|
|
22
|
-
this.ttl = ttl;
|
|
23
|
-
this.set = new Set();
|
|
24
|
-
this.timeMap = new Map();
|
|
25
|
-
}
|
|
26
|
-
ObliviousSet.prototype.has = function (value) {
|
|
27
|
-
return this.set.has(value);
|
|
28
|
-
};
|
|
29
|
-
ObliviousSet.prototype.add = function (value) {
|
|
30
|
-
var _this = this;
|
|
31
|
-
this.timeMap.set(value, now());
|
|
32
|
-
this.set.add(value);
|
|
33
|
-
/**
|
|
34
|
-
* When a new value is added,
|
|
35
|
-
* start the cleanup at the next tick
|
|
36
|
-
* to not block the cpu for more important stuff
|
|
37
|
-
* that might happen.
|
|
38
|
-
*/
|
|
39
|
-
setTimeout(function () {
|
|
40
|
-
removeTooOldValues(_this);
|
|
41
|
-
}, 0);
|
|
42
|
-
};
|
|
43
|
-
ObliviousSet.prototype.clear = function () {
|
|
44
|
-
this.set.clear();
|
|
45
|
-
this.timeMap.clear();
|
|
46
|
-
};
|
|
47
|
-
return ObliviousSet;
|
|
48
|
-
}());
|
|
49
|
-
/**
|
|
50
|
-
* Removes all entries from the set
|
|
51
|
-
* where the TTL has expired
|
|
52
|
-
*/
|
|
53
|
-
function removeTooOldValues(obliviousSet) {
|
|
54
|
-
var olderThen = now() - obliviousSet.ttl;
|
|
55
|
-
var iterator = obliviousSet.set[Symbol.iterator]();
|
|
56
|
-
/**
|
|
57
|
-
* Because we can assume the new values are added at the bottom,
|
|
58
|
-
* we start from the top and stop as soon as we reach a non-too-old value.
|
|
59
|
-
*/
|
|
60
|
-
while (true) {
|
|
61
|
-
var value = iterator.next().value;
|
|
62
|
-
if (!value) {
|
|
63
|
-
return; // no more elements
|
|
64
|
-
}
|
|
65
|
-
var time = obliviousSet.timeMap.get(value);
|
|
66
|
-
if (time < olderThen) {
|
|
67
|
-
obliviousSet.timeMap.delete(value);
|
|
68
|
-
obliviousSet.set.delete(value);
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
// We reached a value that is not old enough
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
function now() {
|
|
77
|
-
return new Date().getTime();
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
exports.ObliviousSet = ObliviousSet;
|
|
81
|
-
exports.now = now;
|
|
82
|
-
exports.removeTooOldValues = removeTooOldValues;
|
|
83
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../../../node_modules/oblivious-set/dist/es/index.js"],"sourcesContent":["/**\n * this is a set which automatically forgets\n * a given entry when a new entry is set and the ttl\n * of the old one is over\n */\nvar ObliviousSet = /** @class */ (function () {\n function ObliviousSet(ttl) {\n this.ttl = ttl;\n this.set = new Set();\n this.timeMap = new Map();\n }\n ObliviousSet.prototype.has = function (value) {\n return this.set.has(value);\n };\n ObliviousSet.prototype.add = function (value) {\n var _this = this;\n this.timeMap.set(value, now());\n this.set.add(value);\n /**\n * When a new value is added,\n * start the cleanup at the next tick\n * to not block the cpu for more important stuff\n * that might happen.\n */\n setTimeout(function () {\n removeTooOldValues(_this);\n }, 0);\n };\n ObliviousSet.prototype.clear = function () {\n this.set.clear();\n this.timeMap.clear();\n };\n return ObliviousSet;\n}());\nexport { ObliviousSet };\n/**\n * Removes all entries from the set\n * where the TTL has expired\n */\nexport function removeTooOldValues(obliviousSet) {\n var olderThen = now() - obliviousSet.ttl;\n var iterator = obliviousSet.set[Symbol.iterator]();\n /**\n * Because we can assume the new values are added at the bottom,\n * we start from the top and stop as soon as we reach a non-too-old value.\n */\n while (true) {\n var value = iterator.next().value;\n if (!value) {\n return; // no more elements\n }\n var time = obliviousSet.timeMap.get(value);\n if (time < olderThen) {\n obliviousSet.timeMap.delete(value);\n obliviousSet.set.delete(value);\n }\n else {\n // We reached a value that is not old enough\n return;\n }\n }\n}\nexport function now() {\n return new Date().getTime();\n}\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACG,IAAC,YAAY,kBAAkB,YAAY;AAC9C,IAAI,SAAS,YAAY,CAAC,GAAG,EAAE;AAC/B,QAAQ,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;AACvB,QAAQ,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;AAC7B,QAAQ,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;AACjC,KAAK;AACL,IAAI,YAAY,CAAC,SAAS,CAAC,GAAG,GAAG,UAAU,KAAK,EAAE;AAClD,QAAQ,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACnC,KAAK,CAAC;AACN,IAAI,YAAY,CAAC,SAAS,CAAC,GAAG,GAAG,UAAU,KAAK,EAAE;AAClD,QAAQ,IAAI,KAAK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AK,CAAC,CAAC;AAC3C,SAAS;AACT,aAAa;AACb;AACA,YAAY,OAAO;AACnB,SAAS;AACT,KAAK;AACL,CAAC;AACM,SAAS,GAAG,GAAG;AACtB,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;AAChC;;;;;;"}
|
|
@@ -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,oBAAAA,kBAAgB,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,EAAA,CAAA;AACFF,IAAAA,WAAW,GAAG,KAAd,CAAA;GAHF,CAAA;;AAMA,EAAA,MAAMG,OAAO,GAAG,IAAIC,iCAAJ,CAAqBL,kBAArB,EAAuC;AACrDM,IAAAA,gBAAgB,EAAE,KAAA;AADmC,GAAvC,CAAhB,CAAA;AAIA,EAAA,MAAMC,UAAU,GAAGR,WAAW,CAACS,aAAZ,EAAnB,CAAA;AAEAT,EAAAA,WAAW,CAACS,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,SAAxB,EAAmC;MACjCX,OAAO,CAACa,WAAR,CAAoB;AAClBF,QAAAA,IAAI,EAAE,SADY;QAElBH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