@tanstack/query-broadcast-client-experimental 4.0.0 → 4.0.5
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/node_modules/broadcast-channel/dist/es/broadcast-channel.js +260 -0
- package/build/cjs/node_modules/broadcast-channel/dist/es/broadcast-channel.js.map +1 -0
- package/build/cjs/node_modules/broadcast-channel/dist/es/method-chooser.js +83 -0
- package/build/cjs/node_modules/broadcast-channel/dist/es/method-chooser.js.map +1 -0
- package/build/cjs/node_modules/broadcast-channel/dist/es/methods/indexed-db.js +325 -0
- package/build/cjs/node_modules/broadcast-channel/dist/es/methods/indexed-db.js.map +1 -0
- package/build/cjs/node_modules/broadcast-channel/dist/es/methods/localstorage.js +193 -0
- package/build/cjs/node_modules/broadcast-channel/dist/es/methods/localstorage.js.map +1 -0
- package/build/cjs/node_modules/broadcast-channel/dist/es/methods/native.js +88 -0
- package/build/cjs/node_modules/broadcast-channel/dist/es/methods/native.js.map +1 -0
- package/build/cjs/node_modules/broadcast-channel/dist/es/methods/simulate.js +77 -0
- package/build/cjs/node_modules/broadcast-channel/dist/es/methods/simulate.js.map +1 -0
- package/build/cjs/node_modules/broadcast-channel/dist/es/options.js +41 -0
- package/build/cjs/node_modules/broadcast-channel/dist/es/options.js.map +1 -0
- package/build/cjs/node_modules/broadcast-channel/dist/es/util.js +77 -0
- package/build/cjs/node_modules/broadcast-channel/dist/es/util.js.map +1 -0
- package/build/cjs/node_modules/oblivious-set/dist/es/index.js +83 -0
- package/build/cjs/node_modules/oblivious-set/dist/es/index.js.map +1 -0
- package/build/stats-html.html +1 -1
- package/build/stats.json +427 -0
- package/build/types/query-broadcast-client-experimental/src/index.d.ts +7 -0
- package/build/types/query-core/src/focusManager.d.ts +16 -0
- package/build/types/query-core/src/hydration.d.ts +34 -0
- package/build/types/query-core/src/index.d.ts +20 -0
- package/build/types/query-core/src/infiniteQueryBehavior.d.ts +15 -0
- package/build/types/query-core/src/infiniteQueryObserver.d.ts +18 -0
- package/build/types/query-core/src/logger.d.ts +8 -0
- package/build/types/query-core/src/mutation.d.ts +70 -0
- package/build/types/query-core/src/mutationCache.d.ts +52 -0
- package/build/types/query-core/src/mutationObserver.d.ts +23 -0
- package/build/types/query-core/src/notifyManager.d.ts +18 -0
- package/build/types/query-core/src/onlineManager.d.ts +16 -0
- package/build/types/query-core/src/queriesObserver.d.ts +23 -0
- package/build/types/query-core/src/query.d.ts +119 -0
- package/build/types/query-core/src/queryCache.d.ts +59 -0
- package/build/types/query-core/src/queryClient.d.ts +65 -0
- package/build/types/query-core/src/queryObserver.d.ts +61 -0
- package/build/types/query-core/src/removable.d.ts +9 -0
- package/build/types/query-core/src/retryer.d.ts +33 -0
- package/build/types/query-core/src/subscribable.d.ts +10 -0
- package/build/types/query-core/src/types.d.ts +417 -0
- package/build/types/query-core/src/utils.d.ts +99 -0
- package/package.json +2 -2
|
@@ -0,0 +1,260 @@
|
|
|
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
|
+
var methodChooser = require('./method-chooser.js');
|
|
17
|
+
var options = require('./options.js');
|
|
18
|
+
|
|
19
|
+
var BroadcastChannel = function BroadcastChannel(name, options$1) {
|
|
20
|
+
this.name = name;
|
|
21
|
+
|
|
22
|
+
if (ENFORCED_OPTIONS) {
|
|
23
|
+
options$1 = ENFORCED_OPTIONS;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
this.options = options.fillOptionsWithDefaults(options$1);
|
|
27
|
+
this.method = methodChooser.chooseMethod(this.options); // isListening
|
|
28
|
+
|
|
29
|
+
this._iL = false;
|
|
30
|
+
/**
|
|
31
|
+
* _onMessageListener
|
|
32
|
+
* setting onmessage twice,
|
|
33
|
+
* will overwrite the first listener
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
this._onML = null;
|
|
37
|
+
/**
|
|
38
|
+
* _addEventListeners
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
this._addEL = {
|
|
42
|
+
message: [],
|
|
43
|
+
internal: []
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Unsend message promises
|
|
47
|
+
* where the sending is still in progress
|
|
48
|
+
* @type {Set<Promise>}
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
this._uMP = new Set();
|
|
52
|
+
/**
|
|
53
|
+
* _beforeClose
|
|
54
|
+
* array of promises that will be awaited
|
|
55
|
+
* before the channel is closed
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
this._befC = [];
|
|
59
|
+
/**
|
|
60
|
+
* _preparePromise
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
this._prepP = null;
|
|
64
|
+
|
|
65
|
+
_prepareChannel(this);
|
|
66
|
+
}; // STATICS
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* used to identify if someone overwrites
|
|
70
|
+
* window.BroadcastChannel with this
|
|
71
|
+
* See methods/native.js
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
BroadcastChannel._pubkey = true;
|
|
75
|
+
/**
|
|
76
|
+
* if set, this method is enforced,
|
|
77
|
+
* no mather what the options are
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
var ENFORCED_OPTIONS;
|
|
81
|
+
|
|
82
|
+
BroadcastChannel.prototype = {
|
|
83
|
+
postMessage: function postMessage(msg) {
|
|
84
|
+
if (this.closed) {
|
|
85
|
+
throw new Error('BroadcastChannel.postMessage(): ' + 'Cannot post message after channel has closed');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return _post(this, 'message', msg);
|
|
89
|
+
},
|
|
90
|
+
postInternal: function postInternal(msg) {
|
|
91
|
+
return _post(this, 'internal', msg);
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
set onmessage(fn) {
|
|
95
|
+
var time = this.method.microSeconds();
|
|
96
|
+
var listenObj = {
|
|
97
|
+
time: time,
|
|
98
|
+
fn: fn
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
_removeListenerObject(this, 'message', this._onML);
|
|
102
|
+
|
|
103
|
+
if (fn && typeof fn === 'function') {
|
|
104
|
+
this._onML = listenObj;
|
|
105
|
+
|
|
106
|
+
_addListenerObject(this, 'message', listenObj);
|
|
107
|
+
} else {
|
|
108
|
+
this._onML = null;
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
addEventListener: function addEventListener(type, fn) {
|
|
113
|
+
var time = this.method.microSeconds();
|
|
114
|
+
var listenObj = {
|
|
115
|
+
time: time,
|
|
116
|
+
fn: fn
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
_addListenerObject(this, type, listenObj);
|
|
120
|
+
},
|
|
121
|
+
removeEventListener: function removeEventListener(type, fn) {
|
|
122
|
+
var obj = this._addEL[type].find(function (obj) {
|
|
123
|
+
return obj.fn === fn;
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
_removeListenerObject(this, type, obj);
|
|
127
|
+
},
|
|
128
|
+
close: function close() {
|
|
129
|
+
var _this = this;
|
|
130
|
+
|
|
131
|
+
if (this.closed) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
this.closed = true;
|
|
136
|
+
var awaitPrepare = this._prepP ? this._prepP : Promise.resolve();
|
|
137
|
+
this._onML = null;
|
|
138
|
+
this._addEL.message = [];
|
|
139
|
+
return awaitPrepare // wait until all current sending are processed
|
|
140
|
+
.then(function () {
|
|
141
|
+
return Promise.all(Array.from(_this._uMP));
|
|
142
|
+
}) // run before-close hooks
|
|
143
|
+
.then(function () {
|
|
144
|
+
return Promise.all(_this._befC.map(function (fn) {
|
|
145
|
+
return fn();
|
|
146
|
+
}));
|
|
147
|
+
}) // close the channel
|
|
148
|
+
.then(function () {
|
|
149
|
+
return _this.method.close(_this._state);
|
|
150
|
+
});
|
|
151
|
+
},
|
|
152
|
+
|
|
153
|
+
get type() {
|
|
154
|
+
return this.method.type;
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
get isClosed() {
|
|
158
|
+
return this.closed;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Post a message over the channel
|
|
164
|
+
* @returns {Promise} that resolved when the message sending is done
|
|
165
|
+
*/
|
|
166
|
+
|
|
167
|
+
function _post(broadcastChannel, type, msg) {
|
|
168
|
+
var time = broadcastChannel.method.microSeconds();
|
|
169
|
+
var msgObj = {
|
|
170
|
+
time: time,
|
|
171
|
+
type: type,
|
|
172
|
+
data: msg
|
|
173
|
+
};
|
|
174
|
+
var awaitPrepare = broadcastChannel._prepP ? broadcastChannel._prepP : Promise.resolve();
|
|
175
|
+
return awaitPrepare.then(function () {
|
|
176
|
+
var sendPromise = broadcastChannel.method.postMessage(broadcastChannel._state, msgObj); // add/remove to unsend messages list
|
|
177
|
+
|
|
178
|
+
broadcastChannel._uMP.add(sendPromise);
|
|
179
|
+
|
|
180
|
+
sendPromise["catch"]().then(function () {
|
|
181
|
+
return broadcastChannel._uMP["delete"](sendPromise);
|
|
182
|
+
});
|
|
183
|
+
return sendPromise;
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function _prepareChannel(channel) {
|
|
188
|
+
var maybePromise = channel.method.create(channel.name, channel.options);
|
|
189
|
+
|
|
190
|
+
if (util.isPromise(maybePromise)) {
|
|
191
|
+
channel._prepP = maybePromise;
|
|
192
|
+
maybePromise.then(function (s) {
|
|
193
|
+
// used in tests to simulate slow runtime
|
|
194
|
+
|
|
195
|
+
/*if (channel.options.prepareDelay) {
|
|
196
|
+
await new Promise(res => setTimeout(res, this.options.prepareDelay));
|
|
197
|
+
}*/
|
|
198
|
+
channel._state = s;
|
|
199
|
+
});
|
|
200
|
+
} else {
|
|
201
|
+
channel._state = maybePromise;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function _hasMessageListeners(channel) {
|
|
206
|
+
if (channel._addEL.message.length > 0) return true;
|
|
207
|
+
if (channel._addEL.internal.length > 0) return true;
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function _addListenerObject(channel, type, obj) {
|
|
212
|
+
channel._addEL[type].push(obj);
|
|
213
|
+
|
|
214
|
+
_startListening(channel);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function _removeListenerObject(channel, type, obj) {
|
|
218
|
+
channel._addEL[type] = channel._addEL[type].filter(function (o) {
|
|
219
|
+
return o !== obj;
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
_stopListening(channel);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function _startListening(channel) {
|
|
226
|
+
if (!channel._iL && _hasMessageListeners(channel)) {
|
|
227
|
+
// someone is listening, start subscribing
|
|
228
|
+
var listenerFn = function listenerFn(msgObj) {
|
|
229
|
+
channel._addEL[msgObj.type].forEach(function (obj) {
|
|
230
|
+
if (msgObj.time >= obj.time) {
|
|
231
|
+
obj.fn(msgObj.data);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
var time = channel.method.microSeconds();
|
|
237
|
+
|
|
238
|
+
if (channel._prepP) {
|
|
239
|
+
channel._prepP.then(function () {
|
|
240
|
+
channel._iL = true;
|
|
241
|
+
channel.method.onMessage(channel._state, listenerFn, time);
|
|
242
|
+
});
|
|
243
|
+
} else {
|
|
244
|
+
channel._iL = true;
|
|
245
|
+
channel.method.onMessage(channel._state, listenerFn, time);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function _stopListening(channel) {
|
|
251
|
+
if (channel._iL && !_hasMessageListeners(channel)) {
|
|
252
|
+
// noone is listening, stop subscribing
|
|
253
|
+
channel._iL = false;
|
|
254
|
+
var time = channel.method.microSeconds();
|
|
255
|
+
channel.method.onMessage(channel._state, null, time);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
exports.BroadcastChannel = BroadcastChannel;
|
|
260
|
+
//# sourceMappingURL=broadcast-channel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"broadcast-channel.js","sources":["../../../../../../../../node_modules/broadcast-channel/dist/es/broadcast-channel.js"],"sourcesContent":["import { isPromise } from './util.js';\nimport { chooseMethod } from './method-chooser.js';\nimport { fillOptionsWithDefaults } from './options.js';\nexport var BroadcastChannel = function BroadcastChannel(name, options) {\n this.name = name;\n\n if (ENFORCED_OPTIONS) {\n options = ENFORCED_OPTIONS;\n }\n\n this.options = fillOptionsWithDefaults(options);\n this.method = chooseMethod(this.options); // isListening\n\n this._iL = false;\n /**\n * _onMessageListener\n * setting onmessage twice,\n * will overwrite the first listener\n */\n\n this._onML = null;\n /**\n * _addEventListeners\n */\n\n this._addEL = {\n message: [],\n internal: []\n };\n /**\n * Unsend message promises\n * where the sending is still in progress\n * @type {Set<Promise>}\n */\n\n this._uMP = new Set();\n /**\n * _beforeClose\n * array of promises that will be awaited\n * before the channel is closed\n */\n\n this._befC = [];\n /**\n * _preparePromise\n */\n\n this._prepP = null;\n\n _prepareChannel(this);\n}; // STATICS\n\n/**\n * used to identify if someone overwrites\n * window.BroadcastChannel with this\n * See methods/native.js\n */\n\nBroadcastChannel._pubkey = true;\n/**\n * clears the tmp-folder if is node\n * @return {Promise<boolean>} true if has run, false if not node\n */\n\nexport function clearNodeFolder(options) {\n options = fillOptionsWithDefaults(options);\n var method = chooseMethod(options);\n\n if (method.type === 'node') {\n return method.clearNodeFolder().then(function () {\n return true;\n });\n } else {\n return Promise.resolve(false);\n }\n}\n/**\n * if set, this method is enforced,\n * no mather what the options are\n */\n\nvar ENFORCED_OPTIONS;\nexport function enforceOptions(options) {\n ENFORCED_OPTIONS = options;\n} // PROTOTYPE\n\nBroadcastChannel.prototype = {\n postMessage: function postMessage(msg) {\n if (this.closed) {\n throw new Error('BroadcastChannel.postMessage(): ' + 'Cannot post message after channel has closed');\n }\n\n return _post(this, 'message', msg);\n },\n postInternal: function postInternal(msg) {\n return _post(this, 'internal', msg);\n },\n\n set onmessage(fn) {\n var time = this.method.microSeconds();\n var listenObj = {\n time: time,\n fn: fn\n };\n\n _removeListenerObject(this, 'message', this._onML);\n\n if (fn && typeof fn === 'function') {\n this._onML = listenObj;\n\n _addListenerObject(this, 'message', listenObj);\n } else {\n this._onML = null;\n }\n },\n\n addEventListener: function addEventListener(type, fn) {\n var time = this.method.microSeconds();\n var listenObj = {\n time: time,\n fn: fn\n };\n\n _addListenerObject(this, type, listenObj);\n },\n removeEventListener: function removeEventListener(type, fn) {\n var obj = this._addEL[type].find(function (obj) {\n return obj.fn === fn;\n });\n\n _removeListenerObject(this, type, obj);\n },\n close: function close() {\n var _this = this;\n\n if (this.closed) {\n return;\n }\n\n this.closed = true;\n var awaitPrepare = this._prepP ? this._prepP : Promise.resolve();\n this._onML = null;\n this._addEL.message = [];\n return awaitPrepare // wait until all current sending are processed\n .then(function () {\n return Promise.all(Array.from(_this._uMP));\n }) // run before-close hooks\n .then(function () {\n return Promise.all(_this._befC.map(function (fn) {\n return fn();\n }));\n }) // close the channel\n .then(function () {\n return _this.method.close(_this._state);\n });\n },\n\n get type() {\n return this.method.type;\n },\n\n get isClosed() {\n return this.closed;\n }\n\n};\n/**\n * Post a message over the channel\n * @returns {Promise} that resolved when the message sending is done\n */\n\nfunction _post(broadcastChannel, type, msg) {\n var time = broadcastChannel.method.microSeconds();\n var msgObj = {\n time: time,\n type: type,\n data: msg\n };\n var awaitPrepare = broadcastChannel._prepP ? broadcastChannel._prepP : Promise.resolve();\n return awaitPrepare.then(function () {\n var sendPromise = broadcastChannel.method.postMessage(broadcastChannel._state, msgObj); // add/remove to unsend messages list\n\n broadcastChannel._uMP.add(sendPromise);\n\n sendPromise[\"catch\"]().then(function () {\n return broadcastChannel._uMP[\"delete\"](sendPromise);\n });\n return sendPromise;\n });\n}\n\nfunction _prepareChannel(channel) {\n var maybePromise = channel.method.create(channel.name, channel.options);\n\n if (isPromise(maybePromise)) {\n channel._prepP = maybePromise;\n maybePromise.then(function (s) {\n // used in tests to simulate slow runtime\n\n /*if (channel.options.prepareDelay) {\n await new Promise(res => setTimeout(res, this.options.prepareDelay));\n }*/\n channel._state = s;\n });\n } else {\n channel._state = maybePromise;\n }\n}\n\nfunction _hasMessageListeners(channel) {\n if (channel._addEL.message.length > 0) return true;\n if (channel._addEL.internal.length > 0) return true;\n return false;\n}\n\nfunction _addListenerObject(channel, type, obj) {\n channel._addEL[type].push(obj);\n\n _startListening(channel);\n}\n\nfunction _removeListenerObject(channel, type, obj) {\n channel._addEL[type] = channel._addEL[type].filter(function (o) {\n return o !== obj;\n });\n\n _stopListening(channel);\n}\n\nfunction _startListening(channel) {\n if (!channel._iL && _hasMessageListeners(channel)) {\n // someone is listening, start subscribing\n var listenerFn = function listenerFn(msgObj) {\n channel._addEL[msgObj.type].forEach(function (obj) {\n if (msgObj.time >= obj.time) {\n obj.fn(msgObj.data);\n }\n });\n };\n\n var time = channel.method.microSeconds();\n\n if (channel._prepP) {\n channel._prepP.then(function () {\n channel._iL = true;\n channel.method.onMessage(channel._state, listenerFn, time);\n });\n } else {\n channel._iL = true;\n channel.method.onMessage(channel._state, listenerFn, time);\n }\n }\n}\n\nfunction _stopListening(channel) {\n if (channel._iL && !_hasMessageListeners(channel)) {\n // noone is listening, stop subscribing\n channel._iL = false;\n var time = channel.method.microSeconds();\n channel.method.onMessage(channel._state, null, time);\n }\n}"],"names":["options","fillOptionsWithDefaults","chooseMethod","isPromise"],"mappings":";;;;;;;;;;;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,YAAY,EAAE,CAAC;AAC7C,IAAI,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACzD,GAAG;AACH;;;;"}
|
|
@@ -0,0 +1,83 @@
|
|
|
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 native = require('./methods/native.js');
|
|
16
|
+
var indexedDb = require('./methods/indexed-db.js');
|
|
17
|
+
var localstorage = require('./methods/localstorage.js');
|
|
18
|
+
var simulate = require('./methods/simulate.js');
|
|
19
|
+
var util = require('./util.js');
|
|
20
|
+
|
|
21
|
+
var METHODS = [native["default"], // fastest
|
|
22
|
+
indexedDb["default"], localstorage["default"]];
|
|
23
|
+
/**
|
|
24
|
+
* The NodeMethod is loaded lazy
|
|
25
|
+
* so it will not get bundled in browser-builds
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
if (util.isNode) {
|
|
29
|
+
/**
|
|
30
|
+
* we use the non-transpiled code for nodejs
|
|
31
|
+
* because it runs faster
|
|
32
|
+
*/
|
|
33
|
+
var NodeMethod = require('../../src/methods/' + // use this hack so that browserify and others
|
|
34
|
+
// do not import the node-method by default
|
|
35
|
+
// when bundling.
|
|
36
|
+
'node.js');
|
|
37
|
+
/**
|
|
38
|
+
* this will be false for webpackbuilds
|
|
39
|
+
* which will shim the node-method with an empty object {}
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
if (typeof NodeMethod.canBeUsed === 'function') {
|
|
44
|
+
METHODS.push(NodeMethod);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function chooseMethod(options) {
|
|
49
|
+
var chooseMethods = [].concat(options.methods, METHODS).filter(Boolean); // directly chosen
|
|
50
|
+
|
|
51
|
+
if (options.type) {
|
|
52
|
+
if (options.type === 'simulate') {
|
|
53
|
+
// only use simulate-method if directly chosen
|
|
54
|
+
return simulate["default"];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
var ret = chooseMethods.find(function (m) {
|
|
58
|
+
return m.type === options.type;
|
|
59
|
+
});
|
|
60
|
+
if (!ret) throw new Error('method-type ' + options.type + ' not found');else return ret;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* if no webworker support is needed,
|
|
64
|
+
* remove idb from the list so that localstorage is been chosen
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
if (!options.webWorkerSupport && !util.isNode) {
|
|
69
|
+
chooseMethods = chooseMethods.filter(function (m) {
|
|
70
|
+
return m.type !== 'idb';
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
var useMethod = chooseMethods.find(function (method) {
|
|
75
|
+
return method.canBeUsed();
|
|
76
|
+
});
|
|
77
|
+
if (!useMethod) throw new Error('No useable methode found:' + JSON.stringify(METHODS.map(function (m) {
|
|
78
|
+
return m.type;
|
|
79
|
+
})));else return useMethod;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
exports.chooseMethod = chooseMethod;
|
|
83
|
+
//# sourceMappingURL=method-chooser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"method-chooser.js","sources":["../../../../../../../../node_modules/broadcast-channel/dist/es/method-chooser.js"],"sourcesContent":["import NativeMethod from './methods/native.js';\nimport IndexeDbMethod from './methods/indexed-db.js';\nimport LocalstorageMethod from './methods/localstorage.js';\nimport SimulateMethod from './methods/simulate.js';\nimport { isNode } from './util'; // order is important\n\nvar METHODS = [NativeMethod, // fastest\nIndexeDbMethod, LocalstorageMethod];\n/**\n * The NodeMethod is loaded lazy\n * so it will not get bundled in browser-builds\n */\n\nif (isNode) {\n /**\n * we use the non-transpiled code for nodejs\n * because it runs faster\n */\n var NodeMethod = require('../../src/methods/' + // use this hack so that browserify and others\n // do not import the node-method by default\n // when bundling.\n 'node.js');\n /**\n * this will be false for webpackbuilds\n * which will shim the node-method with an empty object {}\n */\n\n\n if (typeof NodeMethod.canBeUsed === 'function') {\n METHODS.push(NodeMethod);\n }\n}\n\nexport function chooseMethod(options) {\n var chooseMethods = [].concat(options.methods, METHODS).filter(Boolean); // directly chosen\n\n if (options.type) {\n if (options.type === 'simulate') {\n // only use simulate-method if directly chosen\n return SimulateMethod;\n }\n\n var ret = chooseMethods.find(function (m) {\n return m.type === options.type;\n });\n if (!ret) throw new Error('method-type ' + options.type + ' not found');else return ret;\n }\n /**\n * if no webworker support is needed,\n * remove idb from the list so that localstorage is been chosen\n */\n\n\n if (!options.webWorkerSupport && !isNode) {\n chooseMethods = chooseMethods.filter(function (m) {\n return m.type !== 'idb';\n });\n }\n\n var useMethod = chooseMethods.find(function (method) {\n return method.canBeUsed();\n });\n if (!useMethod) throw new Error('No useable methode found:' + JSON.stringify(METHODS.map(function (m) {\n return m.type;\n })));else return useMethod;\n}"],"names":["NativeMethod","IndexeDbMethod","LocalstorageMethod","isNode","SimulateMethod"],"mappings":";;;;;;;;;;;;;;;;;;;;AAMA,IAAI,OAAO,GAAG,CAACA,iBAAY;AAC3BC,oBAAc,EAAEC,uBAAkB,CAAC,CAAC;AACpC;AACA;AACA;AACA;AACA;AACA,IAAIC,WAAM,EAAE;AACZ;AACA;AACA;AACA;AACA,EAAE,IAAI,UAAU,GAAG,OAAO,CAAC,oBAAoB;AAC/C;AACA;AACA,EAAE,SAAS,CAAC,CAAC;AACb;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,IAAI,OAAO,UAAU,CAAC,SAAS,KAAK,UAAU,EAAE;AAClD,IAAI,OAAO,C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