graphile-build 4.13.0 → 4.14.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/README.md +4 -13
- package/node8plus/Live.js +14 -71
- package/node8plus/Live.js.map +1 -1
- package/node8plus/SchemaBuilder.js +27 -91
- package/node8plus/SchemaBuilder.js.map +1 -1
- package/node8plus/callbackToAsyncIterator.js +0 -15
- package/node8plus/callbackToAsyncIterator.js.map +1 -1
- package/node8plus/extend.js +0 -9
- package/node8plus/extend.js.map +1 -1
- package/node8plus/index.js +2 -19
- package/node8plus/index.js.map +1 -1
- package/node8plus/makeNewBuild.js +76 -155
- package/node8plus/makeNewBuild.js.map +1 -1
- package/node8plus/plugins/AddQueriesToSubscriptionsPlugin.js +0 -7
- package/node8plus/plugins/AddQueriesToSubscriptionsPlugin.js.map +1 -1
- package/node8plus/plugins/ClientMutationIdDescriptionPlugin.js +2 -9
- package/node8plus/plugins/ClientMutationIdDescriptionPlugin.js.map +1 -1
- package/node8plus/plugins/MutationPayloadQueryPlugin.js +0 -6
- package/node8plus/plugins/MutationPayloadQueryPlugin.js.map +1 -1
- package/node8plus/plugins/MutationPlugin.js +0 -6
- package/node8plus/plugins/MutationPlugin.js.map +1 -1
- package/node8plus/plugins/NodePlugin.js +0 -23
- package/node8plus/plugins/NodePlugin.js.map +1 -1
- package/node8plus/plugins/QueryPlugin.js +0 -5
- package/node8plus/plugins/QueryPlugin.js.map +1 -1
- package/node8plus/plugins/StandardTypesPlugin.js +2 -8
- package/node8plus/plugins/StandardTypesPlugin.js.map +1 -1
- package/node8plus/plugins/SubscriptionPlugin.js +0 -7
- package/node8plus/plugins/SubscriptionPlugin.js.map +1 -1
- package/node8plus/plugins/SwallowErrorsPlugin.js +0 -3
- package/node8plus/plugins/SwallowErrorsPlugin.js.map +1 -1
- package/node8plus/plugins/TrimEmptyDescriptionsPlugin.js +0 -10
- package/node8plus/plugins/TrimEmptyDescriptionsPlugin.js.map +1 -1
- package/node8plus/plugins/index.js +0 -11
- package/node8plus/plugins/index.js.map +1 -1
- package/node8plus/resolveNode.js +0 -5
- package/node8plus/resolveNode.js.map +1 -1
- package/node8plus/swallowError.js +0 -6
- package/node8plus/swallowError.js.map +1 -1
- package/node8plus/utils.js +7 -31
- package/node8plus/utils.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -26,26 +26,17 @@ module contains the plugins that are specific to PostgreSQL support
|
|
|
26
26
|
|
|
27
27
|
## Crowd-funded open-source software
|
|
28
28
|
|
|
29
|
-
To help us develop this software sustainably
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
To help us develop this software sustainably, we ask all individuals and
|
|
30
|
+
businesses that use it to help support its ongoing maintenance and development
|
|
31
|
+
via sponsorship.
|
|
32
32
|
|
|
33
33
|
### [Click here to find out more about sponsors and sponsorship.](https://www.graphile.org/sponsor/)
|
|
34
34
|
|
|
35
35
|
And please give some love to our featured sponsors 🤩:
|
|
36
36
|
|
|
37
37
|
<table><tr>
|
|
38
|
-
<td align="center"><a href="https://surge.io/"><img src="https://graphile.org/images/sponsors/surge.png" width="90" height="90" alt="Surge" /><br />Surge</a> *</td>
|
|
39
|
-
<td align="center"><a href="https://www.netflix.com/"><img src="https://graphile.org/images/sponsors/Netflix.png" width="90" height="90" alt="Netflix" /><br />Netflix</a> *</td>
|
|
40
|
-
<td align="center"><a href="https://qwick.com/"><img src="https://graphile.org/images/sponsors/qwick.png" width="90" height="90" alt="Qwick" /><br />Qwick</a> *</td>
|
|
41
38
|
<td align="center"><a href="https://www.the-guild.dev/"><img src="https://graphile.org/images/sponsors/theguild.png" width="90" height="90" alt="The Guild" /><br />The Guild</a> *</td>
|
|
42
|
-
</
|
|
43
|
-
<td align="center"><a href="http://chads.website"><img src="https://graphile.org/images/sponsors/chadf.png" width="90" height="90" alt="Chad Furman" /><br />Chad Furman</a> *</td>
|
|
44
|
-
<td align="center"><a href="https://www.fanatics.com/"><img src="https://graphile.org/images/sponsors/fanatics.png" width="90" height="90" alt="Fanatics" /><br />Fanatics</a> *</td>
|
|
45
|
-
<td align="center"><a href="https://dovetailapp.com/"><img src="https://graphile.org/images/sponsors/dovetail.png" width="90" height="90" alt="Dovetail" /><br />Dovetail</a> *</td>
|
|
46
|
-
<td align="center"><a href="https://www.enzuzo.com/"><img src="https://graphile.org/images/sponsors/enzuzo.png" width="90" height="90" alt="Enzuzo" /><br />Enzuzo</a> *</td>
|
|
47
|
-
</tr><tr>
|
|
48
|
-
<td align="center"><a href="https://stellate.co/"><img src="https://graphile.org/images/sponsors/Stellate.png" width="90" height="90" alt="Stellate" /><br />Stellate</a> *</td>
|
|
39
|
+
<td align="center"><a href="https://gosteelhead.com/"><img src="https://graphile.org/images/sponsors/steelhead.svg" width="90" height="90" alt="Steelhead" /><br />Steelhead</a> *</td>
|
|
49
40
|
</tr></table>
|
|
50
41
|
|
|
51
42
|
<em>\* Sponsors the entire Graphile suite</em>
|
package/node8plus/Live.js
CHANGED
|
@@ -5,68 +5,54 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.LiveSource = exports.LiveProvider = exports.LiveMonitor = exports.LiveCoordinator = void 0;
|
|
7
7
|
exports.makeAsyncIteratorFromMonitor = makeAsyncIteratorFromMonitor;
|
|
8
|
-
|
|
9
8
|
var _callbackToAsyncIterator = _interopRequireDefault(require("./callbackToAsyncIterator"));
|
|
10
|
-
|
|
11
9
|
var _lodash = require("lodash");
|
|
12
|
-
|
|
13
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
|
|
15
11
|
/* eslint-disable flowtype/no-weak-types */
|
|
16
12
|
const DEBOUNCE_DURATION = 25;
|
|
17
13
|
const MONITOR_THROTTLE_DURATION = Math.max(DEBOUNCE_DURATION + 1, parseInt(process.env.LIVE_THROTTLE || "", 10) || 500);
|
|
14
|
+
|
|
18
15
|
/*
|
|
19
16
|
* Sources are long-lived (i.e. in "watch" mode you just re-use the same one
|
|
20
17
|
* over and over) because there is no release for them
|
|
21
18
|
*/
|
|
22
|
-
|
|
23
19
|
class LiveSource {
|
|
24
20
|
subscribeCollection(_callback, _collectionIdentifier, _predicate) {
|
|
25
21
|
return null;
|
|
26
22
|
}
|
|
27
|
-
|
|
28
23
|
subscribeRecord(_callback, _collectionIdentifier, _recordIdentifier) {
|
|
29
24
|
return null;
|
|
30
25
|
}
|
|
31
|
-
|
|
32
26
|
}
|
|
27
|
+
|
|
33
28
|
/*
|
|
34
29
|
* Providers enable a namespace, perform validation, and track the sources used
|
|
35
30
|
* by that namespace within one single schema build. The should not directly use
|
|
36
31
|
* any long-lived features as they do not have an explicit "release"/"close"
|
|
37
32
|
* command when a new schema is built.
|
|
38
33
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
34
|
exports.LiveSource = LiveSource;
|
|
42
|
-
|
|
43
35
|
class LiveProvider {
|
|
44
36
|
constructor(namespace) {
|
|
45
37
|
this.namespace = namespace;
|
|
46
38
|
this.sources = [];
|
|
47
39
|
}
|
|
48
|
-
|
|
49
40
|
registerSource(source) {
|
|
50
41
|
this.sources.push(source);
|
|
51
42
|
}
|
|
52
|
-
|
|
53
43
|
collectionIdentifierIsValid(_collectionIdentifier) {
|
|
54
44
|
return false;
|
|
55
45
|
}
|
|
56
|
-
|
|
57
46
|
recordIdentifierIsValid(_collectionIdentifier, _recordIdentifier) {
|
|
58
47
|
return false;
|
|
59
48
|
}
|
|
60
|
-
|
|
61
49
|
}
|
|
50
|
+
|
|
62
51
|
/*
|
|
63
52
|
* During a single execution of GraphQL (specifically a subscription request),
|
|
64
53
|
* the LiveMonitor tracks the resources viewed and subscribes to updates in them.
|
|
65
54
|
*/
|
|
66
|
-
|
|
67
|
-
|
|
68
55
|
exports.LiveProvider = LiveProvider;
|
|
69
|
-
|
|
70
56
|
class LiveMonitor {
|
|
71
57
|
constructor(providers, extraRootValue) {
|
|
72
58
|
this.extraRootValue = extraRootValue;
|
|
@@ -76,7 +62,6 @@ class LiveMonitor {
|
|
|
76
62
|
this.changeCallback = null;
|
|
77
63
|
this.changeCounter = 0;
|
|
78
64
|
this.liveConditionsByCounter = {};
|
|
79
|
-
|
|
80
65
|
this.handleChange = function () {
|
|
81
66
|
/* This function is throttled to ~25ms (see constructor); it's purpose is
|
|
82
67
|
* to bundle up all the changes that occur in a small window into the same
|
|
@@ -89,7 +74,6 @@ class LiveMonitor {
|
|
|
89
74
|
this._reallyHandleChange();
|
|
90
75
|
}
|
|
91
76
|
};
|
|
92
|
-
|
|
93
77
|
this._reallyHandleChange = function () {
|
|
94
78
|
// This function is throttled to MONITOR_THROTTLE_DURATION (see constructor)
|
|
95
79
|
if (this.changeCallback) {
|
|
@@ -103,10 +87,10 @@ class LiveMonitor {
|
|
|
103
87
|
* ones. To achieve this, we use a custom `subscribe` function which
|
|
104
88
|
* calls `rootValue.release()` once the result set has been calculated.
|
|
105
89
|
*/
|
|
106
|
-
|
|
107
90
|
this.subscriptionReleasersByCounter[String(counter)] = [];
|
|
108
91
|
this.liveConditionsByCounter[String(counter)] = [];
|
|
109
|
-
const changeRootValue = {
|
|
92
|
+
const changeRootValue = {
|
|
93
|
+
...this.extraRootValue,
|
|
110
94
|
counter,
|
|
111
95
|
liveCollection: this.liveCollection.bind(this, counter),
|
|
112
96
|
liveRecord: this.liveRecord.bind(this, counter),
|
|
@@ -122,183 +106,145 @@ class LiveMonitor {
|
|
|
122
106
|
console.warn("Change occurred, but no-one was listening");
|
|
123
107
|
}
|
|
124
108
|
};
|
|
125
|
-
|
|
126
109
|
this.onChange = function (callback) {
|
|
127
110
|
if (this.released) {
|
|
128
111
|
throw new Error("Monitors cannot be reused.");
|
|
129
112
|
}
|
|
130
|
-
|
|
131
113
|
if (this.changeCallback) {
|
|
132
114
|
throw new Error("Already monitoring for changes");
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
115
|
+
}
|
|
116
|
+
// Throttle to every 250ms
|
|
136
117
|
this.changeCallback = callback;
|
|
137
|
-
|
|
138
118
|
if (this.handleChange) {
|
|
139
119
|
setImmediate(this.handleChange);
|
|
140
120
|
}
|
|
141
|
-
|
|
142
121
|
return () => {
|
|
143
122
|
if (this.changeCallback === callback) {
|
|
144
123
|
this.changeCallback = null;
|
|
145
124
|
}
|
|
146
|
-
|
|
147
125
|
this.release();
|
|
148
126
|
};
|
|
149
127
|
};
|
|
150
|
-
|
|
151
128
|
this.handleChange = (0, _lodash.throttle)(this.handleChange.bind(this), DEBOUNCE_DURATION, {
|
|
152
129
|
leading: false,
|
|
153
130
|
trailing: true
|
|
154
131
|
});
|
|
155
|
-
|
|
156
132
|
if (!this._reallyHandleChange) {
|
|
157
133
|
throw new Error("This is just to make flow happy");
|
|
158
134
|
}
|
|
159
|
-
|
|
160
135
|
this._reallyHandleChange = (0, _lodash.throttle)(this._reallyHandleChange.bind(this), MONITOR_THROTTLE_DURATION - DEBOUNCE_DURATION, {
|
|
161
136
|
leading: true,
|
|
162
137
|
trailing: true
|
|
163
138
|
});
|
|
164
139
|
this.onChange = this.onChange.bind(this);
|
|
165
140
|
}
|
|
166
|
-
|
|
167
141
|
resetBefore(currentCounter) {
|
|
168
142
|
// Clear out of date subscriptionReleasers
|
|
169
143
|
{
|
|
170
144
|
const oldCounters = Object.keys(this.subscriptionReleasersByCounter).filter(n => parseInt(n, 10) < currentCounter);
|
|
171
|
-
|
|
172
145
|
for (const oldCounter of oldCounters) {
|
|
173
146
|
for (const releaser of this.subscriptionReleasersByCounter[oldCounter]) {
|
|
174
147
|
releaser();
|
|
175
148
|
}
|
|
176
|
-
|
|
177
149
|
delete this.subscriptionReleasersByCounter[oldCounter];
|
|
178
150
|
}
|
|
179
|
-
}
|
|
180
|
-
|
|
151
|
+
}
|
|
152
|
+
// Clear out of date liveConditions
|
|
181
153
|
{
|
|
182
154
|
const oldCounters = Object.keys(this.liveConditionsByCounter).filter(n => parseInt(n, 10) < currentCounter);
|
|
183
|
-
|
|
184
155
|
for (const oldCounter of oldCounters) {
|
|
185
156
|
delete this.liveConditionsByCounter[oldCounter];
|
|
186
157
|
}
|
|
187
158
|
}
|
|
188
159
|
}
|
|
189
|
-
|
|
190
160
|
release() {
|
|
191
161
|
if (this.handleChange) {
|
|
192
162
|
// $FlowFixMe: throttled function
|
|
193
163
|
this.handleChange.cancel();
|
|
194
164
|
}
|
|
195
|
-
|
|
196
165
|
this.handleChange = null;
|
|
197
|
-
|
|
198
166
|
if (this._reallyHandleChange) {
|
|
199
167
|
// $FlowFixMe: throttled function
|
|
200
168
|
this._reallyHandleChange.cancel();
|
|
201
169
|
}
|
|
202
|
-
|
|
203
170
|
this._reallyHandleChange = null;
|
|
204
171
|
this.resetBefore(Infinity);
|
|
205
172
|
this.providers = {};
|
|
206
173
|
this.released = true;
|
|
207
174
|
}
|
|
208
|
-
|
|
209
175
|
liveCollection(counter, namespace, collectionIdentifier, predicate = () => true) {
|
|
210
176
|
const handleChange = this.handleChange;
|
|
211
|
-
|
|
212
177
|
if (this.released || !handleChange) {
|
|
213
178
|
return;
|
|
214
179
|
}
|
|
215
|
-
|
|
216
180
|
const provider = this.providers[namespace];
|
|
217
181
|
if (!provider || provider.sources.length === 0) return;
|
|
218
|
-
|
|
219
182
|
if (!provider.collectionIdentifierIsValid(collectionIdentifier)) {
|
|
220
183
|
throw new Error(`Invalid collection identifier passed to LiveMonitor[${namespace}]: ${collectionIdentifier}`);
|
|
221
184
|
}
|
|
222
|
-
|
|
223
185
|
for (const source of provider.sources) {
|
|
224
186
|
const releaser = source.subscribeCollection(handleChange, collectionIdentifier, predicate);
|
|
225
|
-
|
|
226
187
|
if (releaser) {
|
|
227
188
|
this.subscriptionReleasersByCounter[String(counter)].push(releaser);
|
|
228
189
|
}
|
|
229
190
|
}
|
|
230
191
|
}
|
|
231
|
-
|
|
232
192
|
liveRecord(counter, namespace, collectionIdentifier, recordIdentifier) {
|
|
233
193
|
const handleChange = this.handleChange;
|
|
234
|
-
|
|
235
194
|
if (this.released || !handleChange) {
|
|
236
195
|
return;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
|
|
196
|
+
}
|
|
197
|
+
// TODO: if (recordIdentifier == null) {return}
|
|
240
198
|
const provider = this.providers[namespace];
|
|
241
199
|
if (!provider || provider.sources.length === 0) return;
|
|
242
|
-
|
|
243
200
|
if (!provider.collectionIdentifierIsValid(collectionIdentifier)) {
|
|
244
201
|
throw new Error(`Invalid collection identifier passed to LiveMonitor[${namespace}]: ${collectionIdentifier}`);
|
|
245
202
|
}
|
|
246
|
-
|
|
247
203
|
if (!provider.recordIdentifierIsValid(collectionIdentifier, recordIdentifier)) {
|
|
248
204
|
throw new Error(`Invalid record identifier passed to LiveMonitor[${namespace}]: ${collectionIdentifier}`);
|
|
249
205
|
}
|
|
250
|
-
|
|
251
206
|
for (const source of provider.sources) {
|
|
252
207
|
const releaser = source.subscribeRecord(handleChange, collectionIdentifier, recordIdentifier);
|
|
253
|
-
|
|
254
208
|
if (releaser) {
|
|
255
209
|
this.subscriptionReleasersByCounter[String(counter)].push(releaser);
|
|
256
210
|
}
|
|
257
211
|
}
|
|
258
212
|
}
|
|
259
|
-
|
|
260
213
|
}
|
|
214
|
+
|
|
261
215
|
/*
|
|
262
216
|
* There is one coordinator for each build of the GraphQL schema, it tracks the providers
|
|
263
217
|
* and gives a handy `subscribe` method that can be used for live queries (assuming
|
|
264
218
|
* that the `resolve` is provided the same as in a Query).
|
|
265
219
|
*/
|
|
266
|
-
|
|
267
|
-
|
|
268
220
|
exports.LiveMonitor = LiveMonitor;
|
|
269
|
-
|
|
270
221
|
class LiveCoordinator {
|
|
271
222
|
constructor() {
|
|
272
223
|
this.providers = {};
|
|
273
224
|
this.subscribe = this.subscribe.bind(this);
|
|
274
225
|
}
|
|
275
|
-
|
|
276
226
|
registerProvider(provider) {
|
|
277
227
|
const {
|
|
278
228
|
namespace
|
|
279
229
|
} = provider;
|
|
280
|
-
|
|
281
230
|
if (this.providers[namespace]) {
|
|
282
231
|
throw new Error(`Namespace ${namespace} already registered with Live`);
|
|
283
232
|
}
|
|
284
|
-
|
|
285
233
|
this.providers[namespace] = provider;
|
|
286
234
|
}
|
|
287
|
-
|
|
288
235
|
registerSource(namespace, source) {
|
|
289
236
|
if (!this.providers[namespace]) {
|
|
290
237
|
// eslint-disable-next-line no-console
|
|
291
238
|
console.warn(`LiveProvider '${namespace}' is not registered, skipping live source.`);
|
|
292
239
|
return;
|
|
293
240
|
}
|
|
294
|
-
|
|
295
241
|
this.providers[namespace].registerSource(source);
|
|
296
242
|
}
|
|
297
|
-
|
|
298
243
|
getMonitor(extraRootValue) {
|
|
299
244
|
return new LiveMonitor(this.providers, extraRootValue);
|
|
300
|
-
}
|
|
245
|
+
}
|
|
301
246
|
|
|
247
|
+
// Tell Flow that we're okay with overwriting this
|
|
302
248
|
|
|
303
249
|
subscribe(_parent, _args, _context, _info) {
|
|
304
250
|
const monitor = this.getMonitor({
|
|
@@ -309,11 +255,8 @@ class LiveCoordinator {
|
|
|
309
255
|
const iterator = makeAsyncIteratorFromMonitor(monitor);
|
|
310
256
|
return iterator;
|
|
311
257
|
}
|
|
312
|
-
|
|
313
258
|
}
|
|
314
|
-
|
|
315
259
|
exports.LiveCoordinator = LiveCoordinator;
|
|
316
|
-
|
|
317
260
|
function makeAsyncIteratorFromMonitor(monitor) {
|
|
318
261
|
return (0, _callbackToAsyncIterator.default)(monitor.onChange, {
|
|
319
262
|
onClose: release => {
|
package/node8plus/Live.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Live.js"],"names":["DEBOUNCE_DURATION","MONITOR_THROTTLE_DURATION","Math","max","parseInt","process","env","LIVE_THROTTLE","LiveSource","subscribeCollection","_callback","_collectionIdentifier","_predicate","subscribeRecord","_recordIdentifier","LiveProvider","constructor","namespace","sources","registerSource","source","push","collectionIdentifierIsValid","recordIdentifierIsValid","LiveMonitor","providers","extraRootValue","released","subscriptionReleasersByCounter","changeCallback","changeCounter","liveConditionsByCounter","handleChange","_reallyHandleChange","cb","counter","String","changeRootValue","liveCollection","bind","liveRecord","liveConditions","release","resetBefore","console","warn","onChange","callback","Error","setImmediate","leading","trailing","currentCounter","oldCounters","Object","keys","filter","n","oldCounter","releaser","cancel","Infinity","collectionIdentifier","predicate","provider","length","recordIdentifier","LiveCoordinator","subscribe","registerProvider","getMonitor","_parent","_args","_context","_info","monitor","liveAbort","e","iterator","throw","makeAsyncIteratorFromMonitor","onClose"],"mappings":";;;;;;;;AAEA;;AAEA;;;;AAHA;AAWA,MAAMA,iBAAiB,GAAG,EAA1B;AAEA,MAAMC,yBAAyB,GAAGC,IAAI,CAACC,GAAL,CAChCH,iBAAiB,GAAG,CADY,EAEhCI,QAAQ,CAACC,OAAO,CAACC,GAAR,CAAYC,aAAZ,IAA6B,EAA9B,EAAkC,EAAlC,CAAR,IAAiD,GAFjB,CAAlC;AAKA;AACA;AACA;AACA;;AACO,MAAMC,UAAN,CAAiB;AACtBC,EAAAA,mBAAmB,CACjBC,SADiB,EAEjBC,qBAFiB,EAGjBC,UAHiB,EAIY;AAC7B,WAAO,IAAP;AACD;;AAEDC,EAAAA,eAAe,CACbH,SADa,EAEbC,qBAFa,EAGbG,iBAHa,EAIgB;AAC7B,WAAO,IAAP;AACD;;AAfqB;AAkBxB;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMC,YAAN,CAAmB;AAIxBC,EAAAA,WAAW,CAACC,SAAD,EAAoB;AAC7B,SAAKA,SAAL,GAAiBA,SAAjB;AACA,SAAKC,OAAL,GAAe,EAAf;AACD;;AAEDC,EAAAA,cAAc,CAACC,MAAD,EAAqB;AACjC,SAAKF,OAAL,CAAaG,IAAb,CAAkBD,MAAlB;AACD;;AAEDE,EAAAA,2BAA2B,CAACX,qBAAD,EAAsC;AAC/D,WAAO,KAAP;AACD;;AAEDY,EAAAA,uBAAuB,CACrBZ,qBADqB,EAErBG,iBAFqB,EAGZ;AACT,WAAO,KAAP;AACD;;AAtBuB;AAyB1B;AACA;AACA;AACA;;;;;AACO,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A0C,EAAAA,SAAS,CACPG,OADO,EAEPC,KAFO,EAGPC,QAHO,EAIPC,KAJO,EAKP;AACA,UAAMC,OAAO,GAAG,KAAKL,UAAL,CAAgB;AAC9BM,MAAAA,SAAS,EAAEC,CAAC,IAAI;AACd,YAAIC,QAAJ,EAAcA,QAAQ,CAACC,KAAT,CAAeF,CAAf;AACf;AAH6B,KAAhB,CAAhB;AAKA,UAAMC,QAAQ,GAAGE,4BAA4B,CAACL,OAAD,CAA7C;AACA,WAAOG,QAAP;AACD;;AAnD0B;;;;AAsDtB,SAASE,4BAAT,CAAsCL,OAAtC,EAA4D;AACjE,SAAO,sCAAwBA,OAAO,CAAC7B,QAAhC,EAA0C;AAC/CmC,IAAAA,OAAO,EAAEvC,OAAO,IAAI;AAClB,UAAIA,OAAJ,EAAaA,OAAO;AACrB;AAH8C,GAA1C,CAAP;AAKD","sourcesContent":["// @flow\n/* eslint-disable flowtype/no-weak-types */\nimport callbackToAsyncIterator from \"./callbackToAsyncIterator\";\nimport type { GraphQLResolveInfo } from \"graphql\";\nimport { throttle } from \"lodash\";\n\ntype SubscriptionReleaser = () => void;\ntype SubscriptionCallback = () => void;\n\ntype Predicate = (record: any) => boolean;\ntype PredicateGenerator = (data: any) => Predicate;\n\nconst DEBOUNCE_DURATION = 25;\n\nconst MONITOR_THROTTLE_DURATION = Math.max(\n DEBOUNCE_DURATION + 1,\n parseInt(process.env.LIVE_THROTTLE || \"\", 10) || 500\n);\n\n/*\n * Sources are long-lived (i.e. in \"watch\" mode you just re-use the same one\n * over and over) because there is no release for them\n */\nexport class LiveSource {\n subscribeCollection(\n _callback: SubscriptionCallback,\n _collectionIdentifier: any,\n _predicate?: Predicate\n ): SubscriptionReleaser | null {\n return null;\n }\n\n subscribeRecord(\n _callback: SubscriptionCallback,\n _collectionIdentifier: any,\n _recordIdentifier: any\n ): SubscriptionReleaser | null {\n return null;\n }\n}\n\n/*\n * Providers enable a namespace, perform validation, and track the sources used\n * by that namespace within one single schema build. The should not directly use\n * any long-lived features as they do not have an explicit \"release\"/\"close\"\n * command when a new schema is built.\n */\nexport class LiveProvider {\n sources: Array<LiveSource>;\n namespace: string;\n\n constructor(namespace: string) {\n this.namespace = namespace;\n this.sources = [];\n }\n\n registerSource(source: LiveSource) {\n this.sources.push(source);\n }\n\n collectionIdentifierIsValid(_collectionIdentifier: any): boolean {\n return false;\n }\n\n recordIdentifierIsValid(\n _collectionIdentifier: any,\n _recordIdentifier: any\n ): boolean {\n return false;\n }\n}\n\n/*\n * During a single execution of GraphQL (specifically a subscription request),\n * the LiveMonitor tracks the resources viewed and subscribes to updates in them.\n */\nexport class LiveMonitor {\n released: boolean;\n providers: { [namespace: string]: LiveProvider };\n subscriptionReleasersByCounter: {\n [counter: string]: (() => void)[],\n };\n liveConditionsByCounter: { [counter: string]: Array<PredicateGenerator> };\n changeCallback: ((arg: any) => void) | null;\n changeCounter: number;\n extraRootValue: any;\n\n handleChange: (() => void) | null;\n _reallyHandleChange: (() => void) | null;\n onChange: (callback: () => void) => () => void;\n\n constructor(\n providers: { [namespace: string]: LiveProvider },\n extraRootValue: any\n ) {\n this.extraRootValue = extraRootValue;\n this.released = false;\n this.providers = providers;\n this.subscriptionReleasersByCounter = {};\n this.changeCallback = null;\n this.changeCounter = 0;\n this.liveConditionsByCounter = {};\n this.handleChange = function () {\n /* This function is throttled to ~25ms (see constructor); it's purpose is\n * to bundle up all the changes that occur in a small window into the same\n * handle change flow, so _reallyHandleChange doesn't get called twice in\n * quick succession. _reallyHandleChange is then further throttled with a\n * larger window, BUT it triggers on both leading and trailing edge,\n * whereas this only triggers on the trailing edge.\n */\n if (this._reallyHandleChange) {\n this._reallyHandleChange();\n }\n };\n\n this._reallyHandleChange = function () {\n // This function is throttled to MONITOR_THROTTLE_DURATION (see constructor)\n if (this.changeCallback) {\n // Convince Flow this won't suddenly become null\n const cb = this.changeCallback;\n const counter = this.changeCounter++;\n /*\n * In live queries we need to know when the current result set has\n * finished being calculated so that we know we've received all the\n * liveRecord / liveCollection calls and can release the out of date\n * ones. To achieve this, we use a custom `subscribe` function which\n * calls `rootValue.release()` once the result set has been calculated.\n */\n this.subscriptionReleasersByCounter[String(counter)] = [];\n this.liveConditionsByCounter[String(counter)] = [];\n const changeRootValue = {\n ...this.extraRootValue,\n counter,\n liveCollection: this.liveCollection.bind(this, counter),\n liveRecord: this.liveRecord.bind(this, counter),\n liveConditions: this.liveConditionsByCounter[String(counter)],\n release: () => {\n // Despite it's name, this means that the execution has complete, which means we're actually releasing everything *before* this.\n this.resetBefore(counter);\n },\n };\n cb(changeRootValue);\n } else {\n // eslint-disable-next-line no-console\n console.warn(\"Change occurred, but no-one was listening\");\n }\n };\n\n this.onChange = function (callback: () => void) {\n if (this.released) {\n throw new Error(\"Monitors cannot be reused.\");\n }\n if (this.changeCallback) {\n throw new Error(\"Already monitoring for changes\");\n }\n // Throttle to every 250ms\n this.changeCallback = callback;\n if (this.handleChange) {\n setImmediate(this.handleChange);\n }\n return () => {\n if (this.changeCallback === callback) {\n this.changeCallback = null;\n }\n this.release();\n };\n };\n\n this.handleChange = throttle(\n this.handleChange.bind(this),\n DEBOUNCE_DURATION,\n {\n leading: false,\n trailing: true,\n }\n );\n if (!this._reallyHandleChange) {\n throw new Error(\"This is just to make flow happy\");\n }\n this._reallyHandleChange = throttle(\n this._reallyHandleChange.bind(this),\n MONITOR_THROTTLE_DURATION - DEBOUNCE_DURATION,\n {\n leading: true,\n trailing: true,\n }\n );\n this.onChange = this.onChange.bind(this);\n }\n\n resetBefore(currentCounter: number) {\n // Clear out of date subscriptionReleasers\n {\n const oldCounters = Object.keys(\n this.subscriptionReleasersByCounter\n ).filter(n => parseInt(n, 10) < currentCounter);\n for (const oldCounter of oldCounters) {\n for (const releaser of this.subscriptionReleasersByCounter[\n oldCounter\n ]) {\n releaser();\n }\n delete this.subscriptionReleasersByCounter[oldCounter];\n }\n }\n // Clear out of date liveConditions\n {\n const oldCounters = Object.keys(this.liveConditionsByCounter).filter(\n n => parseInt(n, 10) < currentCounter\n );\n for (const oldCounter of oldCounters) {\n delete this.liveConditionsByCounter[oldCounter];\n }\n }\n }\n\n release() {\n if (this.handleChange) {\n // $FlowFixMe: throttled function\n this.handleChange.cancel();\n }\n this.handleChange = null;\n if (this._reallyHandleChange) {\n // $FlowFixMe: throttled function\n this._reallyHandleChange.cancel();\n }\n this._reallyHandleChange = null;\n this.resetBefore(Infinity);\n this.providers = {};\n this.released = true;\n }\n\n liveCollection(\n counter: number,\n namespace: string,\n collectionIdentifier: any,\n predicate: (record: any) => boolean = () => true\n ) {\n const handleChange = this.handleChange;\n if (this.released || !handleChange) {\n return;\n }\n const provider = this.providers[namespace];\n if (!provider || provider.sources.length === 0) return;\n if (!provider.collectionIdentifierIsValid(collectionIdentifier)) {\n throw new Error(\n `Invalid collection identifier passed to LiveMonitor[${namespace}]: ${collectionIdentifier}`\n );\n }\n for (const source of provider.sources) {\n const releaser = source.subscribeCollection(\n handleChange,\n collectionIdentifier,\n predicate\n );\n if (releaser) {\n this.subscriptionReleasersByCounter[String(counter)].push(releaser);\n }\n }\n }\n\n liveRecord(\n counter: number,\n namespace: string,\n collectionIdentifier: any,\n recordIdentifier: any\n ) {\n const handleChange = this.handleChange;\n if (this.released || !handleChange) {\n return;\n }\n // TODO: if (recordIdentifier == null) {return}\n const provider = this.providers[namespace];\n if (!provider || provider.sources.length === 0) return;\n if (!provider.collectionIdentifierIsValid(collectionIdentifier)) {\n throw new Error(\n `Invalid collection identifier passed to LiveMonitor[${namespace}]: ${collectionIdentifier}`\n );\n }\n if (\n !provider.recordIdentifierIsValid(collectionIdentifier, recordIdentifier)\n ) {\n throw new Error(\n `Invalid record identifier passed to LiveMonitor[${namespace}]: ${collectionIdentifier}`\n );\n }\n for (const source of provider.sources) {\n const releaser = source.subscribeRecord(\n handleChange,\n collectionIdentifier,\n recordIdentifier\n );\n if (releaser) {\n this.subscriptionReleasersByCounter[String(counter)].push(releaser);\n }\n }\n }\n}\n\n/*\n * There is one coordinator for each build of the GraphQL schema, it tracks the providers\n * and gives a handy `subscribe` method that can be used for live queries (assuming\n * that the `resolve` is provided the same as in a Query).\n */\nexport class LiveCoordinator {\n providers: { [namespace: string]: LiveProvider };\n\n constructor() {\n this.providers = {};\n this.subscribe = this.subscribe.bind(this);\n }\n\n registerProvider(provider: LiveProvider) {\n const { namespace } = provider;\n if (this.providers[namespace]) {\n throw new Error(`Namespace ${namespace} already registered with Live`);\n }\n this.providers[namespace] = provider;\n }\n\n registerSource(namespace: string, source: LiveSource) {\n if (!this.providers[namespace]) {\n // eslint-disable-next-line no-console\n console.warn(\n `LiveProvider '${namespace}' is not registered, skipping live source.`\n );\n return;\n }\n this.providers[namespace].registerSource(source);\n }\n\n getMonitor(extraRootValue: any) {\n return new LiveMonitor(this.providers, extraRootValue);\n }\n\n // Tell Flow that we're okay with overwriting this\n subscribe: (\n _parent: any,\n _args: any,\n context: any,\n _info: GraphQLResolveInfo\n ) => any;\n subscribe(\n _parent: any,\n _args: any,\n _context: any,\n _info: GraphQLResolveInfo\n ) {\n const monitor = this.getMonitor({\n liveAbort: e => {\n if (iterator) iterator.throw(e);\n },\n });\n const iterator = makeAsyncIteratorFromMonitor(monitor);\n return iterator;\n }\n}\n\nexport function makeAsyncIteratorFromMonitor(monitor: LiveMonitor) {\n return callbackToAsyncIterator(monitor.onChange, {\n onClose: release => {\n if (release) release();\n },\n });\n}\n"],"file":"Live.js"}
|
|
1
|
+
{"version":3,"file":"Live.js","names":["_callbackToAsyncIterator","_interopRequireDefault","require","_lodash","obj","__esModule","default","DEBOUNCE_DURATION","MONITOR_THROTTLE_DURATION","Math","max","parseInt","process","env","LIVE_THROTTLE","LiveSource","subscribeCollection","_callback","_collectionIdentifier","_predicate","subscribeRecord","_recordIdentifier","exports","LiveProvider","constructor","namespace","sources","registerSource","source","push","collectionIdentifierIsValid","recordIdentifierIsValid","LiveMonitor","providers","extraRootValue","released","subscriptionReleasersByCounter","changeCallback","changeCounter","liveConditionsByCounter","handleChange","_reallyHandleChange","cb","counter","String","changeRootValue","liveCollection","bind","liveRecord","liveConditions","release","resetBefore","console","warn","onChange","callback","Error","setImmediate","throttle","leading","trailing","currentCounter","oldCounters","Object","keys","filter","n","oldCounter","releaser","cancel","Infinity","collectionIdentifier","predicate","provider","length","recordIdentifier","LiveCoordinator","subscribe","registerProvider","getMonitor","_parent","_args","_context","_info","monitor","liveAbort","e","iterator","throw","makeAsyncIteratorFromMonitor","callbackToAsyncIterator","onClose"],"sources":["../src/Live.js"],"sourcesContent":["// @flow\n/* eslint-disable flowtype/no-weak-types */\nimport callbackToAsyncIterator from \"./callbackToAsyncIterator\";\nimport type { GraphQLResolveInfo } from \"graphql\";\nimport { throttle } from \"lodash\";\n\ntype SubscriptionReleaser = () => void;\ntype SubscriptionCallback = () => void;\n\ntype Predicate = (record: any) => boolean;\ntype PredicateGenerator = (data: any) => Predicate;\n\nconst DEBOUNCE_DURATION = 25;\n\nconst MONITOR_THROTTLE_DURATION = Math.max(\n DEBOUNCE_DURATION + 1,\n parseInt(process.env.LIVE_THROTTLE || \"\", 10) || 500\n);\n\n/*\n * Sources are long-lived (i.e. in \"watch\" mode you just re-use the same one\n * over and over) because there is no release for them\n */\nexport class LiveSource {\n subscribeCollection(\n _callback: SubscriptionCallback,\n _collectionIdentifier: any,\n _predicate?: Predicate\n ): SubscriptionReleaser | null {\n return null;\n }\n\n subscribeRecord(\n _callback: SubscriptionCallback,\n _collectionIdentifier: any,\n _recordIdentifier: any\n ): SubscriptionReleaser | null {\n return null;\n }\n}\n\n/*\n * Providers enable a namespace, perform validation, and track the sources used\n * by that namespace within one single schema build. The should not directly use\n * any long-lived features as they do not have an explicit \"release\"/\"close\"\n * command when a new schema is built.\n */\nexport class LiveProvider {\n sources: Array<LiveSource>;\n namespace: string;\n\n constructor(namespace: string) {\n this.namespace = namespace;\n this.sources = [];\n }\n\n registerSource(source: LiveSource) {\n this.sources.push(source);\n }\n\n collectionIdentifierIsValid(_collectionIdentifier: any): boolean {\n return false;\n }\n\n recordIdentifierIsValid(\n _collectionIdentifier: any,\n _recordIdentifier: any\n ): boolean {\n return false;\n }\n}\n\n/*\n * During a single execution of GraphQL (specifically a subscription request),\n * the LiveMonitor tracks the resources viewed and subscribes to updates in them.\n */\nexport class LiveMonitor {\n released: boolean;\n providers: { [namespace: string]: LiveProvider };\n subscriptionReleasersByCounter: {\n [counter: string]: (() => void)[],\n };\n liveConditionsByCounter: { [counter: string]: Array<PredicateGenerator> };\n changeCallback: ((arg: any) => void) | null;\n changeCounter: number;\n extraRootValue: any;\n\n handleChange: (() => void) | null;\n _reallyHandleChange: (() => void) | null;\n onChange: (callback: () => void) => () => void;\n\n constructor(\n providers: { [namespace: string]: LiveProvider },\n extraRootValue: any\n ) {\n this.extraRootValue = extraRootValue;\n this.released = false;\n this.providers = providers;\n this.subscriptionReleasersByCounter = {};\n this.changeCallback = null;\n this.changeCounter = 0;\n this.liveConditionsByCounter = {};\n this.handleChange = function () {\n /* This function is throttled to ~25ms (see constructor); it's purpose is\n * to bundle up all the changes that occur in a small window into the same\n * handle change flow, so _reallyHandleChange doesn't get called twice in\n * quick succession. _reallyHandleChange is then further throttled with a\n * larger window, BUT it triggers on both leading and trailing edge,\n * whereas this only triggers on the trailing edge.\n */\n if (this._reallyHandleChange) {\n this._reallyHandleChange();\n }\n };\n\n this._reallyHandleChange = function () {\n // This function is throttled to MONITOR_THROTTLE_DURATION (see constructor)\n if (this.changeCallback) {\n // Convince Flow this won't suddenly become null\n const cb = this.changeCallback;\n const counter = this.changeCounter++;\n /*\n * In live queries we need to know when the current result set has\n * finished being calculated so that we know we've received all the\n * liveRecord / liveCollection calls and can release the out of date\n * ones. To achieve this, we use a custom `subscribe` function which\n * calls `rootValue.release()` once the result set has been calculated.\n */\n this.subscriptionReleasersByCounter[String(counter)] = [];\n this.liveConditionsByCounter[String(counter)] = [];\n const changeRootValue = {\n ...this.extraRootValue,\n counter,\n liveCollection: this.liveCollection.bind(this, counter),\n liveRecord: this.liveRecord.bind(this, counter),\n liveConditions: this.liveConditionsByCounter[String(counter)],\n release: () => {\n // Despite it's name, this means that the execution has complete, which means we're actually releasing everything *before* this.\n this.resetBefore(counter);\n },\n };\n cb(changeRootValue);\n } else {\n // eslint-disable-next-line no-console\n console.warn(\"Change occurred, but no-one was listening\");\n }\n };\n\n this.onChange = function (callback: () => void) {\n if (this.released) {\n throw new Error(\"Monitors cannot be reused.\");\n }\n if (this.changeCallback) {\n throw new Error(\"Already monitoring for changes\");\n }\n // Throttle to every 250ms\n this.changeCallback = callback;\n if (this.handleChange) {\n setImmediate(this.handleChange);\n }\n return () => {\n if (this.changeCallback === callback) {\n this.changeCallback = null;\n }\n this.release();\n };\n };\n\n this.handleChange = throttle(\n this.handleChange.bind(this),\n DEBOUNCE_DURATION,\n {\n leading: false,\n trailing: true,\n }\n );\n if (!this._reallyHandleChange) {\n throw new Error(\"This is just to make flow happy\");\n }\n this._reallyHandleChange = throttle(\n this._reallyHandleChange.bind(this),\n MONITOR_THROTTLE_DURATION - DEBOUNCE_DURATION,\n {\n leading: true,\n trailing: true,\n }\n );\n this.onChange = this.onChange.bind(this);\n }\n\n resetBefore(currentCounter: number) {\n // Clear out of date subscriptionReleasers\n {\n const oldCounters = Object.keys(\n this.subscriptionReleasersByCounter\n ).filter(n => parseInt(n, 10) < currentCounter);\n for (const oldCounter of oldCounters) {\n for (const releaser of this.subscriptionReleasersByCounter[\n oldCounter\n ]) {\n releaser();\n }\n delete this.subscriptionReleasersByCounter[oldCounter];\n }\n }\n // Clear out of date liveConditions\n {\n const oldCounters = Object.keys(this.liveConditionsByCounter).filter(\n n => parseInt(n, 10) < currentCounter\n );\n for (const oldCounter of oldCounters) {\n delete this.liveConditionsByCounter[oldCounter];\n }\n }\n }\n\n release() {\n if (this.handleChange) {\n // $FlowFixMe: throttled function\n this.handleChange.cancel();\n }\n this.handleChange = null;\n if (this._reallyHandleChange) {\n // $FlowFixMe: throttled function\n this._reallyHandleChange.cancel();\n }\n this._reallyHandleChange = null;\n this.resetBefore(Infinity);\n this.providers = {};\n this.released = true;\n }\n\n liveCollection(\n counter: number,\n namespace: string,\n collectionIdentifier: any,\n predicate: (record: any) => boolean = () => true\n ) {\n const handleChange = this.handleChange;\n if (this.released || !handleChange) {\n return;\n }\n const provider = this.providers[namespace];\n if (!provider || provider.sources.length === 0) return;\n if (!provider.collectionIdentifierIsValid(collectionIdentifier)) {\n throw new Error(\n `Invalid collection identifier passed to LiveMonitor[${namespace}]: ${collectionIdentifier}`\n );\n }\n for (const source of provider.sources) {\n const releaser = source.subscribeCollection(\n handleChange,\n collectionIdentifier,\n predicate\n );\n if (releaser) {\n this.subscriptionReleasersByCounter[String(counter)].push(releaser);\n }\n }\n }\n\n liveRecord(\n counter: number,\n namespace: string,\n collectionIdentifier: any,\n recordIdentifier: any\n ) {\n const handleChange = this.handleChange;\n if (this.released || !handleChange) {\n return;\n }\n // TODO: if (recordIdentifier == null) {return}\n const provider = this.providers[namespace];\n if (!provider || provider.sources.length === 0) return;\n if (!provider.collectionIdentifierIsValid(collectionIdentifier)) {\n throw new Error(\n `Invalid collection identifier passed to LiveMonitor[${namespace}]: ${collectionIdentifier}`\n );\n }\n if (\n !provider.recordIdentifierIsValid(collectionIdentifier, recordIdentifier)\n ) {\n throw new Error(\n `Invalid record identifier passed to LiveMonitor[${namespace}]: ${collectionIdentifier}`\n );\n }\n for (const source of provider.sources) {\n const releaser = source.subscribeRecord(\n handleChange,\n collectionIdentifier,\n recordIdentifier\n );\n if (releaser) {\n this.subscriptionReleasersByCounter[String(counter)].push(releaser);\n }\n }\n }\n}\n\n/*\n * There is one coordinator for each build of the GraphQL schema, it tracks the providers\n * and gives a handy `subscribe` method that can be used for live queries (assuming\n * that the `resolve` is provided the same as in a Query).\n */\nexport class LiveCoordinator {\n providers: { [namespace: string]: LiveProvider };\n\n constructor() {\n this.providers = {};\n this.subscribe = this.subscribe.bind(this);\n }\n\n registerProvider(provider: LiveProvider) {\n const { namespace } = provider;\n if (this.providers[namespace]) {\n throw new Error(`Namespace ${namespace} already registered with Live`);\n }\n this.providers[namespace] = provider;\n }\n\n registerSource(namespace: string, source: LiveSource) {\n if (!this.providers[namespace]) {\n // eslint-disable-next-line no-console\n console.warn(\n `LiveProvider '${namespace}' is not registered, skipping live source.`\n );\n return;\n }\n this.providers[namespace].registerSource(source);\n }\n\n getMonitor(extraRootValue: any) {\n return new LiveMonitor(this.providers, extraRootValue);\n }\n\n // Tell Flow that we're okay with overwriting this\n subscribe: (\n _parent: any,\n _args: any,\n context: any,\n _info: GraphQLResolveInfo\n ) => any;\n subscribe(\n _parent: any,\n _args: any,\n _context: any,\n _info: GraphQLResolveInfo\n ) {\n const monitor = this.getMonitor({\n liveAbort: e => {\n if (iterator) iterator.throw(e);\n },\n });\n const iterator = makeAsyncIteratorFromMonitor(monitor);\n return iterator;\n }\n}\n\nexport function makeAsyncIteratorFromMonitor(monitor: LiveMonitor) {\n return callbackToAsyncIterator(monitor.onChange, {\n onClose: release => {\n if (release) release();\n },\n });\n}\n"],"mappings":";;;;;;;AAEA,IAAAA,wBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAAkC,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAHlC;AAWA,MAAMG,iBAAiB,GAAG,EAAE;AAE5B,MAAMC,yBAAyB,GAAGC,IAAI,CAACC,GAAG,CACxCH,iBAAiB,GAAG,CAAC,EACrBI,QAAQ,CAACC,OAAO,CAACC,GAAG,CAACC,aAAa,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,GACnD,CAAC;;AAED;AACA;AACA;AACA;AACO,MAAMC,UAAU,CAAC;EACtBC,mBAAmBA,CACjBC,SAA+B,EAC/BC,qBAA0B,EAC1BC,UAAsB,EACO;IAC7B,OAAO,IAAI;EACb;EAEAC,eAAeA,CACbH,SAA+B,EAC/BC,qBAA0B,EAC1BG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