@apollo/client 3.7.0-alpha.3 → 3.7.0-alpha.6
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/apollo-client.cjs +68 -60
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +9 -10
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +2288 -0
- package/cache/inmemory/readFromStore.d.ts.map +1 -1
- package/cache/inmemory/readFromStore.js +10 -11
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +3 -3
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +4 -3
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +6 -5
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +2142 -0
- package/errors/errors.cjs.native.js +48 -0
- package/invariantErrorCodes.js +1 -1
- package/link/batch/batch.cjs.native.js +161 -0
- package/link/batch-http/batch-http.cjs.native.js +127 -0
- package/link/context/context.cjs.native.js +38 -0
- package/link/core/core.cjs.native.js +121 -0
- package/link/error/error.cjs.native.js +90 -0
- package/link/http/http.cjs.native.js +320 -0
- package/link/persisted-queries/persisted-queries.cjs.native.js +174 -0
- package/link/retry/retry.cjs.native.js +170 -0
- package/link/schema/schema.cjs.native.js +56 -0
- package/link/subscriptions/subscriptions.cjs.native.js +45 -0
- package/link/utils/utils.cjs.native.js +115 -0
- package/link/ws/ws.cjs.native.js +28 -0
- package/main.cjs.native.js +16 -0
- package/package.json +12 -12
- package/react/components/components.cjs.native.js +79 -0
- package/react/context/context.cjs.native.js +67 -0
- package/react/hoc/hoc.cjs.native.js +325 -0
- package/react/hooks/hooks.cjs +28 -15
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +609 -0
- package/react/hooks/useQuery.d.ts +1 -1
- package/react/hooks/useQuery.d.ts.map +1 -1
- package/react/hooks/useQuery.js +7 -2
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSubscription.d.ts.map +1 -1
- package/react/hooks/useSubscription.js +17 -7
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSyncExternalStore.d.ts.map +1 -1
- package/react/hooks/useSyncExternalStore.js +4 -6
- package/react/hooks/useSyncExternalStore.js.map +1 -1
- package/react/parser/parser.cjs.native.js +103 -0
- package/react/react.cjs.native.js +22 -0
- package/react/ssr/ssr.cjs.native.js +150 -0
- package/testing/core/core.cjs.native.js +288 -0
- package/testing/testing.cjs.native.js +58 -0
- package/utilities/common/mergeDeep.d.ts.map +1 -1
- package/utilities/common/mergeDeep.js +8 -11
- package/utilities/common/mergeDeep.js.map +1 -1
- package/utilities/globals/globals.cjs.native.js +56 -0
- package/utilities/observables/Concast.d.ts +5 -3
- package/utilities/observables/Concast.d.ts.map +1 -1
- package/utilities/observables/Concast.js +17 -19
- package/utilities/observables/Concast.js.map +1 -1
- package/utilities/policies/pagination.d.ts.map +1 -1
- package/utilities/policies/pagination.js +9 -7
- package/utilities/policies/pagination.js.map +1 -1
- package/utilities/utilities.cjs +34 -37
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +1279 -0
- package/version.js +1 -1
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var globals = require('../../utilities/globals');
|
|
7
|
+
var graphql = require('graphql');
|
|
8
|
+
var equality = require('@wry/equality');
|
|
9
|
+
var core = require('../../link/core');
|
|
10
|
+
var utilities = require('../../utilities');
|
|
11
|
+
var core$1 = require('../../core');
|
|
12
|
+
var cache = require('../../cache');
|
|
13
|
+
|
|
14
|
+
function requestToKey(request, addTypename) {
|
|
15
|
+
var queryString = request.query &&
|
|
16
|
+
graphql.print(addTypename ? utilities.addTypenameToDocument(request.query) : request.query);
|
|
17
|
+
var requestKey = { query: queryString };
|
|
18
|
+
return JSON.stringify(requestKey);
|
|
19
|
+
}
|
|
20
|
+
var MockLink = (function (_super) {
|
|
21
|
+
tslib.__extends(MockLink, _super);
|
|
22
|
+
function MockLink(mockedResponses, addTypename) {
|
|
23
|
+
if (addTypename === void 0) { addTypename = true; }
|
|
24
|
+
var _this = _super.call(this) || this;
|
|
25
|
+
_this.addTypename = true;
|
|
26
|
+
_this.mockedResponsesByKey = {};
|
|
27
|
+
_this.addTypename = addTypename;
|
|
28
|
+
if (mockedResponses) {
|
|
29
|
+
mockedResponses.forEach(function (mockedResponse) {
|
|
30
|
+
_this.addMockedResponse(mockedResponse);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return _this;
|
|
34
|
+
}
|
|
35
|
+
MockLink.prototype.addMockedResponse = function (mockedResponse) {
|
|
36
|
+
var normalizedMockedResponse = this.normalizeMockedResponse(mockedResponse);
|
|
37
|
+
var key = requestToKey(normalizedMockedResponse.request, this.addTypename);
|
|
38
|
+
var mockedResponses = this.mockedResponsesByKey[key];
|
|
39
|
+
if (!mockedResponses) {
|
|
40
|
+
mockedResponses = [];
|
|
41
|
+
this.mockedResponsesByKey[key] = mockedResponses;
|
|
42
|
+
}
|
|
43
|
+
mockedResponses.push(normalizedMockedResponse);
|
|
44
|
+
};
|
|
45
|
+
MockLink.prototype.request = function (operation) {
|
|
46
|
+
var _this = this;
|
|
47
|
+
this.operation = operation;
|
|
48
|
+
var key = requestToKey(operation, this.addTypename);
|
|
49
|
+
var unmatchedVars = [];
|
|
50
|
+
var requestVariables = operation.variables || {};
|
|
51
|
+
var mockedResponses = this.mockedResponsesByKey[key];
|
|
52
|
+
var responseIndex = mockedResponses ? mockedResponses.findIndex(function (res, index) {
|
|
53
|
+
var mockedResponseVars = res.request.variables || {};
|
|
54
|
+
if (equality.equal(requestVariables, mockedResponseVars)) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
unmatchedVars.push(mockedResponseVars);
|
|
58
|
+
return false;
|
|
59
|
+
}) : -1;
|
|
60
|
+
var response = responseIndex >= 0
|
|
61
|
+
? mockedResponses[responseIndex]
|
|
62
|
+
: void 0;
|
|
63
|
+
var configError;
|
|
64
|
+
if (!response) {
|
|
65
|
+
configError = new Error("No more mocked responses for the query: ".concat(graphql.print(operation.query), "\nExpected variables: ").concat(utilities.stringifyForDisplay(operation.variables), "\n").concat(unmatchedVars.length > 0 ? "\nFailed to match ".concat(unmatchedVars.length, " mock").concat(unmatchedVars.length === 1 ? "" : "s", " for this query, which had the following variables:\n").concat(unmatchedVars.map(function (d) { return " ".concat(utilities.stringifyForDisplay(d)); }).join('\n'), "\n") : ""));
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
mockedResponses.splice(responseIndex, 1);
|
|
69
|
+
var newData = response.newData;
|
|
70
|
+
if (newData) {
|
|
71
|
+
response.result = newData();
|
|
72
|
+
mockedResponses.push(response);
|
|
73
|
+
}
|
|
74
|
+
if (!response.result && !response.error) {
|
|
75
|
+
configError = new Error("Mocked response should contain either result or error: ".concat(key));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return new utilities.Observable(function (observer) {
|
|
79
|
+
var timer = setTimeout(function () {
|
|
80
|
+
if (configError) {
|
|
81
|
+
try {
|
|
82
|
+
if (_this.onError(configError, observer) !== false) {
|
|
83
|
+
throw configError;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
observer.error(error);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else if (response) {
|
|
91
|
+
if (response.error) {
|
|
92
|
+
observer.error(response.error);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
if (response.result) {
|
|
96
|
+
observer.next(typeof response.result === 'function'
|
|
97
|
+
? response.result()
|
|
98
|
+
: response.result);
|
|
99
|
+
}
|
|
100
|
+
observer.complete();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}, response && response.delay || 0);
|
|
104
|
+
return function () {
|
|
105
|
+
clearTimeout(timer);
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
MockLink.prototype.normalizeMockedResponse = function (mockedResponse) {
|
|
110
|
+
var newMockedResponse = utilities.cloneDeep(mockedResponse);
|
|
111
|
+
var queryWithoutConnection = utilities.removeConnectionDirectiveFromDocument(newMockedResponse.request.query);
|
|
112
|
+
__DEV__ ? globals.invariant(queryWithoutConnection, "query is required") : globals.invariant(queryWithoutConnection, 35);
|
|
113
|
+
newMockedResponse.request.query = queryWithoutConnection;
|
|
114
|
+
var query = utilities.removeClientSetsFromDocument(newMockedResponse.request.query);
|
|
115
|
+
if (query) {
|
|
116
|
+
newMockedResponse.request.query = query;
|
|
117
|
+
}
|
|
118
|
+
return newMockedResponse;
|
|
119
|
+
};
|
|
120
|
+
return MockLink;
|
|
121
|
+
}(core.ApolloLink));
|
|
122
|
+
function mockSingleLink() {
|
|
123
|
+
var mockedResponses = [];
|
|
124
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
125
|
+
mockedResponses[_i] = arguments[_i];
|
|
126
|
+
}
|
|
127
|
+
var maybeTypename = mockedResponses[mockedResponses.length - 1];
|
|
128
|
+
var mocks = mockedResponses.slice(0, mockedResponses.length - 1);
|
|
129
|
+
if (typeof maybeTypename !== 'boolean') {
|
|
130
|
+
mocks = mockedResponses;
|
|
131
|
+
maybeTypename = true;
|
|
132
|
+
}
|
|
133
|
+
return new MockLink(mocks, maybeTypename);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
var MockSubscriptionLink = (function (_super) {
|
|
137
|
+
tslib.__extends(MockSubscriptionLink, _super);
|
|
138
|
+
function MockSubscriptionLink() {
|
|
139
|
+
var _this = _super.call(this) || this;
|
|
140
|
+
_this.unsubscribers = [];
|
|
141
|
+
_this.setups = [];
|
|
142
|
+
_this.observers = [];
|
|
143
|
+
return _this;
|
|
144
|
+
}
|
|
145
|
+
MockSubscriptionLink.prototype.request = function (operation) {
|
|
146
|
+
var _this = this;
|
|
147
|
+
this.operation = operation;
|
|
148
|
+
return new utilities.Observable(function (observer) {
|
|
149
|
+
_this.setups.forEach(function (x) { return x(); });
|
|
150
|
+
_this.observers.push(observer);
|
|
151
|
+
return function () {
|
|
152
|
+
_this.unsubscribers.forEach(function (x) { return x(); });
|
|
153
|
+
};
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
MockSubscriptionLink.prototype.simulateResult = function (result, complete) {
|
|
157
|
+
var _this = this;
|
|
158
|
+
if (complete === void 0) { complete = false; }
|
|
159
|
+
setTimeout(function () {
|
|
160
|
+
var observers = _this.observers;
|
|
161
|
+
if (!observers.length)
|
|
162
|
+
throw new Error('subscription torn down');
|
|
163
|
+
observers.forEach(function (observer) {
|
|
164
|
+
if (result.result && observer.next)
|
|
165
|
+
observer.next(result.result);
|
|
166
|
+
if (result.error && observer.error)
|
|
167
|
+
observer.error(result.error);
|
|
168
|
+
if (complete && observer.complete)
|
|
169
|
+
observer.complete();
|
|
170
|
+
});
|
|
171
|
+
}, result.delay || 0);
|
|
172
|
+
};
|
|
173
|
+
MockSubscriptionLink.prototype.simulateComplete = function () {
|
|
174
|
+
var observers = this.observers;
|
|
175
|
+
if (!observers.length)
|
|
176
|
+
throw new Error('subscription torn down');
|
|
177
|
+
observers.forEach(function (observer) {
|
|
178
|
+
if (observer.complete)
|
|
179
|
+
observer.complete();
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
MockSubscriptionLink.prototype.onSetup = function (listener) {
|
|
183
|
+
this.setups = this.setups.concat([listener]);
|
|
184
|
+
};
|
|
185
|
+
MockSubscriptionLink.prototype.onUnsubscribe = function (listener) {
|
|
186
|
+
this.unsubscribers = this.unsubscribers.concat([listener]);
|
|
187
|
+
};
|
|
188
|
+
return MockSubscriptionLink;
|
|
189
|
+
}(core.ApolloLink));
|
|
190
|
+
function mockObservableLink() {
|
|
191
|
+
return new MockSubscriptionLink();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function createMockClient(data, query, variables) {
|
|
195
|
+
if (variables === void 0) { variables = {}; }
|
|
196
|
+
return new core$1.ApolloClient({
|
|
197
|
+
link: mockSingleLink({
|
|
198
|
+
request: { query: query, variables: variables },
|
|
199
|
+
result: { data: data },
|
|
200
|
+
}).setOnError(function (error) { throw error; }),
|
|
201
|
+
cache: new cache.InMemoryCache({ addTypename: false }),
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function subscribeAndCount(reject, observable, cb) {
|
|
206
|
+
var queue = Promise.resolve();
|
|
207
|
+
var handleCount = 0;
|
|
208
|
+
var subscription = utilities.asyncMap(observable, function (result) {
|
|
209
|
+
return queue = queue.then(function () {
|
|
210
|
+
return cb(++handleCount, result);
|
|
211
|
+
}).catch(error);
|
|
212
|
+
}).subscribe({ error: error });
|
|
213
|
+
function error(e) {
|
|
214
|
+
subscription.unsubscribe();
|
|
215
|
+
reject(e);
|
|
216
|
+
}
|
|
217
|
+
return subscription;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function wrap(key) {
|
|
221
|
+
return function (message, callback, timeout) { return (key ? it[key] : it)(message, function () {
|
|
222
|
+
var _this = this;
|
|
223
|
+
return new Promise(function (resolve, reject) { return callback.call(_this, resolve, reject); });
|
|
224
|
+
}, timeout); };
|
|
225
|
+
}
|
|
226
|
+
var wrappedIt = wrap();
|
|
227
|
+
var itAsync = Object.assign(function () {
|
|
228
|
+
var args = [];
|
|
229
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
230
|
+
args[_i] = arguments[_i];
|
|
231
|
+
}
|
|
232
|
+
return wrappedIt.apply(this, args);
|
|
233
|
+
}, {
|
|
234
|
+
only: wrap("only"),
|
|
235
|
+
skip: wrap("skip"),
|
|
236
|
+
todo: wrap("todo"),
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
function wrapTestFunction(fn, consoleMethodName) {
|
|
240
|
+
return function () {
|
|
241
|
+
var _this = this;
|
|
242
|
+
var args = arguments;
|
|
243
|
+
var spy = jest.spyOn(console, consoleMethodName);
|
|
244
|
+
spy.mockImplementation(function () { });
|
|
245
|
+
return new Promise(function (resolve) {
|
|
246
|
+
resolve(fn === null || fn === void 0 ? void 0 : fn.apply(_this, args));
|
|
247
|
+
}).finally(function () {
|
|
248
|
+
expect(spy).toMatchSnapshot();
|
|
249
|
+
spy.mockReset();
|
|
250
|
+
});
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
function withErrorSpy(it) {
|
|
254
|
+
var args = [];
|
|
255
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
256
|
+
args[_i - 1] = arguments[_i];
|
|
257
|
+
}
|
|
258
|
+
args[1] = wrapTestFunction(args[1], "error");
|
|
259
|
+
return it.apply(void 0, args);
|
|
260
|
+
}
|
|
261
|
+
function withWarningSpy(it) {
|
|
262
|
+
var args = [];
|
|
263
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
264
|
+
args[_i - 1] = arguments[_i];
|
|
265
|
+
}
|
|
266
|
+
args[1] = wrapTestFunction(args[1], "warn");
|
|
267
|
+
return it.apply(void 0, args);
|
|
268
|
+
}
|
|
269
|
+
function withLogSpy(it) {
|
|
270
|
+
var args = [];
|
|
271
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
272
|
+
args[_i - 1] = arguments[_i];
|
|
273
|
+
}
|
|
274
|
+
args[1] = wrapTestFunction(args[1], "log");
|
|
275
|
+
return it.apply(void 0, args);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
exports.MockLink = MockLink;
|
|
279
|
+
exports.MockSubscriptionLink = MockSubscriptionLink;
|
|
280
|
+
exports.createMockClient = createMockClient;
|
|
281
|
+
exports.itAsync = itAsync;
|
|
282
|
+
exports.mockObservableLink = mockObservableLink;
|
|
283
|
+
exports.mockSingleLink = mockSingleLink;
|
|
284
|
+
exports.subscribeAndCount = subscribeAndCount;
|
|
285
|
+
exports.withErrorSpy = withErrorSpy;
|
|
286
|
+
exports.withLogSpy = withLogSpy;
|
|
287
|
+
exports.withWarningSpy = withWarningSpy;
|
|
288
|
+
//# sourceMappingURL=core.cjs.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('../utilities/globals');
|
|
6
|
+
var tslib = require('tslib');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var core$1 = require('../core');
|
|
9
|
+
var cache = require('../cache');
|
|
10
|
+
var context = require('../react/context');
|
|
11
|
+
var core = require('./core');
|
|
12
|
+
|
|
13
|
+
function _interopNamespace(e) {
|
|
14
|
+
if (e && e.__esModule) return e;
|
|
15
|
+
var n = Object.create(null);
|
|
16
|
+
if (e) {
|
|
17
|
+
for (var k in e) {
|
|
18
|
+
n[k] = e[k];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
n["default"] = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
26
|
+
|
|
27
|
+
var MockedProvider = (function (_super) {
|
|
28
|
+
tslib.__extends(MockedProvider, _super);
|
|
29
|
+
function MockedProvider(props) {
|
|
30
|
+
var _this = _super.call(this, props) || this;
|
|
31
|
+
var _a = _this.props, mocks = _a.mocks, addTypename = _a.addTypename, defaultOptions = _a.defaultOptions, cache$1 = _a.cache, resolvers = _a.resolvers, link = _a.link;
|
|
32
|
+
var client = new core$1.ApolloClient({
|
|
33
|
+
cache: cache$1 || new cache.InMemoryCache({ addTypename: addTypename }),
|
|
34
|
+
defaultOptions: defaultOptions,
|
|
35
|
+
link: link || new core.MockLink(mocks || [], addTypename),
|
|
36
|
+
resolvers: resolvers,
|
|
37
|
+
});
|
|
38
|
+
_this.state = { client: client };
|
|
39
|
+
return _this;
|
|
40
|
+
}
|
|
41
|
+
MockedProvider.prototype.render = function () {
|
|
42
|
+
var _a = this.props, children = _a.children, childProps = _a.childProps;
|
|
43
|
+
return React__namespace.isValidElement(children) ? (React__namespace.createElement(context.ApolloProvider, { client: this.state.client }, React__namespace.cloneElement(React__namespace.Children.only(children), tslib.__assign({}, childProps)))) : null;
|
|
44
|
+
};
|
|
45
|
+
MockedProvider.prototype.componentWillUnmount = function () {
|
|
46
|
+
this.state.client.stop();
|
|
47
|
+
};
|
|
48
|
+
MockedProvider.defaultProps = {
|
|
49
|
+
addTypename: true
|
|
50
|
+
};
|
|
51
|
+
return MockedProvider;
|
|
52
|
+
}(React__namespace.Component));
|
|
53
|
+
|
|
54
|
+
exports.MockedProvider = MockedProvider;
|
|
55
|
+
for (var k in core) {
|
|
56
|
+
if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = core[k];
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=testing.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeDeep.d.ts","sourceRoot":"","sources":["../../../src/utilities/common/mergeDeep.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAkB5C,oBAAY,mBAAmB,CAAC,CAAC,SAAS,GAAG,EAAE,IAC7C,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GACvB,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GACpC,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GACjD,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAC9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Y,KACrB,GAAG,CAAC;AAOT,qBAAa,UAAU,CAAC,YAAY,SAAS,GAAG,EAAE;IAE9C,OAAO,CAAC,UAAU;gBAAV,UAAU,GAAE,kBAAkB,CAAC,YAAY,CAAqB;IAGnE,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,EAAE,YAAY,GAAG,GAAG;IA6B9D,QAAQ,yBAAmB;IAElC,OAAO,CAAC,UAAU,CAAkB;IAE7B,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC;CAgB3C"}
|
|
@@ -58,18 +58,15 @@ var DeepMerger = (function () {
|
|
|
58
58
|
};
|
|
59
59
|
DeepMerger.prototype.shallowCopyForMerge = function (value) {
|
|
60
60
|
if (isNonNullObject(value)) {
|
|
61
|
-
if (this.pastCopies.has(value)) {
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
else {
|
|
70
|
-
value = __assign({ __proto__: Object.getPrototypeOf(value) }, value);
|
|
61
|
+
if (!this.pastCopies.has(value)) {
|
|
62
|
+
if (Array.isArray(value)) {
|
|
63
|
+
value = value.slice(0);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
value = __assign({ __proto__: Object.getPrototypeOf(value) }, value);
|
|
67
|
+
}
|
|
68
|
+
this.pastCopies.add(value);
|
|
71
69
|
}
|
|
72
|
-
this.pastCopies.add(value);
|
|
73
70
|
}
|
|
74
71
|
return value;
|
|
75
72
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeDeep.js","sourceRoot":"","sources":["../../../src/utilities/common/mergeDeep.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEpC,IAAA,cAAc,GAAK,MAAM,CAAC,SAAS,eAArB,CAAsB;AAwB5C,MAAM,UAAU,SAAS;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W,EAAE;wBACrC,IAAM,MAAM,GAAG,KAAI,CAAC,UAAU,OAAf,KAAI,iBAAY,MAAM,EAAE,MAAM,EAAE,SAAS,GAAK,OAAO,SAAC,CAAC;wBAGtE,IAAI,MAAM,KAAK,WAAW,EAAE;4BAC1B,MAAM,GAAG,KAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;4BAC1C,MAAM,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC;yBAC5B;qBACF;iBACF;qBAAM;oBAGL,MAAM,GAAG,KAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;oBAC1C,MAAM,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;iBACvC;YACH,CAAC,CAAC,CAAC;YAEH,OAAO,MAAM,CAAC;SACf;QAGD,OAAO,MAAM,CAAC;IAChB,CAAC;IAMM,wCAAmB,GAA1B,UAA8B,KAAQ;QACpC,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE;YAC1B,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;gBAC/B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;oBACxB,KAAK,GAAI,KAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;iBACjC;qBAAM;oBACL,KAAK,cACH,SAAS,EAAE,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,IACpC,KAAK,CACT,CAAC;iBACH;gBACD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;aAC5B;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACH,iBAAC;AAAD,CAAC,AAtDD,IAsDC","sourcesContent":["import { isNonNullObject } from \"./objects\";\n\nconst { hasOwnProperty } = Object.prototype;\n\n// These mergeDeep and mergeDeepArray utilities merge any number of objects\n// together, sharing as much memory as possible with the source objects, while\n// remaining careful to avoid modifying any source objects.\n\n// Logically, the return type of mergeDeep should be the intersection of\n// all the argument types. The binary call signature is by far the most\n// common, but we support 0- through 5-ary as well. After that, the\n// resulting type is just the inferred array element type. Note to nerds:\n// there is a more clever way of doing this that converts the tuple type\n// first to a union type (easy enough: T[number]) and then converts the\n// union to an intersection type using distributive conditional type\n// inference, but that approach has several fatal flaws (boolean becomes\n// true & false, and the inferred type ends up as unknown in many cases),\n// in addition to being nearly impossible to explain/understand.\nexport type TupleToIntersection<T extends any[]> =\n T extends [infer A] ? A :\n T extends [infer A, infer B] ? A & B :\n T extends [infer A, infer B, infer C] ? A & B & C :\n T extends [infer A, infer B, infer C, infer D] ? A & B & C & D :\n T extends [infer A, infer B, infer C, infer D, infer E] ? A & B & C & D & E :\n T extends (infer U)[] ? U : any;\n\nexport function mergeDeep<T extends any[]>(\n ...sources: T\n): TupleToIntersection<T> {\n return mergeDeepArray(sources);\n}\n\n// In almost any situation where you could succeed in getting the\n// TypeScript compiler to infer a tuple type for the sources array, you\n// could just use mergeDeep instead of mergeDeepArray, so instead of\n// trying to convert T[] to an intersection type we just infer the array\n// element type, which works perfectly when the sources array has a\n// consistent element type.\nexport function mergeDeepArray<T>(sources: T[]): T {\n let target = sources[0] || ({} as T);\n const count = sources.length;\n if (count > 1) {\n const merger = new DeepMerger();\n for (let i = 1; i < count; ++i) {\n target = merger.merge(target, sources[i]);\n }\n }\n return target;\n}\n\nexport type ReconcilerFunction<TContextArgs extends any[]> = (\n this: DeepMerger<TContextArgs>,\n target: Record<string | number, any>,\n source: Record<string | number, any>,\n property: string | number,\n ...context: TContextArgs\n) => any;\n\nconst defaultReconciler: ReconcilerFunction<any[]> =\n function (target, source, property) {\n return this.merge(target[property], source[property]);\n };\n\nexport class DeepMerger<TContextArgs extends any[]> {\n constructor(\n private reconciler: ReconcilerFunction<TContextArgs> = defaultReconciler,\n ) {}\n\n public merge(target: any, source: any, ...context: TContextArgs): any {\n if (isNonNullObject(source) && isNonNullObject(target)) {\n Object.keys(source).forEach(sourceKey => {\n if (hasOwnProperty.call(target, sourceKey)) {\n const targetValue = target[sourceKey];\n if (source[sourceKey] !== targetValue) {\n const result = this.reconciler(target, source, sourceKey, ...context);\n // A well-implemented reconciler may return targetValue to indicate\n // the merge changed nothing about the structure of the target.\n if (result !== targetValue) {\n target = this.shallowCopyForMerge(target);\n target[sourceKey] = result;\n }\n }\n } else {\n // If there is no collision, the target can safely share memory with\n // the source, and the recursion can terminate here.\n target = this.shallowCopyForMerge(target);\n target[sourceKey] = source[sourceKey];\n }\n });\n\n return target;\n }\n\n // If source (or target) is not an object, let source replace target.\n return source;\n }\n\n public isObject = isNonNullObject;\n\n private pastCopies = new Set<any>();\n\n public shallowCopyForMerge<T>(value: T): T {\n if (isNonNullObject(value)) {\n if (!this.pastCopies.has(value)) {\n if (Array.isArray(value)) {\n value = (value as any).slice(0);\n } else {\n value = {\n __proto__: Object.getPrototypeOf(value),\n ...value,\n };\n }\n this.pastCopies.add(value);\n }\n }\n return value;\n }\n}\n"]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tsInvariant = require('ts-invariant');
|
|
6
|
+
var process$1 = require('ts-invariant/process');
|
|
7
|
+
var graphql = require('graphql');
|
|
8
|
+
|
|
9
|
+
function maybe(thunk) {
|
|
10
|
+
try {
|
|
11
|
+
return thunk();
|
|
12
|
+
}
|
|
13
|
+
catch (_a) { }
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
var global$1 = (maybe(function () { return globalThis; }) ||
|
|
17
|
+
maybe(function () { return window; }) ||
|
|
18
|
+
maybe(function () { return self; }) ||
|
|
19
|
+
maybe(function () { return global; }) ||
|
|
20
|
+
maybe(function () { return maybe.constructor("return this")(); }));
|
|
21
|
+
|
|
22
|
+
var __ = "__";
|
|
23
|
+
var GLOBAL_KEY = [__, __].join("DEV");
|
|
24
|
+
function getDEV() {
|
|
25
|
+
try {
|
|
26
|
+
return Boolean(__DEV__);
|
|
27
|
+
}
|
|
28
|
+
catch (_a) {
|
|
29
|
+
Object.defineProperty(global$1, GLOBAL_KEY, {
|
|
30
|
+
value: maybe(function () { return process.env.NODE_ENV; }) !== "production",
|
|
31
|
+
enumerable: false,
|
|
32
|
+
configurable: true,
|
|
33
|
+
writable: true,
|
|
34
|
+
});
|
|
35
|
+
return global$1[GLOBAL_KEY];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
var DEV = getDEV();
|
|
39
|
+
|
|
40
|
+
function removeTemporaryGlobals() {
|
|
41
|
+
return typeof graphql.Source === "function" ? process$1.remove() : process$1.remove();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function checkDEV() {
|
|
45
|
+
__DEV__ ? tsInvariant.invariant("boolean" === typeof DEV, DEV) : tsInvariant.invariant("boolean" === typeof DEV, 36);
|
|
46
|
+
}
|
|
47
|
+
removeTemporaryGlobals();
|
|
48
|
+
checkDEV();
|
|
49
|
+
|
|
50
|
+
exports.InvariantError = tsInvariant.InvariantError;
|
|
51
|
+
exports.invariant = tsInvariant.invariant;
|
|
52
|
+
exports.DEV = DEV;
|
|
53
|
+
exports.checkDEV = checkDEV;
|
|
54
|
+
exports.global = global$1;
|
|
55
|
+
exports.maybe = maybe;
|
|
56
|
+
//# sourceMappingURL=globals.cjs.map
|
|
@@ -9,16 +9,18 @@ export declare class Concast<T> extends Observable<T> {
|
|
|
9
9
|
private sources;
|
|
10
10
|
private start;
|
|
11
11
|
private deliverLastMessage;
|
|
12
|
-
private addCount;
|
|
13
12
|
addObserver(observer: Observer<T>): void;
|
|
14
|
-
removeObserver(observer: Observer<T
|
|
13
|
+
removeObserver(observer: Observer<T>): void;
|
|
15
14
|
private resolve;
|
|
16
15
|
private reject;
|
|
17
16
|
readonly promise: Promise<T>;
|
|
18
17
|
private latest?;
|
|
19
18
|
private handlers;
|
|
20
|
-
|
|
19
|
+
private nextResultListeners;
|
|
20
|
+
private notify;
|
|
21
|
+
beforeNext(callback: NextResultListener): void;
|
|
21
22
|
cancel: (reason: any) => void;
|
|
22
23
|
}
|
|
24
|
+
declare type NextResultListener = (method: "next" | "error" | "complete", arg?: any) => any;
|
|
23
25
|
export {};
|
|
24
26
|
//# sourceMappingURL=Concast.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Concast.d.ts","sourceRoot":"","sources":["../../../src/utilities/observables/Concast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAA0B,UAAU,EAAE,MAAM,cAAc,CAAC;AAIxF,aAAK,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;AAOxC,aAAK,MAAM,CAAC,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAE3C,oBAAY,sBAAsB,CAAC,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AA+B5D,qBAAa,OAAO,CAAC,CAAC,CAAE,SAAQ,UAAU,CAAC,CAAC,CAAC;IAI3C,OAAO,CAAC,SAAS,CAA0B;IAM3C,OAAO,CAAC,GAAG,CAAC,CAAgC;gBAIhC,OAAO,EAAE,UAAU,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IA8B1E,OAAO,CAAC,OAAO,CAAc;IAE7B,OAAO,CAAC,KAAK;IAeb,OAAO,CAAC,kBAAkB;
|
|
1
|
+
{"version":3,"file":"Concast.d.ts","sourceRoot":"","sources":["../../../src/utilities/observables/Concast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAA0B,UAAU,EAAE,MAAM,cAAc,CAAC;AAIxF,aAAK,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;AAOxC,aAAK,MAAM,CAAC,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAE3C,oBAAY,sBAAsB,CAAC,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AA+B5D,qBAAa,OAAO,CAAC,CAAC,CAAE,SAAQ,UAAU,CAAC,CAAC,CAAC;IAI3C,OAAO,CAAC,SAAS,CAA0B;IAM3C,OAAO,CAAC,GAAG,CAAC,CAAgC;gBAIhC,OAAO,EAAE,UAAU,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IA8B1E,OAAO,CAAC,OAAO,CAAc;IAE7B,OAAO,CAAC,KAAK;IAeb,OAAO,CAAC,kBAAkB;IAkBnB,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;IASjC,cAAc,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;IAgB3C,OAAO,CAAC,OAAO,CAAwC;IACvD,OAAO,CAAC,MAAM,CAAwB;IACtC,SAAgB,OAAO,aAGpB;IAIH,OAAO,CAAC,MAAM,CAAC,CAA+B;IAI9C,OAAO,CAAC,QAAQ,CAoDd;IAEF,OAAO,CAAC,mBAAmB,CAAiC;IAE5D,OAAO,CAAC,MAAM;IAmBd,UAAU,CAAC,QAAQ,EAAE,kBAAkB;IAWhC,MAAM,WAAY,GAAG,UAI3B;CACF;AAED,aAAK,kBAAkB,GAAG,CACxB,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,UAAU,EACrC,GAAG,CAAC,EAAE,GAAG,KACN,GAAG,CAAC"}
|
|
@@ -13,7 +13,6 @@ var Concast = (function (_super) {
|
|
|
13
13
|
return function () { return _this.removeObserver(observer); };
|
|
14
14
|
}) || this;
|
|
15
15
|
_this.observers = new Set();
|
|
16
|
-
_this.addCount = 0;
|
|
17
16
|
_this.promise = new Promise(function (resolve, reject) {
|
|
18
17
|
_this.resolve = resolve;
|
|
19
18
|
_this.reject = reject;
|
|
@@ -22,6 +21,7 @@ var Concast = (function (_super) {
|
|
|
22
21
|
next: function (result) {
|
|
23
22
|
if (_this.sub !== null) {
|
|
24
23
|
_this.latest = ["next", result];
|
|
24
|
+
_this.notify("next", result);
|
|
25
25
|
iterateObserversSafely(_this.observers, "next", result);
|
|
26
26
|
}
|
|
27
27
|
},
|
|
@@ -33,6 +33,7 @@ var Concast = (function (_super) {
|
|
|
33
33
|
_this.sub = null;
|
|
34
34
|
_this.latest = ["error", error];
|
|
35
35
|
_this.reject(error);
|
|
36
|
+
_this.notify("error", error);
|
|
36
37
|
iterateObserversSafely(_this.observers, "error", error);
|
|
37
38
|
}
|
|
38
39
|
},
|
|
@@ -51,6 +52,7 @@ var Concast = (function (_super) {
|
|
|
51
52
|
else {
|
|
52
53
|
_this.resolve();
|
|
53
54
|
}
|
|
55
|
+
_this.notify("complete");
|
|
54
56
|
iterateObserversSafely(_this.observers, "complete");
|
|
55
57
|
}
|
|
56
58
|
else if (isPromiseLike(value)) {
|
|
@@ -62,6 +64,7 @@ var Concast = (function (_super) {
|
|
|
62
64
|
}
|
|
63
65
|
},
|
|
64
66
|
};
|
|
67
|
+
_this.nextResultListeners = new Set();
|
|
65
68
|
_this.cancel = function (reason) {
|
|
66
69
|
_this.reject(reason);
|
|
67
70
|
_this.sources = [];
|
|
@@ -103,34 +106,29 @@ var Concast = (function (_super) {
|
|
|
103
106
|
if (!this.observers.has(observer)) {
|
|
104
107
|
this.deliverLastMessage(observer);
|
|
105
108
|
this.observers.add(observer);
|
|
106
|
-
++this.addCount;
|
|
107
109
|
}
|
|
108
110
|
};
|
|
109
|
-
Concast.prototype.removeObserver = function (observer
|
|
111
|
+
Concast.prototype.removeObserver = function (observer) {
|
|
110
112
|
if (this.observers.delete(observer) &&
|
|
111
|
-
|
|
112
|
-
!quietly) {
|
|
113
|
+
this.observers.size < 1) {
|
|
113
114
|
this.handlers.complete();
|
|
114
115
|
}
|
|
115
116
|
};
|
|
116
|
-
Concast.prototype.
|
|
117
|
-
var
|
|
117
|
+
Concast.prototype.notify = function (method, arg) {
|
|
118
|
+
var nextResultListeners = this.nextResultListeners;
|
|
119
|
+
if (nextResultListeners.size) {
|
|
120
|
+
this.nextResultListeners = new Set;
|
|
121
|
+
nextResultListeners.forEach(function (listener) { return listener(method, arg); });
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
Concast.prototype.beforeNext = function (callback) {
|
|
118
125
|
var called = false;
|
|
119
|
-
|
|
126
|
+
this.nextResultListeners.add(function (method, arg) {
|
|
120
127
|
if (!called) {
|
|
121
128
|
called = true;
|
|
122
|
-
|
|
123
|
-
callback();
|
|
129
|
+
callback(method, arg);
|
|
124
130
|
}
|
|
125
|
-
};
|
|
126
|
-
var observer = {
|
|
127
|
-
next: once,
|
|
128
|
-
error: once,
|
|
129
|
-
complete: once,
|
|
130
|
-
};
|
|
131
|
-
var count = this.addCount;
|
|
132
|
-
this.addObserver(observer);
|
|
133
|
-
this.addCount = count;
|
|
131
|
+
});
|
|
134
132
|
};
|
|
135
133
|
return Concast;
|
|
136
134
|
}(Observable));
|