koishi-plugin-warframe 1.7.10 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +201 -19
- package/lib/index.js +700 -3233
- package/lib/index.tsbuildinfo +1 -1
- package/package.json +6 -8
package/lib/index.js
CHANGED
|
@@ -34,2975 +34,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
34
34
|
));
|
|
35
35
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
36
|
|
|
37
|
-
// node_modules/bottleneck/lib/parser.js
|
|
38
|
-
var require_parser = __commonJS({
|
|
39
|
-
"node_modules/bottleneck/lib/parser.js"(exports2) {
|
|
40
|
-
"use strict";
|
|
41
|
-
exports2.load = function(received, defaults, onto = {}) {
|
|
42
|
-
var k, ref, v;
|
|
43
|
-
for (k in defaults) {
|
|
44
|
-
v = defaults[k];
|
|
45
|
-
onto[k] = (ref = received[k]) != null ? ref : v;
|
|
46
|
-
}
|
|
47
|
-
return onto;
|
|
48
|
-
};
|
|
49
|
-
exports2.overwrite = function(received, defaults, onto = {}) {
|
|
50
|
-
var k, v;
|
|
51
|
-
for (k in received) {
|
|
52
|
-
v = received[k];
|
|
53
|
-
if (defaults[k] !== void 0) {
|
|
54
|
-
onto[k] = v;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return onto;
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// node_modules/bottleneck/lib/DLList.js
|
|
63
|
-
var require_DLList = __commonJS({
|
|
64
|
-
"node_modules/bottleneck/lib/DLList.js"(exports2, module2) {
|
|
65
|
-
"use strict";
|
|
66
|
-
var DLList;
|
|
67
|
-
DLList = class DLList {
|
|
68
|
-
static {
|
|
69
|
-
__name(this, "DLList");
|
|
70
|
-
}
|
|
71
|
-
constructor(incr, decr) {
|
|
72
|
-
this.incr = incr;
|
|
73
|
-
this.decr = decr;
|
|
74
|
-
this._first = null;
|
|
75
|
-
this._last = null;
|
|
76
|
-
this.length = 0;
|
|
77
|
-
}
|
|
78
|
-
push(value) {
|
|
79
|
-
var node;
|
|
80
|
-
this.length++;
|
|
81
|
-
if (typeof this.incr === "function") {
|
|
82
|
-
this.incr();
|
|
83
|
-
}
|
|
84
|
-
node = {
|
|
85
|
-
value,
|
|
86
|
-
prev: this._last,
|
|
87
|
-
next: null
|
|
88
|
-
};
|
|
89
|
-
if (this._last != null) {
|
|
90
|
-
this._last.next = node;
|
|
91
|
-
this._last = node;
|
|
92
|
-
} else {
|
|
93
|
-
this._first = this._last = node;
|
|
94
|
-
}
|
|
95
|
-
return void 0;
|
|
96
|
-
}
|
|
97
|
-
shift() {
|
|
98
|
-
var value;
|
|
99
|
-
if (this._first == null) {
|
|
100
|
-
return;
|
|
101
|
-
} else {
|
|
102
|
-
this.length--;
|
|
103
|
-
if (typeof this.decr === "function") {
|
|
104
|
-
this.decr();
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
value = this._first.value;
|
|
108
|
-
if ((this._first = this._first.next) != null) {
|
|
109
|
-
this._first.prev = null;
|
|
110
|
-
} else {
|
|
111
|
-
this._last = null;
|
|
112
|
-
}
|
|
113
|
-
return value;
|
|
114
|
-
}
|
|
115
|
-
first() {
|
|
116
|
-
if (this._first != null) {
|
|
117
|
-
return this._first.value;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
getArray() {
|
|
121
|
-
var node, ref, results;
|
|
122
|
-
node = this._first;
|
|
123
|
-
results = [];
|
|
124
|
-
while (node != null) {
|
|
125
|
-
results.push((ref = node, node = node.next, ref.value));
|
|
126
|
-
}
|
|
127
|
-
return results;
|
|
128
|
-
}
|
|
129
|
-
forEachShift(cb) {
|
|
130
|
-
var node;
|
|
131
|
-
node = this.shift();
|
|
132
|
-
while (node != null) {
|
|
133
|
-
cb(node), node = this.shift();
|
|
134
|
-
}
|
|
135
|
-
return void 0;
|
|
136
|
-
}
|
|
137
|
-
debug() {
|
|
138
|
-
var node, ref, ref1, ref2, results;
|
|
139
|
-
node = this._first;
|
|
140
|
-
results = [];
|
|
141
|
-
while (node != null) {
|
|
142
|
-
results.push((ref = node, node = node.next, {
|
|
143
|
-
value: ref.value,
|
|
144
|
-
prev: (ref1 = ref.prev) != null ? ref1.value : void 0,
|
|
145
|
-
next: (ref2 = ref.next) != null ? ref2.value : void 0
|
|
146
|
-
}));
|
|
147
|
-
}
|
|
148
|
-
return results;
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
module2.exports = DLList;
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
// node_modules/bottleneck/lib/Events.js
|
|
156
|
-
var require_Events = __commonJS({
|
|
157
|
-
"node_modules/bottleneck/lib/Events.js"(exports2, module2) {
|
|
158
|
-
"use strict";
|
|
159
|
-
function asyncGeneratorStep2(gen, resolve3, reject, _next, _throw, key, arg) {
|
|
160
|
-
try {
|
|
161
|
-
var info = gen[key](arg);
|
|
162
|
-
var value = info.value;
|
|
163
|
-
} catch (error) {
|
|
164
|
-
reject(error);
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
if (info.done) {
|
|
168
|
-
resolve3(value);
|
|
169
|
-
} else {
|
|
170
|
-
Promise.resolve(value).then(_next, _throw);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
__name(asyncGeneratorStep2, "asyncGeneratorStep");
|
|
174
|
-
function _asyncToGenerator2(fn) {
|
|
175
|
-
return function() {
|
|
176
|
-
var self2 = this, args = arguments;
|
|
177
|
-
return new Promise(function(resolve3, reject) {
|
|
178
|
-
var gen = fn.apply(self2, args);
|
|
179
|
-
function _next(value) {
|
|
180
|
-
asyncGeneratorStep2(gen, resolve3, reject, _next, _throw, "next", value);
|
|
181
|
-
}
|
|
182
|
-
__name(_next, "_next");
|
|
183
|
-
function _throw(err) {
|
|
184
|
-
asyncGeneratorStep2(gen, resolve3, reject, _next, _throw, "throw", err);
|
|
185
|
-
}
|
|
186
|
-
__name(_throw, "_throw");
|
|
187
|
-
_next(void 0);
|
|
188
|
-
});
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
__name(_asyncToGenerator2, "_asyncToGenerator");
|
|
192
|
-
var Events2;
|
|
193
|
-
Events2 = class Events {
|
|
194
|
-
static {
|
|
195
|
-
__name(this, "Events");
|
|
196
|
-
}
|
|
197
|
-
constructor(instance) {
|
|
198
|
-
this.instance = instance;
|
|
199
|
-
this._events = {};
|
|
200
|
-
if (this.instance.on != null || this.instance.once != null || this.instance.removeAllListeners != null) {
|
|
201
|
-
throw new Error("An Emitter already exists for this object");
|
|
202
|
-
}
|
|
203
|
-
this.instance.on = (name2, cb) => {
|
|
204
|
-
return this._addListener(name2, "many", cb);
|
|
205
|
-
};
|
|
206
|
-
this.instance.once = (name2, cb) => {
|
|
207
|
-
return this._addListener(name2, "once", cb);
|
|
208
|
-
};
|
|
209
|
-
this.instance.removeAllListeners = (name2 = null) => {
|
|
210
|
-
if (name2 != null) {
|
|
211
|
-
return delete this._events[name2];
|
|
212
|
-
} else {
|
|
213
|
-
return this._events = {};
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
_addListener(name2, status, cb) {
|
|
218
|
-
var base;
|
|
219
|
-
if ((base = this._events)[name2] == null) {
|
|
220
|
-
base[name2] = [];
|
|
221
|
-
}
|
|
222
|
-
this._events[name2].push({
|
|
223
|
-
cb,
|
|
224
|
-
status
|
|
225
|
-
});
|
|
226
|
-
return this.instance;
|
|
227
|
-
}
|
|
228
|
-
listenerCount(name2) {
|
|
229
|
-
if (this._events[name2] != null) {
|
|
230
|
-
return this._events[name2].length;
|
|
231
|
-
} else {
|
|
232
|
-
return 0;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
trigger(name2, ...args) {
|
|
236
|
-
var _this = this;
|
|
237
|
-
return _asyncToGenerator2(function* () {
|
|
238
|
-
var e, promises;
|
|
239
|
-
try {
|
|
240
|
-
if (name2 !== "debug") {
|
|
241
|
-
_this.trigger("debug", `Event triggered: ${name2}`, args);
|
|
242
|
-
}
|
|
243
|
-
if (_this._events[name2] == null) {
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
_this._events[name2] = _this._events[name2].filter(function(listener) {
|
|
247
|
-
return listener.status !== "none";
|
|
248
|
-
});
|
|
249
|
-
promises = _this._events[name2].map(
|
|
250
|
-
/* @__PURE__ */ (function() {
|
|
251
|
-
var _ref = _asyncToGenerator2(function* (listener) {
|
|
252
|
-
var e2, returned;
|
|
253
|
-
if (listener.status === "none") {
|
|
254
|
-
return;
|
|
255
|
-
}
|
|
256
|
-
if (listener.status === "once") {
|
|
257
|
-
listener.status = "none";
|
|
258
|
-
}
|
|
259
|
-
try {
|
|
260
|
-
returned = typeof listener.cb === "function" ? listener.cb(...args) : void 0;
|
|
261
|
-
if (typeof (returned != null ? returned.then : void 0) === "function") {
|
|
262
|
-
return yield returned;
|
|
263
|
-
} else {
|
|
264
|
-
return returned;
|
|
265
|
-
}
|
|
266
|
-
} catch (error) {
|
|
267
|
-
e2 = error;
|
|
268
|
-
if (true) {
|
|
269
|
-
_this.trigger("error", e2);
|
|
270
|
-
}
|
|
271
|
-
return null;
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
return function(_x) {
|
|
275
|
-
return _ref.apply(this, arguments);
|
|
276
|
-
};
|
|
277
|
-
})()
|
|
278
|
-
);
|
|
279
|
-
return (yield Promise.all(promises)).find(function(x) {
|
|
280
|
-
return x != null;
|
|
281
|
-
});
|
|
282
|
-
} catch (error) {
|
|
283
|
-
e = error;
|
|
284
|
-
if (true) {
|
|
285
|
-
_this.trigger("error", e);
|
|
286
|
-
}
|
|
287
|
-
return null;
|
|
288
|
-
}
|
|
289
|
-
})();
|
|
290
|
-
}
|
|
291
|
-
};
|
|
292
|
-
module2.exports = Events2;
|
|
293
|
-
}
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
// node_modules/bottleneck/lib/Queues.js
|
|
297
|
-
var require_Queues = __commonJS({
|
|
298
|
-
"node_modules/bottleneck/lib/Queues.js"(exports2, module2) {
|
|
299
|
-
"use strict";
|
|
300
|
-
var DLList;
|
|
301
|
-
var Events2;
|
|
302
|
-
var Queues;
|
|
303
|
-
DLList = require_DLList();
|
|
304
|
-
Events2 = require_Events();
|
|
305
|
-
Queues = class Queues {
|
|
306
|
-
static {
|
|
307
|
-
__name(this, "Queues");
|
|
308
|
-
}
|
|
309
|
-
constructor(num_priorities) {
|
|
310
|
-
var i;
|
|
311
|
-
this.Events = new Events2(this);
|
|
312
|
-
this._length = 0;
|
|
313
|
-
this._lists = function() {
|
|
314
|
-
var j, ref, results;
|
|
315
|
-
results = [];
|
|
316
|
-
for (i = j = 1, ref = num_priorities; 1 <= ref ? j <= ref : j >= ref; i = 1 <= ref ? ++j : --j) {
|
|
317
|
-
results.push(new DLList(() => {
|
|
318
|
-
return this.incr();
|
|
319
|
-
}, () => {
|
|
320
|
-
return this.decr();
|
|
321
|
-
}));
|
|
322
|
-
}
|
|
323
|
-
return results;
|
|
324
|
-
}.call(this);
|
|
325
|
-
}
|
|
326
|
-
incr() {
|
|
327
|
-
if (this._length++ === 0) {
|
|
328
|
-
return this.Events.trigger("leftzero");
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
decr() {
|
|
332
|
-
if (--this._length === 0) {
|
|
333
|
-
return this.Events.trigger("zero");
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
push(job) {
|
|
337
|
-
return this._lists[job.options.priority].push(job);
|
|
338
|
-
}
|
|
339
|
-
queued(priority) {
|
|
340
|
-
if (priority != null) {
|
|
341
|
-
return this._lists[priority].length;
|
|
342
|
-
} else {
|
|
343
|
-
return this._length;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
shiftAll(fn) {
|
|
347
|
-
return this._lists.forEach(function(list) {
|
|
348
|
-
return list.forEachShift(fn);
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
getFirst(arr = this._lists) {
|
|
352
|
-
var j, len, list;
|
|
353
|
-
for (j = 0, len = arr.length; j < len; j++) {
|
|
354
|
-
list = arr[j];
|
|
355
|
-
if (list.length > 0) {
|
|
356
|
-
return list;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
return [];
|
|
360
|
-
}
|
|
361
|
-
shiftLastFrom(priority) {
|
|
362
|
-
return this.getFirst(this._lists.slice(priority).reverse()).shift();
|
|
363
|
-
}
|
|
364
|
-
};
|
|
365
|
-
module2.exports = Queues;
|
|
366
|
-
}
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
// node_modules/bottleneck/lib/BottleneckError.js
|
|
370
|
-
var require_BottleneckError = __commonJS({
|
|
371
|
-
"node_modules/bottleneck/lib/BottleneckError.js"(exports2, module2) {
|
|
372
|
-
"use strict";
|
|
373
|
-
var BottleneckError;
|
|
374
|
-
BottleneckError = class BottleneckError extends Error {
|
|
375
|
-
static {
|
|
376
|
-
__name(this, "BottleneckError");
|
|
377
|
-
}
|
|
378
|
-
};
|
|
379
|
-
module2.exports = BottleneckError;
|
|
380
|
-
}
|
|
381
|
-
});
|
|
382
|
-
|
|
383
|
-
// node_modules/bottleneck/lib/Job.js
|
|
384
|
-
var require_Job = __commonJS({
|
|
385
|
-
"node_modules/bottleneck/lib/Job.js"(exports2, module2) {
|
|
386
|
-
"use strict";
|
|
387
|
-
function asyncGeneratorStep2(gen, resolve3, reject, _next, _throw, key, arg) {
|
|
388
|
-
try {
|
|
389
|
-
var info = gen[key](arg);
|
|
390
|
-
var value = info.value;
|
|
391
|
-
} catch (error) {
|
|
392
|
-
reject(error);
|
|
393
|
-
return;
|
|
394
|
-
}
|
|
395
|
-
if (info.done) {
|
|
396
|
-
resolve3(value);
|
|
397
|
-
} else {
|
|
398
|
-
Promise.resolve(value).then(_next, _throw);
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
__name(asyncGeneratorStep2, "asyncGeneratorStep");
|
|
402
|
-
function _asyncToGenerator2(fn) {
|
|
403
|
-
return function() {
|
|
404
|
-
var self2 = this, args = arguments;
|
|
405
|
-
return new Promise(function(resolve3, reject) {
|
|
406
|
-
var gen = fn.apply(self2, args);
|
|
407
|
-
function _next(value) {
|
|
408
|
-
asyncGeneratorStep2(gen, resolve3, reject, _next, _throw, "next", value);
|
|
409
|
-
}
|
|
410
|
-
__name(_next, "_next");
|
|
411
|
-
function _throw(err) {
|
|
412
|
-
asyncGeneratorStep2(gen, resolve3, reject, _next, _throw, "throw", err);
|
|
413
|
-
}
|
|
414
|
-
__name(_throw, "_throw");
|
|
415
|
-
_next(void 0);
|
|
416
|
-
});
|
|
417
|
-
};
|
|
418
|
-
}
|
|
419
|
-
__name(_asyncToGenerator2, "_asyncToGenerator");
|
|
420
|
-
var BottleneckError;
|
|
421
|
-
var DEFAULT_PRIORITY;
|
|
422
|
-
var Job;
|
|
423
|
-
var NUM_PRIORITIES;
|
|
424
|
-
var parser2;
|
|
425
|
-
NUM_PRIORITIES = 10;
|
|
426
|
-
DEFAULT_PRIORITY = 5;
|
|
427
|
-
parser2 = require_parser();
|
|
428
|
-
BottleneckError = require_BottleneckError();
|
|
429
|
-
Job = class Job {
|
|
430
|
-
static {
|
|
431
|
-
__name(this, "Job");
|
|
432
|
-
}
|
|
433
|
-
constructor(task, args, options2, jobDefaults, rejectOnDrop, Events2, _states, Promise2) {
|
|
434
|
-
this.task = task;
|
|
435
|
-
this.args = args;
|
|
436
|
-
this.rejectOnDrop = rejectOnDrop;
|
|
437
|
-
this.Events = Events2;
|
|
438
|
-
this._states = _states;
|
|
439
|
-
this.Promise = Promise2;
|
|
440
|
-
this.options = parser2.load(options2, jobDefaults);
|
|
441
|
-
this.options.priority = this._sanitizePriority(this.options.priority);
|
|
442
|
-
if (this.options.id === jobDefaults.id) {
|
|
443
|
-
this.options.id = `${this.options.id}-${this._randomIndex()}`;
|
|
444
|
-
}
|
|
445
|
-
this.promise = new this.Promise((_resolve, _reject) => {
|
|
446
|
-
this._resolve = _resolve;
|
|
447
|
-
this._reject = _reject;
|
|
448
|
-
});
|
|
449
|
-
this.retryCount = 0;
|
|
450
|
-
}
|
|
451
|
-
_sanitizePriority(priority) {
|
|
452
|
-
var sProperty;
|
|
453
|
-
sProperty = ~~priority !== priority ? DEFAULT_PRIORITY : priority;
|
|
454
|
-
if (sProperty < 0) {
|
|
455
|
-
return 0;
|
|
456
|
-
} else if (sProperty > NUM_PRIORITIES - 1) {
|
|
457
|
-
return NUM_PRIORITIES - 1;
|
|
458
|
-
} else {
|
|
459
|
-
return sProperty;
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
_randomIndex() {
|
|
463
|
-
return Math.random().toString(36).slice(2);
|
|
464
|
-
}
|
|
465
|
-
doDrop({
|
|
466
|
-
error,
|
|
467
|
-
message = "This job has been dropped by Bottleneck"
|
|
468
|
-
} = {}) {
|
|
469
|
-
if (this._states.remove(this.options.id)) {
|
|
470
|
-
if (this.rejectOnDrop) {
|
|
471
|
-
this._reject(error != null ? error : new BottleneckError(message));
|
|
472
|
-
}
|
|
473
|
-
this.Events.trigger("dropped", {
|
|
474
|
-
args: this.args,
|
|
475
|
-
options: this.options,
|
|
476
|
-
task: this.task,
|
|
477
|
-
promise: this.promise
|
|
478
|
-
});
|
|
479
|
-
return true;
|
|
480
|
-
} else {
|
|
481
|
-
return false;
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
_assertStatus(expected) {
|
|
485
|
-
var status;
|
|
486
|
-
status = this._states.jobStatus(this.options.id);
|
|
487
|
-
if (!(status === expected || expected === "DONE" && status === null)) {
|
|
488
|
-
throw new BottleneckError(`Invalid job status ${status}, expected ${expected}. Please open an issue at https://github.com/SGrondin/bottleneck/issues`);
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
doReceive() {
|
|
492
|
-
this._states.start(this.options.id);
|
|
493
|
-
return this.Events.trigger("received", {
|
|
494
|
-
args: this.args,
|
|
495
|
-
options: this.options
|
|
496
|
-
});
|
|
497
|
-
}
|
|
498
|
-
doQueue(reachedHWM, blocked) {
|
|
499
|
-
this._assertStatus("RECEIVED");
|
|
500
|
-
this._states.next(this.options.id);
|
|
501
|
-
return this.Events.trigger("queued", {
|
|
502
|
-
args: this.args,
|
|
503
|
-
options: this.options,
|
|
504
|
-
reachedHWM,
|
|
505
|
-
blocked
|
|
506
|
-
});
|
|
507
|
-
}
|
|
508
|
-
doRun() {
|
|
509
|
-
if (this.retryCount === 0) {
|
|
510
|
-
this._assertStatus("QUEUED");
|
|
511
|
-
this._states.next(this.options.id);
|
|
512
|
-
} else {
|
|
513
|
-
this._assertStatus("EXECUTING");
|
|
514
|
-
}
|
|
515
|
-
return this.Events.trigger("scheduled", {
|
|
516
|
-
args: this.args,
|
|
517
|
-
options: this.options
|
|
518
|
-
});
|
|
519
|
-
}
|
|
520
|
-
doExecute(chained, clearGlobalState, run, free) {
|
|
521
|
-
var _this = this;
|
|
522
|
-
return _asyncToGenerator2(function* () {
|
|
523
|
-
var error, eventInfo, passed;
|
|
524
|
-
if (_this.retryCount === 0) {
|
|
525
|
-
_this._assertStatus("RUNNING");
|
|
526
|
-
_this._states.next(_this.options.id);
|
|
527
|
-
} else {
|
|
528
|
-
_this._assertStatus("EXECUTING");
|
|
529
|
-
}
|
|
530
|
-
eventInfo = {
|
|
531
|
-
args: _this.args,
|
|
532
|
-
options: _this.options,
|
|
533
|
-
retryCount: _this.retryCount
|
|
534
|
-
};
|
|
535
|
-
_this.Events.trigger("executing", eventInfo);
|
|
536
|
-
try {
|
|
537
|
-
passed = yield chained != null ? chained.schedule(_this.options, _this.task, ..._this.args) : _this.task(..._this.args);
|
|
538
|
-
if (clearGlobalState()) {
|
|
539
|
-
_this.doDone(eventInfo);
|
|
540
|
-
yield free(_this.options, eventInfo);
|
|
541
|
-
_this._assertStatus("DONE");
|
|
542
|
-
return _this._resolve(passed);
|
|
543
|
-
}
|
|
544
|
-
} catch (error1) {
|
|
545
|
-
error = error1;
|
|
546
|
-
return _this._onFailure(error, eventInfo, clearGlobalState, run, free);
|
|
547
|
-
}
|
|
548
|
-
})();
|
|
549
|
-
}
|
|
550
|
-
doExpire(clearGlobalState, run, free) {
|
|
551
|
-
var error, eventInfo;
|
|
552
|
-
if (this._states.jobStatus(this.options.id === "RUNNING")) {
|
|
553
|
-
this._states.next(this.options.id);
|
|
554
|
-
}
|
|
555
|
-
this._assertStatus("EXECUTING");
|
|
556
|
-
eventInfo = {
|
|
557
|
-
args: this.args,
|
|
558
|
-
options: this.options,
|
|
559
|
-
retryCount: this.retryCount
|
|
560
|
-
};
|
|
561
|
-
error = new BottleneckError(`This job timed out after ${this.options.expiration} ms.`);
|
|
562
|
-
return this._onFailure(error, eventInfo, clearGlobalState, run, free);
|
|
563
|
-
}
|
|
564
|
-
_onFailure(error, eventInfo, clearGlobalState, run, free) {
|
|
565
|
-
var _this2 = this;
|
|
566
|
-
return _asyncToGenerator2(function* () {
|
|
567
|
-
var retry, retryAfter;
|
|
568
|
-
if (clearGlobalState()) {
|
|
569
|
-
retry = yield _this2.Events.trigger("failed", error, eventInfo);
|
|
570
|
-
if (retry != null) {
|
|
571
|
-
retryAfter = ~~retry;
|
|
572
|
-
_this2.Events.trigger("retry", `Retrying ${_this2.options.id} after ${retryAfter} ms`, eventInfo);
|
|
573
|
-
_this2.retryCount++;
|
|
574
|
-
return run(retryAfter);
|
|
575
|
-
} else {
|
|
576
|
-
_this2.doDone(eventInfo);
|
|
577
|
-
yield free(_this2.options, eventInfo);
|
|
578
|
-
_this2._assertStatus("DONE");
|
|
579
|
-
return _this2._reject(error);
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
})();
|
|
583
|
-
}
|
|
584
|
-
doDone(eventInfo) {
|
|
585
|
-
this._assertStatus("EXECUTING");
|
|
586
|
-
this._states.next(this.options.id);
|
|
587
|
-
return this.Events.trigger("done", eventInfo);
|
|
588
|
-
}
|
|
589
|
-
};
|
|
590
|
-
module2.exports = Job;
|
|
591
|
-
}
|
|
592
|
-
});
|
|
593
|
-
|
|
594
|
-
// node_modules/bottleneck/lib/LocalDatastore.js
|
|
595
|
-
var require_LocalDatastore = __commonJS({
|
|
596
|
-
"node_modules/bottleneck/lib/LocalDatastore.js"(exports2, module2) {
|
|
597
|
-
"use strict";
|
|
598
|
-
function asyncGeneratorStep2(gen, resolve3, reject, _next, _throw, key, arg) {
|
|
599
|
-
try {
|
|
600
|
-
var info = gen[key](arg);
|
|
601
|
-
var value = info.value;
|
|
602
|
-
} catch (error) {
|
|
603
|
-
reject(error);
|
|
604
|
-
return;
|
|
605
|
-
}
|
|
606
|
-
if (info.done) {
|
|
607
|
-
resolve3(value);
|
|
608
|
-
} else {
|
|
609
|
-
Promise.resolve(value).then(_next, _throw);
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
__name(asyncGeneratorStep2, "asyncGeneratorStep");
|
|
613
|
-
function _asyncToGenerator2(fn) {
|
|
614
|
-
return function() {
|
|
615
|
-
var self2 = this, args = arguments;
|
|
616
|
-
return new Promise(function(resolve3, reject) {
|
|
617
|
-
var gen = fn.apply(self2, args);
|
|
618
|
-
function _next(value) {
|
|
619
|
-
asyncGeneratorStep2(gen, resolve3, reject, _next, _throw, "next", value);
|
|
620
|
-
}
|
|
621
|
-
__name(_next, "_next");
|
|
622
|
-
function _throw(err) {
|
|
623
|
-
asyncGeneratorStep2(gen, resolve3, reject, _next, _throw, "throw", err);
|
|
624
|
-
}
|
|
625
|
-
__name(_throw, "_throw");
|
|
626
|
-
_next(void 0);
|
|
627
|
-
});
|
|
628
|
-
};
|
|
629
|
-
}
|
|
630
|
-
__name(_asyncToGenerator2, "_asyncToGenerator");
|
|
631
|
-
var BottleneckError;
|
|
632
|
-
var LocalDatastore;
|
|
633
|
-
var parser2;
|
|
634
|
-
parser2 = require_parser();
|
|
635
|
-
BottleneckError = require_BottleneckError();
|
|
636
|
-
LocalDatastore = class LocalDatastore {
|
|
637
|
-
static {
|
|
638
|
-
__name(this, "LocalDatastore");
|
|
639
|
-
}
|
|
640
|
-
constructor(instance, storeOptions, storeInstanceOptions) {
|
|
641
|
-
this.instance = instance;
|
|
642
|
-
this.storeOptions = storeOptions;
|
|
643
|
-
this.clientId = this.instance._randomIndex();
|
|
644
|
-
parser2.load(storeInstanceOptions, storeInstanceOptions, this);
|
|
645
|
-
this._nextRequest = this._lastReservoirRefresh = this._lastReservoirIncrease = Date.now();
|
|
646
|
-
this._running = 0;
|
|
647
|
-
this._done = 0;
|
|
648
|
-
this._unblockTime = 0;
|
|
649
|
-
this.ready = this.Promise.resolve();
|
|
650
|
-
this.clients = {};
|
|
651
|
-
this._startHeartbeat();
|
|
652
|
-
}
|
|
653
|
-
_startHeartbeat() {
|
|
654
|
-
var base;
|
|
655
|
-
if (this.heartbeat == null && (this.storeOptions.reservoirRefreshInterval != null && this.storeOptions.reservoirRefreshAmount != null || this.storeOptions.reservoirIncreaseInterval != null && this.storeOptions.reservoirIncreaseAmount != null)) {
|
|
656
|
-
return typeof (base = this.heartbeat = setInterval(() => {
|
|
657
|
-
var amount, incr, maximum, now, reservoir;
|
|
658
|
-
now = Date.now();
|
|
659
|
-
if (this.storeOptions.reservoirRefreshInterval != null && now >= this._lastReservoirRefresh + this.storeOptions.reservoirRefreshInterval) {
|
|
660
|
-
this._lastReservoirRefresh = now;
|
|
661
|
-
this.storeOptions.reservoir = this.storeOptions.reservoirRefreshAmount;
|
|
662
|
-
this.instance._drainAll(this.computeCapacity());
|
|
663
|
-
}
|
|
664
|
-
if (this.storeOptions.reservoirIncreaseInterval != null && now >= this._lastReservoirIncrease + this.storeOptions.reservoirIncreaseInterval) {
|
|
665
|
-
var _this$storeOptions = this.storeOptions;
|
|
666
|
-
amount = _this$storeOptions.reservoirIncreaseAmount;
|
|
667
|
-
maximum = _this$storeOptions.reservoirIncreaseMaximum;
|
|
668
|
-
reservoir = _this$storeOptions.reservoir;
|
|
669
|
-
this._lastReservoirIncrease = now;
|
|
670
|
-
incr = maximum != null ? Math.min(amount, maximum - reservoir) : amount;
|
|
671
|
-
if (incr > 0) {
|
|
672
|
-
this.storeOptions.reservoir += incr;
|
|
673
|
-
return this.instance._drainAll(this.computeCapacity());
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
}, this.heartbeatInterval)).unref === "function" ? base.unref() : void 0;
|
|
677
|
-
} else {
|
|
678
|
-
return clearInterval(this.heartbeat);
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
__publish__(message) {
|
|
682
|
-
var _this = this;
|
|
683
|
-
return _asyncToGenerator2(function* () {
|
|
684
|
-
yield _this.yieldLoop();
|
|
685
|
-
return _this.instance.Events.trigger("message", message.toString());
|
|
686
|
-
})();
|
|
687
|
-
}
|
|
688
|
-
__disconnect__(flush) {
|
|
689
|
-
var _this2 = this;
|
|
690
|
-
return _asyncToGenerator2(function* () {
|
|
691
|
-
yield _this2.yieldLoop();
|
|
692
|
-
clearInterval(_this2.heartbeat);
|
|
693
|
-
return _this2.Promise.resolve();
|
|
694
|
-
})();
|
|
695
|
-
}
|
|
696
|
-
yieldLoop(t2 = 0) {
|
|
697
|
-
return new this.Promise(function(resolve3, reject) {
|
|
698
|
-
return setTimeout(resolve3, t2);
|
|
699
|
-
});
|
|
700
|
-
}
|
|
701
|
-
computePenalty() {
|
|
702
|
-
var ref;
|
|
703
|
-
return (ref = this.storeOptions.penalty) != null ? ref : 15 * this.storeOptions.minTime || 5e3;
|
|
704
|
-
}
|
|
705
|
-
__updateSettings__(options2) {
|
|
706
|
-
var _this3 = this;
|
|
707
|
-
return _asyncToGenerator2(function* () {
|
|
708
|
-
yield _this3.yieldLoop();
|
|
709
|
-
parser2.overwrite(options2, options2, _this3.storeOptions);
|
|
710
|
-
_this3._startHeartbeat();
|
|
711
|
-
_this3.instance._drainAll(_this3.computeCapacity());
|
|
712
|
-
return true;
|
|
713
|
-
})();
|
|
714
|
-
}
|
|
715
|
-
__running__() {
|
|
716
|
-
var _this4 = this;
|
|
717
|
-
return _asyncToGenerator2(function* () {
|
|
718
|
-
yield _this4.yieldLoop();
|
|
719
|
-
return _this4._running;
|
|
720
|
-
})();
|
|
721
|
-
}
|
|
722
|
-
__queued__() {
|
|
723
|
-
var _this5 = this;
|
|
724
|
-
return _asyncToGenerator2(function* () {
|
|
725
|
-
yield _this5.yieldLoop();
|
|
726
|
-
return _this5.instance.queued();
|
|
727
|
-
})();
|
|
728
|
-
}
|
|
729
|
-
__done__() {
|
|
730
|
-
var _this6 = this;
|
|
731
|
-
return _asyncToGenerator2(function* () {
|
|
732
|
-
yield _this6.yieldLoop();
|
|
733
|
-
return _this6._done;
|
|
734
|
-
})();
|
|
735
|
-
}
|
|
736
|
-
__groupCheck__(time2) {
|
|
737
|
-
var _this7 = this;
|
|
738
|
-
return _asyncToGenerator2(function* () {
|
|
739
|
-
yield _this7.yieldLoop();
|
|
740
|
-
return _this7._nextRequest + _this7.timeout < time2;
|
|
741
|
-
})();
|
|
742
|
-
}
|
|
743
|
-
computeCapacity() {
|
|
744
|
-
var maxConcurrent, reservoir;
|
|
745
|
-
var _this$storeOptions2 = this.storeOptions;
|
|
746
|
-
maxConcurrent = _this$storeOptions2.maxConcurrent;
|
|
747
|
-
reservoir = _this$storeOptions2.reservoir;
|
|
748
|
-
if (maxConcurrent != null && reservoir != null) {
|
|
749
|
-
return Math.min(maxConcurrent - this._running, reservoir);
|
|
750
|
-
} else if (maxConcurrent != null) {
|
|
751
|
-
return maxConcurrent - this._running;
|
|
752
|
-
} else if (reservoir != null) {
|
|
753
|
-
return reservoir;
|
|
754
|
-
} else {
|
|
755
|
-
return null;
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
conditionsCheck(weight) {
|
|
759
|
-
var capacity;
|
|
760
|
-
capacity = this.computeCapacity();
|
|
761
|
-
return capacity == null || weight <= capacity;
|
|
762
|
-
}
|
|
763
|
-
__incrementReservoir__(incr) {
|
|
764
|
-
var _this8 = this;
|
|
765
|
-
return _asyncToGenerator2(function* () {
|
|
766
|
-
var reservoir;
|
|
767
|
-
yield _this8.yieldLoop();
|
|
768
|
-
reservoir = _this8.storeOptions.reservoir += incr;
|
|
769
|
-
_this8.instance._drainAll(_this8.computeCapacity());
|
|
770
|
-
return reservoir;
|
|
771
|
-
})();
|
|
772
|
-
}
|
|
773
|
-
__currentReservoir__() {
|
|
774
|
-
var _this9 = this;
|
|
775
|
-
return _asyncToGenerator2(function* () {
|
|
776
|
-
yield _this9.yieldLoop();
|
|
777
|
-
return _this9.storeOptions.reservoir;
|
|
778
|
-
})();
|
|
779
|
-
}
|
|
780
|
-
isBlocked(now) {
|
|
781
|
-
return this._unblockTime >= now;
|
|
782
|
-
}
|
|
783
|
-
check(weight, now) {
|
|
784
|
-
return this.conditionsCheck(weight) && this._nextRequest - now <= 0;
|
|
785
|
-
}
|
|
786
|
-
__check__(weight) {
|
|
787
|
-
var _this10 = this;
|
|
788
|
-
return _asyncToGenerator2(function* () {
|
|
789
|
-
var now;
|
|
790
|
-
yield _this10.yieldLoop();
|
|
791
|
-
now = Date.now();
|
|
792
|
-
return _this10.check(weight, now);
|
|
793
|
-
})();
|
|
794
|
-
}
|
|
795
|
-
__register__(index, weight, expiration) {
|
|
796
|
-
var _this11 = this;
|
|
797
|
-
return _asyncToGenerator2(function* () {
|
|
798
|
-
var now, wait;
|
|
799
|
-
yield _this11.yieldLoop();
|
|
800
|
-
now = Date.now();
|
|
801
|
-
if (_this11.conditionsCheck(weight)) {
|
|
802
|
-
_this11._running += weight;
|
|
803
|
-
if (_this11.storeOptions.reservoir != null) {
|
|
804
|
-
_this11.storeOptions.reservoir -= weight;
|
|
805
|
-
}
|
|
806
|
-
wait = Math.max(_this11._nextRequest - now, 0);
|
|
807
|
-
_this11._nextRequest = now + wait + _this11.storeOptions.minTime;
|
|
808
|
-
return {
|
|
809
|
-
success: true,
|
|
810
|
-
wait,
|
|
811
|
-
reservoir: _this11.storeOptions.reservoir
|
|
812
|
-
};
|
|
813
|
-
} else {
|
|
814
|
-
return {
|
|
815
|
-
success: false
|
|
816
|
-
};
|
|
817
|
-
}
|
|
818
|
-
})();
|
|
819
|
-
}
|
|
820
|
-
strategyIsBlock() {
|
|
821
|
-
return this.storeOptions.strategy === 3;
|
|
822
|
-
}
|
|
823
|
-
__submit__(queueLength, weight) {
|
|
824
|
-
var _this12 = this;
|
|
825
|
-
return _asyncToGenerator2(function* () {
|
|
826
|
-
var blocked, now, reachedHWM;
|
|
827
|
-
yield _this12.yieldLoop();
|
|
828
|
-
if (_this12.storeOptions.maxConcurrent != null && weight > _this12.storeOptions.maxConcurrent) {
|
|
829
|
-
throw new BottleneckError(`Impossible to add a job having a weight of ${weight} to a limiter having a maxConcurrent setting of ${_this12.storeOptions.maxConcurrent}`);
|
|
830
|
-
}
|
|
831
|
-
now = Date.now();
|
|
832
|
-
reachedHWM = _this12.storeOptions.highWater != null && queueLength === _this12.storeOptions.highWater && !_this12.check(weight, now);
|
|
833
|
-
blocked = _this12.strategyIsBlock() && (reachedHWM || _this12.isBlocked(now));
|
|
834
|
-
if (blocked) {
|
|
835
|
-
_this12._unblockTime = now + _this12.computePenalty();
|
|
836
|
-
_this12._nextRequest = _this12._unblockTime + _this12.storeOptions.minTime;
|
|
837
|
-
_this12.instance._dropAllQueued();
|
|
838
|
-
}
|
|
839
|
-
return {
|
|
840
|
-
reachedHWM,
|
|
841
|
-
blocked,
|
|
842
|
-
strategy: _this12.storeOptions.strategy
|
|
843
|
-
};
|
|
844
|
-
})();
|
|
845
|
-
}
|
|
846
|
-
__free__(index, weight) {
|
|
847
|
-
var _this13 = this;
|
|
848
|
-
return _asyncToGenerator2(function* () {
|
|
849
|
-
yield _this13.yieldLoop();
|
|
850
|
-
_this13._running -= weight;
|
|
851
|
-
_this13._done += weight;
|
|
852
|
-
_this13.instance._drainAll(_this13.computeCapacity());
|
|
853
|
-
return {
|
|
854
|
-
running: _this13._running
|
|
855
|
-
};
|
|
856
|
-
})();
|
|
857
|
-
}
|
|
858
|
-
};
|
|
859
|
-
module2.exports = LocalDatastore;
|
|
860
|
-
}
|
|
861
|
-
});
|
|
862
|
-
|
|
863
|
-
// node_modules/bottleneck/lib/lua.json
|
|
864
|
-
var require_lua = __commonJS({
|
|
865
|
-
"node_modules/bottleneck/lib/lua.json"(exports2, module2) {
|
|
866
|
-
module2.exports = {
|
|
867
|
-
"blacklist_client.lua": "local blacklist = ARGV[num_static_argv + 1]\n\nif redis.call('zscore', client_last_seen_key, blacklist) then\n redis.call('zadd', client_last_seen_key, 0, blacklist)\nend\n\n\nreturn {}\n",
|
|
868
|
-
"check.lua": "local weight = tonumber(ARGV[num_static_argv + 1])\n\nlocal capacity = process_tick(now, false)['capacity']\nlocal nextRequest = tonumber(redis.call('hget', settings_key, 'nextRequest'))\n\nreturn conditions_check(capacity, weight) and nextRequest - now <= 0\n",
|
|
869
|
-
"conditions_check.lua": "local conditions_check = function (capacity, weight)\n return capacity == nil or weight <= capacity\nend\n",
|
|
870
|
-
"current_reservoir.lua": "return process_tick(now, false)['reservoir']\n",
|
|
871
|
-
"done.lua": "process_tick(now, false)\n\nreturn tonumber(redis.call('hget', settings_key, 'done'))\n",
|
|
872
|
-
"free.lua": "local index = ARGV[num_static_argv + 1]\n\nredis.call('zadd', job_expirations_key, 0, index)\n\nreturn process_tick(now, false)['running']\n",
|
|
873
|
-
"get_time.lua": "redis.replicate_commands()\n\nlocal get_time = function ()\n local time = redis.call('time')\n\n return tonumber(time[1]..string.sub(time[2], 1, 3))\nend\n",
|
|
874
|
-
"group_check.lua": "return not (redis.call('exists', settings_key) == 1)\n",
|
|
875
|
-
"heartbeat.lua": "process_tick(now, true)\n",
|
|
876
|
-
"increment_reservoir.lua": "local incr = tonumber(ARGV[num_static_argv + 1])\n\nredis.call('hincrby', settings_key, 'reservoir', incr)\n\nlocal reservoir = process_tick(now, true)['reservoir']\n\nlocal groupTimeout = tonumber(redis.call('hget', settings_key, 'groupTimeout'))\nrefresh_expiration(0, 0, groupTimeout)\n\nreturn reservoir\n",
|
|
877
|
-
"init.lua": `local clear = tonumber(ARGV[num_static_argv + 1])
|
|
878
|
-
local limiter_version = ARGV[num_static_argv + 2]
|
|
879
|
-
local num_local_argv = num_static_argv + 2
|
|
880
|
-
|
|
881
|
-
if clear == 1 then
|
|
882
|
-
redis.call('del', unpack(KEYS))
|
|
883
|
-
end
|
|
884
|
-
|
|
885
|
-
if redis.call('exists', settings_key) == 0 then
|
|
886
|
-
-- Create
|
|
887
|
-
local args = {'hmset', settings_key}
|
|
888
|
-
|
|
889
|
-
for i = num_local_argv + 1, #ARGV do
|
|
890
|
-
table.insert(args, ARGV[i])
|
|
891
|
-
end
|
|
892
|
-
|
|
893
|
-
redis.call(unpack(args))
|
|
894
|
-
redis.call('hmset', settings_key,
|
|
895
|
-
'nextRequest', now,
|
|
896
|
-
'lastReservoirRefresh', now,
|
|
897
|
-
'lastReservoirIncrease', now,
|
|
898
|
-
'running', 0,
|
|
899
|
-
'done', 0,
|
|
900
|
-
'unblockTime', 0,
|
|
901
|
-
'capacityPriorityCounter', 0
|
|
902
|
-
)
|
|
903
|
-
|
|
904
|
-
else
|
|
905
|
-
-- Apply migrations
|
|
906
|
-
local settings = redis.call('hmget', settings_key,
|
|
907
|
-
'id',
|
|
908
|
-
'version'
|
|
909
|
-
)
|
|
910
|
-
local id = settings[1]
|
|
911
|
-
local current_version = settings[2]
|
|
912
|
-
|
|
913
|
-
if current_version ~= limiter_version then
|
|
914
|
-
local version_digits = {}
|
|
915
|
-
for k, v in string.gmatch(current_version, "([^.]+)") do
|
|
916
|
-
table.insert(version_digits, tonumber(k))
|
|
917
|
-
end
|
|
918
|
-
|
|
919
|
-
-- 2.10.0
|
|
920
|
-
if version_digits[2] < 10 then
|
|
921
|
-
redis.call('hsetnx', settings_key, 'reservoirRefreshInterval', '')
|
|
922
|
-
redis.call('hsetnx', settings_key, 'reservoirRefreshAmount', '')
|
|
923
|
-
redis.call('hsetnx', settings_key, 'lastReservoirRefresh', '')
|
|
924
|
-
redis.call('hsetnx', settings_key, 'done', 0)
|
|
925
|
-
redis.call('hset', settings_key, 'version', '2.10.0')
|
|
926
|
-
end
|
|
927
|
-
|
|
928
|
-
-- 2.11.1
|
|
929
|
-
if version_digits[2] < 11 or (version_digits[2] == 11 and version_digits[3] < 1) then
|
|
930
|
-
if redis.call('hstrlen', settings_key, 'lastReservoirRefresh') == 0 then
|
|
931
|
-
redis.call('hmset', settings_key,
|
|
932
|
-
'lastReservoirRefresh', now,
|
|
933
|
-
'version', '2.11.1'
|
|
934
|
-
)
|
|
935
|
-
end
|
|
936
|
-
end
|
|
937
|
-
|
|
938
|
-
-- 2.14.0
|
|
939
|
-
if version_digits[2] < 14 then
|
|
940
|
-
local old_running_key = 'b_'..id..'_running'
|
|
941
|
-
local old_executing_key = 'b_'..id..'_executing'
|
|
942
|
-
|
|
943
|
-
if redis.call('exists', old_running_key) == 1 then
|
|
944
|
-
redis.call('rename', old_running_key, job_weights_key)
|
|
945
|
-
end
|
|
946
|
-
if redis.call('exists', old_executing_key) == 1 then
|
|
947
|
-
redis.call('rename', old_executing_key, job_expirations_key)
|
|
948
|
-
end
|
|
949
|
-
redis.call('hset', settings_key, 'version', '2.14.0')
|
|
950
|
-
end
|
|
951
|
-
|
|
952
|
-
-- 2.15.2
|
|
953
|
-
if version_digits[2] < 15 or (version_digits[2] == 15 and version_digits[3] < 2) then
|
|
954
|
-
redis.call('hsetnx', settings_key, 'capacityPriorityCounter', 0)
|
|
955
|
-
redis.call('hset', settings_key, 'version', '2.15.2')
|
|
956
|
-
end
|
|
957
|
-
|
|
958
|
-
-- 2.17.0
|
|
959
|
-
if version_digits[2] < 17 then
|
|
960
|
-
redis.call('hsetnx', settings_key, 'clientTimeout', 10000)
|
|
961
|
-
redis.call('hset', settings_key, 'version', '2.17.0')
|
|
962
|
-
end
|
|
963
|
-
|
|
964
|
-
-- 2.18.0
|
|
965
|
-
if version_digits[2] < 18 then
|
|
966
|
-
redis.call('hsetnx', settings_key, 'reservoirIncreaseInterval', '')
|
|
967
|
-
redis.call('hsetnx', settings_key, 'reservoirIncreaseAmount', '')
|
|
968
|
-
redis.call('hsetnx', settings_key, 'reservoirIncreaseMaximum', '')
|
|
969
|
-
redis.call('hsetnx', settings_key, 'lastReservoirIncrease', now)
|
|
970
|
-
redis.call('hset', settings_key, 'version', '2.18.0')
|
|
971
|
-
end
|
|
972
|
-
|
|
973
|
-
end
|
|
974
|
-
|
|
975
|
-
process_tick(now, false)
|
|
976
|
-
end
|
|
977
|
-
|
|
978
|
-
local groupTimeout = tonumber(redis.call('hget', settings_key, 'groupTimeout'))
|
|
979
|
-
refresh_expiration(0, 0, groupTimeout)
|
|
980
|
-
|
|
981
|
-
return {}
|
|
982
|
-
`,
|
|
983
|
-
"process_tick.lua": "local process_tick = function (now, always_publish)\n\n local compute_capacity = function (maxConcurrent, running, reservoir)\n if maxConcurrent ~= nil and reservoir ~= nil then\n return math.min((maxConcurrent - running), reservoir)\n elseif maxConcurrent ~= nil then\n return maxConcurrent - running\n elseif reservoir ~= nil then\n return reservoir\n else\n return nil\n end\n end\n\n local settings = redis.call('hmget', settings_key,\n 'id',\n 'maxConcurrent',\n 'running',\n 'reservoir',\n 'reservoirRefreshInterval',\n 'reservoirRefreshAmount',\n 'lastReservoirRefresh',\n 'reservoirIncreaseInterval',\n 'reservoirIncreaseAmount',\n 'reservoirIncreaseMaximum',\n 'lastReservoirIncrease',\n 'capacityPriorityCounter',\n 'clientTimeout'\n )\n local id = settings[1]\n local maxConcurrent = tonumber(settings[2])\n local running = tonumber(settings[3])\n local reservoir = tonumber(settings[4])\n local reservoirRefreshInterval = tonumber(settings[5])\n local reservoirRefreshAmount = tonumber(settings[6])\n local lastReservoirRefresh = tonumber(settings[7])\n local reservoirIncreaseInterval = tonumber(settings[8])\n local reservoirIncreaseAmount = tonumber(settings[9])\n local reservoirIncreaseMaximum = tonumber(settings[10])\n local lastReservoirIncrease = tonumber(settings[11])\n local capacityPriorityCounter = tonumber(settings[12])\n local clientTimeout = tonumber(settings[13])\n\n local initial_capacity = compute_capacity(maxConcurrent, running, reservoir)\n\n --\n -- Process 'running' changes\n --\n local expired = redis.call('zrangebyscore', job_expirations_key, '-inf', '('..now)\n\n if #expired > 0 then\n redis.call('zremrangebyscore', job_expirations_key, '-inf', '('..now)\n\n local flush_batch = function (batch, acc)\n local weights = redis.call('hmget', job_weights_key, unpack(batch))\n redis.call('hdel', job_weights_key, unpack(batch))\n local clients = redis.call('hmget', job_clients_key, unpack(batch))\n redis.call('hdel', job_clients_key, unpack(batch))\n\n -- Calculate sum of removed weights\n for i = 1, #weights do\n acc['total'] = acc['total'] + (tonumber(weights[i]) or 0)\n end\n\n -- Calculate sum of removed weights by client\n local client_weights = {}\n for i = 1, #clients do\n local removed = tonumber(weights[i]) or 0\n if removed > 0 then\n acc['client_weights'][clients[i]] = (acc['client_weights'][clients[i]] or 0) + removed\n end\n end\n end\n\n local acc = {\n ['total'] = 0,\n ['client_weights'] = {}\n }\n local batch_size = 1000\n\n -- Compute changes to Zsets and apply changes to Hashes\n for i = 1, #expired, batch_size do\n local batch = {}\n for j = i, math.min(i + batch_size - 1, #expired) do\n table.insert(batch, expired[j])\n end\n\n flush_batch(batch, acc)\n end\n\n -- Apply changes to Zsets\n if acc['total'] > 0 then\n redis.call('hincrby', settings_key, 'done', acc['total'])\n running = tonumber(redis.call('hincrby', settings_key, 'running', -acc['total']))\n end\n\n for client, weight in pairs(acc['client_weights']) do\n redis.call('zincrby', client_running_key, -weight, client)\n end\n end\n\n --\n -- Process 'reservoir' changes\n --\n local reservoirRefreshActive = reservoirRefreshInterval ~= nil and reservoirRefreshAmount ~= nil\n if reservoirRefreshActive and now >= lastReservoirRefresh + reservoirRefreshInterval then\n reservoir = reservoirRefreshAmount\n redis.call('hmset', settings_key,\n 'reservoir', reservoir,\n 'lastReservoirRefresh', now\n )\n end\n\n local reservoirIncreaseActive = reservoirIncreaseInterval ~= nil and reservoirIncreaseAmount ~= nil\n if reservoirIncreaseActive and now >= lastReservoirIncrease + reservoirIncreaseInterval then\n local num_intervals = math.floor((now - lastReservoirIncrease) / reservoirIncreaseInterval)\n local incr = reservoirIncreaseAmount * num_intervals\n if reservoirIncreaseMaximum ~= nil then\n incr = math.min(incr, reservoirIncreaseMaximum - (reservoir or 0))\n end\n if incr > 0 then\n reservoir = (reservoir or 0) + incr\n end\n redis.call('hmset', settings_key,\n 'reservoir', reservoir,\n 'lastReservoirIncrease', lastReservoirIncrease + (num_intervals * reservoirIncreaseInterval)\n )\n end\n\n --\n -- Clear unresponsive clients\n --\n local unresponsive = redis.call('zrangebyscore', client_last_seen_key, '-inf', (now - clientTimeout))\n local unresponsive_lookup = {}\n local terminated_clients = {}\n for i = 1, #unresponsive do\n unresponsive_lookup[unresponsive[i]] = true\n if tonumber(redis.call('zscore', client_running_key, unresponsive[i])) == 0 then\n table.insert(terminated_clients, unresponsive[i])\n end\n end\n if #terminated_clients > 0 then\n redis.call('zrem', client_running_key, unpack(terminated_clients))\n redis.call('hdel', client_num_queued_key, unpack(terminated_clients))\n redis.call('zrem', client_last_registered_key, unpack(terminated_clients))\n redis.call('zrem', client_last_seen_key, unpack(terminated_clients))\n end\n\n --\n -- Broadcast capacity changes\n --\n local final_capacity = compute_capacity(maxConcurrent, running, reservoir)\n\n if always_publish or (initial_capacity ~= nil and final_capacity == nil) then\n -- always_publish or was not unlimited, now unlimited\n redis.call('publish', 'b_'..id, 'capacity:'..(final_capacity or ''))\n\n elseif initial_capacity ~= nil and final_capacity ~= nil and final_capacity > initial_capacity then\n -- capacity was increased\n -- send the capacity message to the limiter having the lowest number of running jobs\n -- the tiebreaker is the limiter having not registered a job in the longest time\n\n local lowest_concurrency_value = nil\n local lowest_concurrency_clients = {}\n local lowest_concurrency_last_registered = {}\n local client_concurrencies = redis.call('zrange', client_running_key, 0, -1, 'withscores')\n\n for i = 1, #client_concurrencies, 2 do\n local client = client_concurrencies[i]\n local concurrency = tonumber(client_concurrencies[i+1])\n\n if (\n lowest_concurrency_value == nil or lowest_concurrency_value == concurrency\n ) and (\n not unresponsive_lookup[client]\n ) and (\n tonumber(redis.call('hget', client_num_queued_key, client)) > 0\n ) then\n lowest_concurrency_value = concurrency\n table.insert(lowest_concurrency_clients, client)\n local last_registered = tonumber(redis.call('zscore', client_last_registered_key, client))\n table.insert(lowest_concurrency_last_registered, last_registered)\n end\n end\n\n if #lowest_concurrency_clients > 0 then\n local position = 1\n local earliest = lowest_concurrency_last_registered[1]\n\n for i,v in ipairs(lowest_concurrency_last_registered) do\n if v < earliest then\n position = i\n earliest = v\n end\n end\n\n local next_client = lowest_concurrency_clients[position]\n redis.call('publish', 'b_'..id,\n 'capacity-priority:'..(final_capacity or '')..\n ':'..next_client..\n ':'..capacityPriorityCounter\n )\n redis.call('hincrby', settings_key, 'capacityPriorityCounter', '1')\n else\n redis.call('publish', 'b_'..id, 'capacity:'..(final_capacity or ''))\n end\n end\n\n return {\n ['capacity'] = final_capacity,\n ['running'] = running,\n ['reservoir'] = reservoir\n }\nend\n",
|
|
984
|
-
"queued.lua": "local clientTimeout = tonumber(redis.call('hget', settings_key, 'clientTimeout'))\nlocal valid_clients = redis.call('zrangebyscore', client_last_seen_key, (now - clientTimeout), 'inf')\nlocal client_queued = redis.call('hmget', client_num_queued_key, unpack(valid_clients))\n\nlocal sum = 0\nfor i = 1, #client_queued do\n sum = sum + tonumber(client_queued[i])\nend\n\nreturn sum\n",
|
|
985
|
-
"refresh_expiration.lua": "local refresh_expiration = function (now, nextRequest, groupTimeout)\n\n if groupTimeout ~= nil then\n local ttl = (nextRequest + groupTimeout) - now\n\n for i = 1, #KEYS do\n redis.call('pexpire', KEYS[i], ttl)\n end\n end\n\nend\n",
|
|
986
|
-
"refs.lua": "local settings_key = KEYS[1]\nlocal job_weights_key = KEYS[2]\nlocal job_expirations_key = KEYS[3]\nlocal job_clients_key = KEYS[4]\nlocal client_running_key = KEYS[5]\nlocal client_num_queued_key = KEYS[6]\nlocal client_last_registered_key = KEYS[7]\nlocal client_last_seen_key = KEYS[8]\n\nlocal now = tonumber(ARGV[1])\nlocal client = ARGV[2]\n\nlocal num_static_argv = 2\n",
|
|
987
|
-
"register.lua": "local index = ARGV[num_static_argv + 1]\nlocal weight = tonumber(ARGV[num_static_argv + 2])\nlocal expiration = tonumber(ARGV[num_static_argv + 3])\n\nlocal state = process_tick(now, false)\nlocal capacity = state['capacity']\nlocal reservoir = state['reservoir']\n\nlocal settings = redis.call('hmget', settings_key,\n 'nextRequest',\n 'minTime',\n 'groupTimeout'\n)\nlocal nextRequest = tonumber(settings[1])\nlocal minTime = tonumber(settings[2])\nlocal groupTimeout = tonumber(settings[3])\n\nif conditions_check(capacity, weight) then\n\n redis.call('hincrby', settings_key, 'running', weight)\n redis.call('hset', job_weights_key, index, weight)\n if expiration ~= nil then\n redis.call('zadd', job_expirations_key, now + expiration, index)\n end\n redis.call('hset', job_clients_key, index, client)\n redis.call('zincrby', client_running_key, weight, client)\n redis.call('hincrby', client_num_queued_key, client, -1)\n redis.call('zadd', client_last_registered_key, now, client)\n\n local wait = math.max(nextRequest - now, 0)\n local newNextRequest = now + wait + minTime\n\n if reservoir == nil then\n redis.call('hset', settings_key,\n 'nextRequest', newNextRequest\n )\n else\n reservoir = reservoir - weight\n redis.call('hmset', settings_key,\n 'reservoir', reservoir,\n 'nextRequest', newNextRequest\n )\n end\n\n refresh_expiration(now, newNextRequest, groupTimeout)\n\n return {true, wait, reservoir}\n\nelse\n return {false}\nend\n",
|
|
988
|
-
"register_client.lua": "local queued = tonumber(ARGV[num_static_argv + 1])\n\n-- Could have been re-registered concurrently\nif not redis.call('zscore', client_last_seen_key, client) then\n redis.call('zadd', client_running_key, 0, client)\n redis.call('hset', client_num_queued_key, client, queued)\n redis.call('zadd', client_last_registered_key, 0, client)\nend\n\nredis.call('zadd', client_last_seen_key, now, client)\n\nreturn {}\n",
|
|
989
|
-
"running.lua": "return process_tick(now, false)['running']\n",
|
|
990
|
-
"submit.lua": "local queueLength = tonumber(ARGV[num_static_argv + 1])\nlocal weight = tonumber(ARGV[num_static_argv + 2])\n\nlocal capacity = process_tick(now, false)['capacity']\n\nlocal settings = redis.call('hmget', settings_key,\n 'id',\n 'maxConcurrent',\n 'highWater',\n 'nextRequest',\n 'strategy',\n 'unblockTime',\n 'penalty',\n 'minTime',\n 'groupTimeout'\n)\nlocal id = settings[1]\nlocal maxConcurrent = tonumber(settings[2])\nlocal highWater = tonumber(settings[3])\nlocal nextRequest = tonumber(settings[4])\nlocal strategy = tonumber(settings[5])\nlocal unblockTime = tonumber(settings[6])\nlocal penalty = tonumber(settings[7])\nlocal minTime = tonumber(settings[8])\nlocal groupTimeout = tonumber(settings[9])\n\nif maxConcurrent ~= nil and weight > maxConcurrent then\n return redis.error_reply('OVERWEIGHT:'..weight..':'..maxConcurrent)\nend\n\nlocal reachedHWM = (highWater ~= nil and queueLength == highWater\n and not (\n conditions_check(capacity, weight)\n and nextRequest - now <= 0\n )\n)\n\nlocal blocked = strategy == 3 and (reachedHWM or unblockTime >= now)\n\nif blocked then\n local computedPenalty = penalty\n if computedPenalty == nil then\n if minTime == 0 then\n computedPenalty = 5000\n else\n computedPenalty = 15 * minTime\n end\n end\n\n local newNextRequest = now + computedPenalty + minTime\n\n redis.call('hmset', settings_key,\n 'unblockTime', now + computedPenalty,\n 'nextRequest', newNextRequest\n )\n\n local clients_queued_reset = redis.call('hkeys', client_num_queued_key)\n local queued_reset = {}\n for i = 1, #clients_queued_reset do\n table.insert(queued_reset, clients_queued_reset[i])\n table.insert(queued_reset, 0)\n end\n redis.call('hmset', client_num_queued_key, unpack(queued_reset))\n\n redis.call('publish', 'b_'..id, 'blocked:')\n\n refresh_expiration(now, newNextRequest, groupTimeout)\nend\n\nif not blocked and not reachedHWM then\n redis.call('hincrby', client_num_queued_key, client, 1)\nend\n\nreturn {reachedHWM, blocked, strategy}\n",
|
|
991
|
-
"update_settings.lua": "local args = {'hmset', settings_key}\n\nfor i = num_static_argv + 1, #ARGV do\n table.insert(args, ARGV[i])\nend\n\nredis.call(unpack(args))\n\nprocess_tick(now, true)\n\nlocal groupTimeout = tonumber(redis.call('hget', settings_key, 'groupTimeout'))\nrefresh_expiration(0, 0, groupTimeout)\n\nreturn {}\n",
|
|
992
|
-
"validate_client.lua": "if not redis.call('zscore', client_last_seen_key, client) then\n return redis.error_reply('UNKNOWN_CLIENT')\nend\n\nredis.call('zadd', client_last_seen_key, now, client)\n",
|
|
993
|
-
"validate_keys.lua": "if not (redis.call('exists', settings_key) == 1) then\n return redis.error_reply('SETTINGS_KEY_NOT_FOUND')\nend\n"
|
|
994
|
-
};
|
|
995
|
-
}
|
|
996
|
-
});
|
|
997
|
-
|
|
998
|
-
// node_modules/bottleneck/lib/Scripts.js
|
|
999
|
-
var require_Scripts = __commonJS({
|
|
1000
|
-
"node_modules/bottleneck/lib/Scripts.js"(exports2) {
|
|
1001
|
-
"use strict";
|
|
1002
|
-
var headers;
|
|
1003
|
-
var lua;
|
|
1004
|
-
var templates;
|
|
1005
|
-
lua = require_lua();
|
|
1006
|
-
headers = {
|
|
1007
|
-
refs: lua["refs.lua"],
|
|
1008
|
-
validate_keys: lua["validate_keys.lua"],
|
|
1009
|
-
validate_client: lua["validate_client.lua"],
|
|
1010
|
-
refresh_expiration: lua["refresh_expiration.lua"],
|
|
1011
|
-
process_tick: lua["process_tick.lua"],
|
|
1012
|
-
conditions_check: lua["conditions_check.lua"],
|
|
1013
|
-
get_time: lua["get_time.lua"]
|
|
1014
|
-
};
|
|
1015
|
-
exports2.allKeys = function(id) {
|
|
1016
|
-
return [
|
|
1017
|
-
/*
|
|
1018
|
-
HASH
|
|
1019
|
-
*/
|
|
1020
|
-
`b_${id}_settings`,
|
|
1021
|
-
/*
|
|
1022
|
-
HASH
|
|
1023
|
-
job index -> weight
|
|
1024
|
-
*/
|
|
1025
|
-
`b_${id}_job_weights`,
|
|
1026
|
-
/*
|
|
1027
|
-
ZSET
|
|
1028
|
-
job index -> expiration
|
|
1029
|
-
*/
|
|
1030
|
-
`b_${id}_job_expirations`,
|
|
1031
|
-
/*
|
|
1032
|
-
HASH
|
|
1033
|
-
job index -> client
|
|
1034
|
-
*/
|
|
1035
|
-
`b_${id}_job_clients`,
|
|
1036
|
-
/*
|
|
1037
|
-
ZSET
|
|
1038
|
-
client -> sum running
|
|
1039
|
-
*/
|
|
1040
|
-
`b_${id}_client_running`,
|
|
1041
|
-
/*
|
|
1042
|
-
HASH
|
|
1043
|
-
client -> num queued
|
|
1044
|
-
*/
|
|
1045
|
-
`b_${id}_client_num_queued`,
|
|
1046
|
-
/*
|
|
1047
|
-
ZSET
|
|
1048
|
-
client -> last job registered
|
|
1049
|
-
*/
|
|
1050
|
-
`b_${id}_client_last_registered`,
|
|
1051
|
-
/*
|
|
1052
|
-
ZSET
|
|
1053
|
-
client -> last seen
|
|
1054
|
-
*/
|
|
1055
|
-
`b_${id}_client_last_seen`
|
|
1056
|
-
];
|
|
1057
|
-
};
|
|
1058
|
-
templates = {
|
|
1059
|
-
init: {
|
|
1060
|
-
keys: exports2.allKeys,
|
|
1061
|
-
headers: ["process_tick"],
|
|
1062
|
-
refresh_expiration: true,
|
|
1063
|
-
code: lua["init.lua"]
|
|
1064
|
-
},
|
|
1065
|
-
group_check: {
|
|
1066
|
-
keys: exports2.allKeys,
|
|
1067
|
-
headers: [],
|
|
1068
|
-
refresh_expiration: false,
|
|
1069
|
-
code: lua["group_check.lua"]
|
|
1070
|
-
},
|
|
1071
|
-
register_client: {
|
|
1072
|
-
keys: exports2.allKeys,
|
|
1073
|
-
headers: ["validate_keys"],
|
|
1074
|
-
refresh_expiration: false,
|
|
1075
|
-
code: lua["register_client.lua"]
|
|
1076
|
-
},
|
|
1077
|
-
blacklist_client: {
|
|
1078
|
-
keys: exports2.allKeys,
|
|
1079
|
-
headers: ["validate_keys", "validate_client"],
|
|
1080
|
-
refresh_expiration: false,
|
|
1081
|
-
code: lua["blacklist_client.lua"]
|
|
1082
|
-
},
|
|
1083
|
-
heartbeat: {
|
|
1084
|
-
keys: exports2.allKeys,
|
|
1085
|
-
headers: ["validate_keys", "validate_client", "process_tick"],
|
|
1086
|
-
refresh_expiration: false,
|
|
1087
|
-
code: lua["heartbeat.lua"]
|
|
1088
|
-
},
|
|
1089
|
-
update_settings: {
|
|
1090
|
-
keys: exports2.allKeys,
|
|
1091
|
-
headers: ["validate_keys", "validate_client", "process_tick"],
|
|
1092
|
-
refresh_expiration: true,
|
|
1093
|
-
code: lua["update_settings.lua"]
|
|
1094
|
-
},
|
|
1095
|
-
running: {
|
|
1096
|
-
keys: exports2.allKeys,
|
|
1097
|
-
headers: ["validate_keys", "validate_client", "process_tick"],
|
|
1098
|
-
refresh_expiration: false,
|
|
1099
|
-
code: lua["running.lua"]
|
|
1100
|
-
},
|
|
1101
|
-
queued: {
|
|
1102
|
-
keys: exports2.allKeys,
|
|
1103
|
-
headers: ["validate_keys", "validate_client"],
|
|
1104
|
-
refresh_expiration: false,
|
|
1105
|
-
code: lua["queued.lua"]
|
|
1106
|
-
},
|
|
1107
|
-
done: {
|
|
1108
|
-
keys: exports2.allKeys,
|
|
1109
|
-
headers: ["validate_keys", "validate_client", "process_tick"],
|
|
1110
|
-
refresh_expiration: false,
|
|
1111
|
-
code: lua["done.lua"]
|
|
1112
|
-
},
|
|
1113
|
-
check: {
|
|
1114
|
-
keys: exports2.allKeys,
|
|
1115
|
-
headers: ["validate_keys", "validate_client", "process_tick", "conditions_check"],
|
|
1116
|
-
refresh_expiration: false,
|
|
1117
|
-
code: lua["check.lua"]
|
|
1118
|
-
},
|
|
1119
|
-
submit: {
|
|
1120
|
-
keys: exports2.allKeys,
|
|
1121
|
-
headers: ["validate_keys", "validate_client", "process_tick", "conditions_check"],
|
|
1122
|
-
refresh_expiration: true,
|
|
1123
|
-
code: lua["submit.lua"]
|
|
1124
|
-
},
|
|
1125
|
-
register: {
|
|
1126
|
-
keys: exports2.allKeys,
|
|
1127
|
-
headers: ["validate_keys", "validate_client", "process_tick", "conditions_check"],
|
|
1128
|
-
refresh_expiration: true,
|
|
1129
|
-
code: lua["register.lua"]
|
|
1130
|
-
},
|
|
1131
|
-
free: {
|
|
1132
|
-
keys: exports2.allKeys,
|
|
1133
|
-
headers: ["validate_keys", "validate_client", "process_tick"],
|
|
1134
|
-
refresh_expiration: true,
|
|
1135
|
-
code: lua["free.lua"]
|
|
1136
|
-
},
|
|
1137
|
-
current_reservoir: {
|
|
1138
|
-
keys: exports2.allKeys,
|
|
1139
|
-
headers: ["validate_keys", "validate_client", "process_tick"],
|
|
1140
|
-
refresh_expiration: false,
|
|
1141
|
-
code: lua["current_reservoir.lua"]
|
|
1142
|
-
},
|
|
1143
|
-
increment_reservoir: {
|
|
1144
|
-
keys: exports2.allKeys,
|
|
1145
|
-
headers: ["validate_keys", "validate_client", "process_tick"],
|
|
1146
|
-
refresh_expiration: true,
|
|
1147
|
-
code: lua["increment_reservoir.lua"]
|
|
1148
|
-
}
|
|
1149
|
-
};
|
|
1150
|
-
exports2.names = Object.keys(templates);
|
|
1151
|
-
exports2.keys = function(name2, id) {
|
|
1152
|
-
return templates[name2].keys(id);
|
|
1153
|
-
};
|
|
1154
|
-
exports2.payload = function(name2) {
|
|
1155
|
-
var template2;
|
|
1156
|
-
template2 = templates[name2];
|
|
1157
|
-
return Array.prototype.concat(headers.refs, template2.headers.map(function(h2) {
|
|
1158
|
-
return headers[h2];
|
|
1159
|
-
}), template2.refresh_expiration ? headers.refresh_expiration : "", template2.code).join("\n");
|
|
1160
|
-
};
|
|
1161
|
-
}
|
|
1162
|
-
});
|
|
1163
|
-
|
|
1164
|
-
// node_modules/bottleneck/lib/RedisConnection.js
|
|
1165
|
-
var require_RedisConnection = __commonJS({
|
|
1166
|
-
"node_modules/bottleneck/lib/RedisConnection.js"(exports, module) {
|
|
1167
|
-
"use strict";
|
|
1168
|
-
function asyncGeneratorStep(gen, resolve3, reject, _next, _throw, key, arg) {
|
|
1169
|
-
try {
|
|
1170
|
-
var info = gen[key](arg);
|
|
1171
|
-
var value = info.value;
|
|
1172
|
-
} catch (error) {
|
|
1173
|
-
reject(error);
|
|
1174
|
-
return;
|
|
1175
|
-
}
|
|
1176
|
-
if (info.done) {
|
|
1177
|
-
resolve3(value);
|
|
1178
|
-
} else {
|
|
1179
|
-
Promise.resolve(value).then(_next, _throw);
|
|
1180
|
-
}
|
|
1181
|
-
}
|
|
1182
|
-
__name(asyncGeneratorStep, "asyncGeneratorStep");
|
|
1183
|
-
function _asyncToGenerator(fn) {
|
|
1184
|
-
return function() {
|
|
1185
|
-
var self2 = this, args = arguments;
|
|
1186
|
-
return new Promise(function(resolve3, reject) {
|
|
1187
|
-
var gen = fn.apply(self2, args);
|
|
1188
|
-
function _next(value) {
|
|
1189
|
-
asyncGeneratorStep(gen, resolve3, reject, _next, _throw, "next", value);
|
|
1190
|
-
}
|
|
1191
|
-
__name(_next, "_next");
|
|
1192
|
-
function _throw(err) {
|
|
1193
|
-
asyncGeneratorStep(gen, resolve3, reject, _next, _throw, "throw", err);
|
|
1194
|
-
}
|
|
1195
|
-
__name(_throw, "_throw");
|
|
1196
|
-
_next(void 0);
|
|
1197
|
-
});
|
|
1198
|
-
};
|
|
1199
|
-
}
|
|
1200
|
-
__name(_asyncToGenerator, "_asyncToGenerator");
|
|
1201
|
-
var Events;
|
|
1202
|
-
var RedisConnection;
|
|
1203
|
-
var Scripts;
|
|
1204
|
-
var parser;
|
|
1205
|
-
parser = require_parser();
|
|
1206
|
-
Events = require_Events();
|
|
1207
|
-
Scripts = require_Scripts();
|
|
1208
|
-
RedisConnection = function() {
|
|
1209
|
-
class RedisConnection {
|
|
1210
|
-
static {
|
|
1211
|
-
__name(this, "RedisConnection");
|
|
1212
|
-
}
|
|
1213
|
-
constructor(options = {}) {
|
|
1214
|
-
parser.load(options, this.defaults, this);
|
|
1215
|
-
if (this.Redis == null) {
|
|
1216
|
-
this.Redis = eval("require")("redis");
|
|
1217
|
-
}
|
|
1218
|
-
if (this.Events == null) {
|
|
1219
|
-
this.Events = new Events(this);
|
|
1220
|
-
}
|
|
1221
|
-
this.terminated = false;
|
|
1222
|
-
if (this.client == null) {
|
|
1223
|
-
this.client = this.Redis.createClient(this.clientOptions);
|
|
1224
|
-
}
|
|
1225
|
-
this.subscriber = this.client.duplicate();
|
|
1226
|
-
this.limiters = {};
|
|
1227
|
-
this.shas = {};
|
|
1228
|
-
this.ready = this.Promise.all([this._setup(this.client, false), this._setup(this.subscriber, true)]).then(() => {
|
|
1229
|
-
return this._loadScripts();
|
|
1230
|
-
}).then(() => {
|
|
1231
|
-
return {
|
|
1232
|
-
client: this.client,
|
|
1233
|
-
subscriber: this.subscriber
|
|
1234
|
-
};
|
|
1235
|
-
});
|
|
1236
|
-
}
|
|
1237
|
-
_setup(client, sub) {
|
|
1238
|
-
client.setMaxListeners(0);
|
|
1239
|
-
return new this.Promise((resolve3, reject) => {
|
|
1240
|
-
client.on("error", (e) => {
|
|
1241
|
-
return this.Events.trigger("error", e);
|
|
1242
|
-
});
|
|
1243
|
-
if (sub) {
|
|
1244
|
-
client.on("message", (channel, message) => {
|
|
1245
|
-
var ref;
|
|
1246
|
-
return (ref = this.limiters[channel]) != null ? ref._store.onMessage(channel, message) : void 0;
|
|
1247
|
-
});
|
|
1248
|
-
}
|
|
1249
|
-
if (client.ready) {
|
|
1250
|
-
return resolve3();
|
|
1251
|
-
} else {
|
|
1252
|
-
return client.once("ready", resolve3);
|
|
1253
|
-
}
|
|
1254
|
-
});
|
|
1255
|
-
}
|
|
1256
|
-
_loadScript(name2) {
|
|
1257
|
-
return new this.Promise((resolve3, reject) => {
|
|
1258
|
-
var payload;
|
|
1259
|
-
payload = Scripts.payload(name2);
|
|
1260
|
-
return this.client.multi([["script", "load", payload]]).exec((err, replies) => {
|
|
1261
|
-
if (err != null) {
|
|
1262
|
-
return reject(err);
|
|
1263
|
-
}
|
|
1264
|
-
this.shas[name2] = replies[0];
|
|
1265
|
-
return resolve3(replies[0]);
|
|
1266
|
-
});
|
|
1267
|
-
});
|
|
1268
|
-
}
|
|
1269
|
-
_loadScripts() {
|
|
1270
|
-
return this.Promise.all(Scripts.names.map((k) => {
|
|
1271
|
-
return this._loadScript(k);
|
|
1272
|
-
}));
|
|
1273
|
-
}
|
|
1274
|
-
__runCommand__(cmd) {
|
|
1275
|
-
var _this = this;
|
|
1276
|
-
return _asyncToGenerator(function* () {
|
|
1277
|
-
yield _this.ready;
|
|
1278
|
-
return new _this.Promise((resolve3, reject) => {
|
|
1279
|
-
return _this.client.multi([cmd]).exec_atomic(function(err, replies) {
|
|
1280
|
-
if (err != null) {
|
|
1281
|
-
return reject(err);
|
|
1282
|
-
} else {
|
|
1283
|
-
return resolve3(replies[0]);
|
|
1284
|
-
}
|
|
1285
|
-
});
|
|
1286
|
-
});
|
|
1287
|
-
})();
|
|
1288
|
-
}
|
|
1289
|
-
__addLimiter__(instance) {
|
|
1290
|
-
return this.Promise.all([instance.channel(), instance.channel_client()].map((channel) => {
|
|
1291
|
-
return new this.Promise((resolve3, reject) => {
|
|
1292
|
-
var handler;
|
|
1293
|
-
handler = /* @__PURE__ */ __name((chan) => {
|
|
1294
|
-
if (chan === channel) {
|
|
1295
|
-
this.subscriber.removeListener("subscribe", handler);
|
|
1296
|
-
this.limiters[channel] = instance;
|
|
1297
|
-
return resolve3();
|
|
1298
|
-
}
|
|
1299
|
-
}, "handler");
|
|
1300
|
-
this.subscriber.on("subscribe", handler);
|
|
1301
|
-
return this.subscriber.subscribe(channel);
|
|
1302
|
-
});
|
|
1303
|
-
}));
|
|
1304
|
-
}
|
|
1305
|
-
__removeLimiter__(instance) {
|
|
1306
|
-
var _this2 = this;
|
|
1307
|
-
return this.Promise.all([instance.channel(), instance.channel_client()].map(
|
|
1308
|
-
/* @__PURE__ */ (function() {
|
|
1309
|
-
var _ref = _asyncToGenerator(function* (channel) {
|
|
1310
|
-
if (!_this2.terminated) {
|
|
1311
|
-
yield new _this2.Promise((resolve3, reject) => {
|
|
1312
|
-
return _this2.subscriber.unsubscribe(channel, function(err, chan) {
|
|
1313
|
-
if (err != null) {
|
|
1314
|
-
return reject(err);
|
|
1315
|
-
}
|
|
1316
|
-
if (chan === channel) {
|
|
1317
|
-
return resolve3();
|
|
1318
|
-
}
|
|
1319
|
-
});
|
|
1320
|
-
});
|
|
1321
|
-
}
|
|
1322
|
-
return delete _this2.limiters[channel];
|
|
1323
|
-
});
|
|
1324
|
-
return function(_x) {
|
|
1325
|
-
return _ref.apply(this, arguments);
|
|
1326
|
-
};
|
|
1327
|
-
})()
|
|
1328
|
-
));
|
|
1329
|
-
}
|
|
1330
|
-
__scriptArgs__(name2, id, args, cb) {
|
|
1331
|
-
var keys;
|
|
1332
|
-
keys = Scripts.keys(name2, id);
|
|
1333
|
-
return [this.shas[name2], keys.length].concat(keys, args, cb);
|
|
1334
|
-
}
|
|
1335
|
-
__scriptFn__(name2) {
|
|
1336
|
-
return this.client.evalsha.bind(this.client);
|
|
1337
|
-
}
|
|
1338
|
-
disconnect(flush = true) {
|
|
1339
|
-
var i, k, len, ref;
|
|
1340
|
-
ref = Object.keys(this.limiters);
|
|
1341
|
-
for (i = 0, len = ref.length; i < len; i++) {
|
|
1342
|
-
k = ref[i];
|
|
1343
|
-
clearInterval(this.limiters[k]._store.heartbeat);
|
|
1344
|
-
}
|
|
1345
|
-
this.limiters = {};
|
|
1346
|
-
this.terminated = true;
|
|
1347
|
-
this.client.end(flush);
|
|
1348
|
-
this.subscriber.end(flush);
|
|
1349
|
-
return this.Promise.resolve();
|
|
1350
|
-
}
|
|
1351
|
-
}
|
|
1352
|
-
;
|
|
1353
|
-
RedisConnection.prototype.datastore = "redis";
|
|
1354
|
-
RedisConnection.prototype.defaults = {
|
|
1355
|
-
Redis: null,
|
|
1356
|
-
clientOptions: {},
|
|
1357
|
-
client: null,
|
|
1358
|
-
Promise,
|
|
1359
|
-
Events: null
|
|
1360
|
-
};
|
|
1361
|
-
return RedisConnection;
|
|
1362
|
-
}.call(void 0);
|
|
1363
|
-
module.exports = RedisConnection;
|
|
1364
|
-
}
|
|
1365
|
-
});
|
|
1366
|
-
|
|
1367
|
-
// node_modules/bottleneck/lib/IORedisConnection.js
|
|
1368
|
-
var require_IORedisConnection = __commonJS({
|
|
1369
|
-
"node_modules/bottleneck/lib/IORedisConnection.js"(exports, module) {
|
|
1370
|
-
"use strict";
|
|
1371
|
-
function _slicedToArray(arr, i) {
|
|
1372
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
|
|
1373
|
-
}
|
|
1374
|
-
__name(_slicedToArray, "_slicedToArray");
|
|
1375
|
-
function _nonIterableRest() {
|
|
1376
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
|
1377
|
-
}
|
|
1378
|
-
__name(_nonIterableRest, "_nonIterableRest");
|
|
1379
|
-
function _iterableToArrayLimit(arr, i) {
|
|
1380
|
-
var _arr = [];
|
|
1381
|
-
var _n = true;
|
|
1382
|
-
var _d = false;
|
|
1383
|
-
var _e = void 0;
|
|
1384
|
-
try {
|
|
1385
|
-
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
1386
|
-
_arr.push(_s.value);
|
|
1387
|
-
if (i && _arr.length === i) break;
|
|
1388
|
-
}
|
|
1389
|
-
} catch (err) {
|
|
1390
|
-
_d = true;
|
|
1391
|
-
_e = err;
|
|
1392
|
-
} finally {
|
|
1393
|
-
try {
|
|
1394
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
1395
|
-
} finally {
|
|
1396
|
-
if (_d) throw _e;
|
|
1397
|
-
}
|
|
1398
|
-
}
|
|
1399
|
-
return _arr;
|
|
1400
|
-
}
|
|
1401
|
-
__name(_iterableToArrayLimit, "_iterableToArrayLimit");
|
|
1402
|
-
function _arrayWithHoles(arr) {
|
|
1403
|
-
if (Array.isArray(arr)) return arr;
|
|
1404
|
-
}
|
|
1405
|
-
__name(_arrayWithHoles, "_arrayWithHoles");
|
|
1406
|
-
function asyncGeneratorStep(gen, resolve3, reject, _next, _throw, key, arg) {
|
|
1407
|
-
try {
|
|
1408
|
-
var info = gen[key](arg);
|
|
1409
|
-
var value = info.value;
|
|
1410
|
-
} catch (error) {
|
|
1411
|
-
reject(error);
|
|
1412
|
-
return;
|
|
1413
|
-
}
|
|
1414
|
-
if (info.done) {
|
|
1415
|
-
resolve3(value);
|
|
1416
|
-
} else {
|
|
1417
|
-
Promise.resolve(value).then(_next, _throw);
|
|
1418
|
-
}
|
|
1419
|
-
}
|
|
1420
|
-
__name(asyncGeneratorStep, "asyncGeneratorStep");
|
|
1421
|
-
function _asyncToGenerator(fn) {
|
|
1422
|
-
return function() {
|
|
1423
|
-
var self2 = this, args = arguments;
|
|
1424
|
-
return new Promise(function(resolve3, reject) {
|
|
1425
|
-
var gen = fn.apply(self2, args);
|
|
1426
|
-
function _next(value) {
|
|
1427
|
-
asyncGeneratorStep(gen, resolve3, reject, _next, _throw, "next", value);
|
|
1428
|
-
}
|
|
1429
|
-
__name(_next, "_next");
|
|
1430
|
-
function _throw(err) {
|
|
1431
|
-
asyncGeneratorStep(gen, resolve3, reject, _next, _throw, "throw", err);
|
|
1432
|
-
}
|
|
1433
|
-
__name(_throw, "_throw");
|
|
1434
|
-
_next(void 0);
|
|
1435
|
-
});
|
|
1436
|
-
};
|
|
1437
|
-
}
|
|
1438
|
-
__name(_asyncToGenerator, "_asyncToGenerator");
|
|
1439
|
-
var Events;
|
|
1440
|
-
var IORedisConnection;
|
|
1441
|
-
var Scripts;
|
|
1442
|
-
var parser;
|
|
1443
|
-
parser = require_parser();
|
|
1444
|
-
Events = require_Events();
|
|
1445
|
-
Scripts = require_Scripts();
|
|
1446
|
-
IORedisConnection = function() {
|
|
1447
|
-
class IORedisConnection {
|
|
1448
|
-
static {
|
|
1449
|
-
__name(this, "IORedisConnection");
|
|
1450
|
-
}
|
|
1451
|
-
constructor(options = {}) {
|
|
1452
|
-
parser.load(options, this.defaults, this);
|
|
1453
|
-
if (this.Redis == null) {
|
|
1454
|
-
this.Redis = eval("require")("ioredis");
|
|
1455
|
-
}
|
|
1456
|
-
if (this.Events == null) {
|
|
1457
|
-
this.Events = new Events(this);
|
|
1458
|
-
}
|
|
1459
|
-
this.terminated = false;
|
|
1460
|
-
if (this.clusterNodes != null) {
|
|
1461
|
-
this.client = new this.Redis.Cluster(this.clusterNodes, this.clientOptions);
|
|
1462
|
-
this.subscriber = new this.Redis.Cluster(this.clusterNodes, this.clientOptions);
|
|
1463
|
-
} else if (this.client != null && this.client.duplicate == null) {
|
|
1464
|
-
this.subscriber = new this.Redis.Cluster(this.client.startupNodes, this.client.options);
|
|
1465
|
-
} else {
|
|
1466
|
-
if (this.client == null) {
|
|
1467
|
-
this.client = new this.Redis(this.clientOptions);
|
|
1468
|
-
}
|
|
1469
|
-
this.subscriber = this.client.duplicate();
|
|
1470
|
-
}
|
|
1471
|
-
this.limiters = {};
|
|
1472
|
-
this.ready = this.Promise.all([this._setup(this.client, false), this._setup(this.subscriber, true)]).then(() => {
|
|
1473
|
-
this._loadScripts();
|
|
1474
|
-
return {
|
|
1475
|
-
client: this.client,
|
|
1476
|
-
subscriber: this.subscriber
|
|
1477
|
-
};
|
|
1478
|
-
});
|
|
1479
|
-
}
|
|
1480
|
-
_setup(client, sub) {
|
|
1481
|
-
client.setMaxListeners(0);
|
|
1482
|
-
return new this.Promise((resolve3, reject) => {
|
|
1483
|
-
client.on("error", (e) => {
|
|
1484
|
-
return this.Events.trigger("error", e);
|
|
1485
|
-
});
|
|
1486
|
-
if (sub) {
|
|
1487
|
-
client.on("message", (channel, message) => {
|
|
1488
|
-
var ref;
|
|
1489
|
-
return (ref = this.limiters[channel]) != null ? ref._store.onMessage(channel, message) : void 0;
|
|
1490
|
-
});
|
|
1491
|
-
}
|
|
1492
|
-
if (client.status === "ready") {
|
|
1493
|
-
return resolve3();
|
|
1494
|
-
} else {
|
|
1495
|
-
return client.once("ready", resolve3);
|
|
1496
|
-
}
|
|
1497
|
-
});
|
|
1498
|
-
}
|
|
1499
|
-
_loadScripts() {
|
|
1500
|
-
return Scripts.names.forEach((name2) => {
|
|
1501
|
-
return this.client.defineCommand(name2, {
|
|
1502
|
-
lua: Scripts.payload(name2)
|
|
1503
|
-
});
|
|
1504
|
-
});
|
|
1505
|
-
}
|
|
1506
|
-
__runCommand__(cmd) {
|
|
1507
|
-
var _this = this;
|
|
1508
|
-
return _asyncToGenerator(function* () {
|
|
1509
|
-
var _, deleted;
|
|
1510
|
-
yield _this.ready;
|
|
1511
|
-
var _ref = yield _this.client.pipeline([cmd]).exec();
|
|
1512
|
-
var _ref2 = _slicedToArray(_ref, 1);
|
|
1513
|
-
var _ref2$ = _slicedToArray(_ref2[0], 2);
|
|
1514
|
-
_ = _ref2$[0];
|
|
1515
|
-
deleted = _ref2$[1];
|
|
1516
|
-
return deleted;
|
|
1517
|
-
})();
|
|
1518
|
-
}
|
|
1519
|
-
__addLimiter__(instance) {
|
|
1520
|
-
return this.Promise.all([instance.channel(), instance.channel_client()].map((channel) => {
|
|
1521
|
-
return new this.Promise((resolve3, reject) => {
|
|
1522
|
-
return this.subscriber.subscribe(channel, () => {
|
|
1523
|
-
this.limiters[channel] = instance;
|
|
1524
|
-
return resolve3();
|
|
1525
|
-
});
|
|
1526
|
-
});
|
|
1527
|
-
}));
|
|
1528
|
-
}
|
|
1529
|
-
__removeLimiter__(instance) {
|
|
1530
|
-
var _this2 = this;
|
|
1531
|
-
return [instance.channel(), instance.channel_client()].forEach(
|
|
1532
|
-
/* @__PURE__ */ (function() {
|
|
1533
|
-
var _ref3 = _asyncToGenerator(function* (channel) {
|
|
1534
|
-
if (!_this2.terminated) {
|
|
1535
|
-
yield _this2.subscriber.unsubscribe(channel);
|
|
1536
|
-
}
|
|
1537
|
-
return delete _this2.limiters[channel];
|
|
1538
|
-
});
|
|
1539
|
-
return function(_x) {
|
|
1540
|
-
return _ref3.apply(this, arguments);
|
|
1541
|
-
};
|
|
1542
|
-
})()
|
|
1543
|
-
);
|
|
1544
|
-
}
|
|
1545
|
-
__scriptArgs__(name2, id, args, cb) {
|
|
1546
|
-
var keys;
|
|
1547
|
-
keys = Scripts.keys(name2, id);
|
|
1548
|
-
return [keys.length].concat(keys, args, cb);
|
|
1549
|
-
}
|
|
1550
|
-
__scriptFn__(name2) {
|
|
1551
|
-
return this.client[name2].bind(this.client);
|
|
1552
|
-
}
|
|
1553
|
-
disconnect(flush = true) {
|
|
1554
|
-
var i, k, len, ref;
|
|
1555
|
-
ref = Object.keys(this.limiters);
|
|
1556
|
-
for (i = 0, len = ref.length; i < len; i++) {
|
|
1557
|
-
k = ref[i];
|
|
1558
|
-
clearInterval(this.limiters[k]._store.heartbeat);
|
|
1559
|
-
}
|
|
1560
|
-
this.limiters = {};
|
|
1561
|
-
this.terminated = true;
|
|
1562
|
-
if (flush) {
|
|
1563
|
-
return this.Promise.all([this.client.quit(), this.subscriber.quit()]);
|
|
1564
|
-
} else {
|
|
1565
|
-
this.client.disconnect();
|
|
1566
|
-
this.subscriber.disconnect();
|
|
1567
|
-
return this.Promise.resolve();
|
|
1568
|
-
}
|
|
1569
|
-
}
|
|
1570
|
-
}
|
|
1571
|
-
;
|
|
1572
|
-
IORedisConnection.prototype.datastore = "ioredis";
|
|
1573
|
-
IORedisConnection.prototype.defaults = {
|
|
1574
|
-
Redis: null,
|
|
1575
|
-
clientOptions: {},
|
|
1576
|
-
clusterNodes: null,
|
|
1577
|
-
client: null,
|
|
1578
|
-
Promise,
|
|
1579
|
-
Events: null
|
|
1580
|
-
};
|
|
1581
|
-
return IORedisConnection;
|
|
1582
|
-
}.call(void 0);
|
|
1583
|
-
module.exports = IORedisConnection;
|
|
1584
|
-
}
|
|
1585
|
-
});
|
|
1586
|
-
|
|
1587
|
-
// node_modules/bottleneck/lib/RedisDatastore.js
|
|
1588
|
-
var require_RedisDatastore = __commonJS({
|
|
1589
|
-
"node_modules/bottleneck/lib/RedisDatastore.js"(exports2, module2) {
|
|
1590
|
-
"use strict";
|
|
1591
|
-
function _slicedToArray2(arr, i) {
|
|
1592
|
-
return _arrayWithHoles2(arr) || _iterableToArrayLimit2(arr, i) || _nonIterableRest2();
|
|
1593
|
-
}
|
|
1594
|
-
__name(_slicedToArray2, "_slicedToArray");
|
|
1595
|
-
function _nonIterableRest2() {
|
|
1596
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
|
1597
|
-
}
|
|
1598
|
-
__name(_nonIterableRest2, "_nonIterableRest");
|
|
1599
|
-
function _iterableToArrayLimit2(arr, i) {
|
|
1600
|
-
var _arr = [];
|
|
1601
|
-
var _n = true;
|
|
1602
|
-
var _d = false;
|
|
1603
|
-
var _e = void 0;
|
|
1604
|
-
try {
|
|
1605
|
-
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
1606
|
-
_arr.push(_s.value);
|
|
1607
|
-
if (i && _arr.length === i) break;
|
|
1608
|
-
}
|
|
1609
|
-
} catch (err) {
|
|
1610
|
-
_d = true;
|
|
1611
|
-
_e = err;
|
|
1612
|
-
} finally {
|
|
1613
|
-
try {
|
|
1614
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
1615
|
-
} finally {
|
|
1616
|
-
if (_d) throw _e;
|
|
1617
|
-
}
|
|
1618
|
-
}
|
|
1619
|
-
return _arr;
|
|
1620
|
-
}
|
|
1621
|
-
__name(_iterableToArrayLimit2, "_iterableToArrayLimit");
|
|
1622
|
-
function _arrayWithHoles2(arr) {
|
|
1623
|
-
if (Array.isArray(arr)) return arr;
|
|
1624
|
-
}
|
|
1625
|
-
__name(_arrayWithHoles2, "_arrayWithHoles");
|
|
1626
|
-
function asyncGeneratorStep2(gen, resolve3, reject, _next, _throw, key, arg) {
|
|
1627
|
-
try {
|
|
1628
|
-
var info = gen[key](arg);
|
|
1629
|
-
var value = info.value;
|
|
1630
|
-
} catch (error) {
|
|
1631
|
-
reject(error);
|
|
1632
|
-
return;
|
|
1633
|
-
}
|
|
1634
|
-
if (info.done) {
|
|
1635
|
-
resolve3(value);
|
|
1636
|
-
} else {
|
|
1637
|
-
Promise.resolve(value).then(_next, _throw);
|
|
1638
|
-
}
|
|
1639
|
-
}
|
|
1640
|
-
__name(asyncGeneratorStep2, "asyncGeneratorStep");
|
|
1641
|
-
function _asyncToGenerator2(fn) {
|
|
1642
|
-
return function() {
|
|
1643
|
-
var self2 = this, args = arguments;
|
|
1644
|
-
return new Promise(function(resolve3, reject) {
|
|
1645
|
-
var gen = fn.apply(self2, args);
|
|
1646
|
-
function _next(value) {
|
|
1647
|
-
asyncGeneratorStep2(gen, resolve3, reject, _next, _throw, "next", value);
|
|
1648
|
-
}
|
|
1649
|
-
__name(_next, "_next");
|
|
1650
|
-
function _throw(err) {
|
|
1651
|
-
asyncGeneratorStep2(gen, resolve3, reject, _next, _throw, "throw", err);
|
|
1652
|
-
}
|
|
1653
|
-
__name(_throw, "_throw");
|
|
1654
|
-
_next(void 0);
|
|
1655
|
-
});
|
|
1656
|
-
};
|
|
1657
|
-
}
|
|
1658
|
-
__name(_asyncToGenerator2, "_asyncToGenerator");
|
|
1659
|
-
var BottleneckError;
|
|
1660
|
-
var IORedisConnection2;
|
|
1661
|
-
var RedisConnection2;
|
|
1662
|
-
var RedisDatastore;
|
|
1663
|
-
var parser2;
|
|
1664
|
-
parser2 = require_parser();
|
|
1665
|
-
BottleneckError = require_BottleneckError();
|
|
1666
|
-
RedisConnection2 = require_RedisConnection();
|
|
1667
|
-
IORedisConnection2 = require_IORedisConnection();
|
|
1668
|
-
RedisDatastore = class RedisDatastore {
|
|
1669
|
-
static {
|
|
1670
|
-
__name(this, "RedisDatastore");
|
|
1671
|
-
}
|
|
1672
|
-
constructor(instance, storeOptions, storeInstanceOptions) {
|
|
1673
|
-
this.instance = instance;
|
|
1674
|
-
this.storeOptions = storeOptions;
|
|
1675
|
-
this.originalId = this.instance.id;
|
|
1676
|
-
this.clientId = this.instance._randomIndex();
|
|
1677
|
-
parser2.load(storeInstanceOptions, storeInstanceOptions, this);
|
|
1678
|
-
this.clients = {};
|
|
1679
|
-
this.capacityPriorityCounters = {};
|
|
1680
|
-
this.sharedConnection = this.connection != null;
|
|
1681
|
-
if (this.connection == null) {
|
|
1682
|
-
this.connection = this.instance.datastore === "redis" ? new RedisConnection2({
|
|
1683
|
-
Redis: this.Redis,
|
|
1684
|
-
clientOptions: this.clientOptions,
|
|
1685
|
-
Promise: this.Promise,
|
|
1686
|
-
Events: this.instance.Events
|
|
1687
|
-
}) : this.instance.datastore === "ioredis" ? new IORedisConnection2({
|
|
1688
|
-
Redis: this.Redis,
|
|
1689
|
-
clientOptions: this.clientOptions,
|
|
1690
|
-
clusterNodes: this.clusterNodes,
|
|
1691
|
-
Promise: this.Promise,
|
|
1692
|
-
Events: this.instance.Events
|
|
1693
|
-
}) : void 0;
|
|
1694
|
-
}
|
|
1695
|
-
this.instance.connection = this.connection;
|
|
1696
|
-
this.instance.datastore = this.connection.datastore;
|
|
1697
|
-
this.ready = this.connection.ready.then((clients) => {
|
|
1698
|
-
this.clients = clients;
|
|
1699
|
-
return this.runScript("init", this.prepareInitSettings(this.clearDatastore));
|
|
1700
|
-
}).then(() => {
|
|
1701
|
-
return this.connection.__addLimiter__(this.instance);
|
|
1702
|
-
}).then(() => {
|
|
1703
|
-
return this.runScript("register_client", [this.instance.queued()]);
|
|
1704
|
-
}).then(() => {
|
|
1705
|
-
var base;
|
|
1706
|
-
if (typeof (base = this.heartbeat = setInterval(() => {
|
|
1707
|
-
return this.runScript("heartbeat", []).catch((e) => {
|
|
1708
|
-
return this.instance.Events.trigger("error", e);
|
|
1709
|
-
});
|
|
1710
|
-
}, this.heartbeatInterval)).unref === "function") {
|
|
1711
|
-
base.unref();
|
|
1712
|
-
}
|
|
1713
|
-
return this.clients;
|
|
1714
|
-
});
|
|
1715
|
-
}
|
|
1716
|
-
__publish__(message) {
|
|
1717
|
-
var _this = this;
|
|
1718
|
-
return _asyncToGenerator2(function* () {
|
|
1719
|
-
var client;
|
|
1720
|
-
var _ref = yield _this.ready;
|
|
1721
|
-
client = _ref.client;
|
|
1722
|
-
return client.publish(_this.instance.channel(), `message:${message.toString()}`);
|
|
1723
|
-
})();
|
|
1724
|
-
}
|
|
1725
|
-
onMessage(channel, message) {
|
|
1726
|
-
var _this2 = this;
|
|
1727
|
-
return _asyncToGenerator2(function* () {
|
|
1728
|
-
var capacity, counter, data, drained, e, newCapacity, pos, priorityClient, rawCapacity, type;
|
|
1729
|
-
try {
|
|
1730
|
-
pos = message.indexOf(":");
|
|
1731
|
-
var _ref2 = [message.slice(0, pos), message.slice(pos + 1)];
|
|
1732
|
-
type = _ref2[0];
|
|
1733
|
-
data = _ref2[1];
|
|
1734
|
-
if (type === "capacity") {
|
|
1735
|
-
return yield _this2.instance._drainAll(data.length > 0 ? ~~data : void 0);
|
|
1736
|
-
} else if (type === "capacity-priority") {
|
|
1737
|
-
var _data$split = data.split(":");
|
|
1738
|
-
var _data$split2 = _slicedToArray2(_data$split, 3);
|
|
1739
|
-
rawCapacity = _data$split2[0];
|
|
1740
|
-
priorityClient = _data$split2[1];
|
|
1741
|
-
counter = _data$split2[2];
|
|
1742
|
-
capacity = rawCapacity.length > 0 ? ~~rawCapacity : void 0;
|
|
1743
|
-
if (priorityClient === _this2.clientId) {
|
|
1744
|
-
drained = yield _this2.instance._drainAll(capacity);
|
|
1745
|
-
newCapacity = capacity != null ? capacity - (drained || 0) : "";
|
|
1746
|
-
return yield _this2.clients.client.publish(_this2.instance.channel(), `capacity-priority:${newCapacity}::${counter}`);
|
|
1747
|
-
} else if (priorityClient === "") {
|
|
1748
|
-
clearTimeout(_this2.capacityPriorityCounters[counter]);
|
|
1749
|
-
delete _this2.capacityPriorityCounters[counter];
|
|
1750
|
-
return _this2.instance._drainAll(capacity);
|
|
1751
|
-
} else {
|
|
1752
|
-
return _this2.capacityPriorityCounters[counter] = setTimeout(
|
|
1753
|
-
/* @__PURE__ */ _asyncToGenerator2(function* () {
|
|
1754
|
-
var e2;
|
|
1755
|
-
try {
|
|
1756
|
-
delete _this2.capacityPriorityCounters[counter];
|
|
1757
|
-
yield _this2.runScript("blacklist_client", [priorityClient]);
|
|
1758
|
-
return yield _this2.instance._drainAll(capacity);
|
|
1759
|
-
} catch (error) {
|
|
1760
|
-
e2 = error;
|
|
1761
|
-
return _this2.instance.Events.trigger("error", e2);
|
|
1762
|
-
}
|
|
1763
|
-
}),
|
|
1764
|
-
1e3
|
|
1765
|
-
);
|
|
1766
|
-
}
|
|
1767
|
-
} else if (type === "message") {
|
|
1768
|
-
return _this2.instance.Events.trigger("message", data);
|
|
1769
|
-
} else if (type === "blocked") {
|
|
1770
|
-
return yield _this2.instance._dropAllQueued();
|
|
1771
|
-
}
|
|
1772
|
-
} catch (error) {
|
|
1773
|
-
e = error;
|
|
1774
|
-
return _this2.instance.Events.trigger("error", e);
|
|
1775
|
-
}
|
|
1776
|
-
})();
|
|
1777
|
-
}
|
|
1778
|
-
__disconnect__(flush) {
|
|
1779
|
-
clearInterval(this.heartbeat);
|
|
1780
|
-
if (this.sharedConnection) {
|
|
1781
|
-
return this.connection.__removeLimiter__(this.instance);
|
|
1782
|
-
} else {
|
|
1783
|
-
return this.connection.disconnect(flush);
|
|
1784
|
-
}
|
|
1785
|
-
}
|
|
1786
|
-
runScript(name2, args) {
|
|
1787
|
-
var _this3 = this;
|
|
1788
|
-
return _asyncToGenerator2(function* () {
|
|
1789
|
-
if (!(name2 === "init" || name2 === "register_client")) {
|
|
1790
|
-
yield _this3.ready;
|
|
1791
|
-
}
|
|
1792
|
-
return new _this3.Promise((resolve3, reject) => {
|
|
1793
|
-
var all_args, arr;
|
|
1794
|
-
all_args = [Date.now(), _this3.clientId].concat(args);
|
|
1795
|
-
_this3.instance.Events.trigger("debug", `Calling Redis script: ${name2}.lua`, all_args);
|
|
1796
|
-
arr = _this3.connection.__scriptArgs__(name2, _this3.originalId, all_args, function(err, replies) {
|
|
1797
|
-
if (err != null) {
|
|
1798
|
-
return reject(err);
|
|
1799
|
-
}
|
|
1800
|
-
return resolve3(replies);
|
|
1801
|
-
});
|
|
1802
|
-
return _this3.connection.__scriptFn__(name2)(...arr);
|
|
1803
|
-
}).catch((e) => {
|
|
1804
|
-
if (e.message === "SETTINGS_KEY_NOT_FOUND") {
|
|
1805
|
-
if (name2 === "heartbeat") {
|
|
1806
|
-
return _this3.Promise.resolve();
|
|
1807
|
-
} else {
|
|
1808
|
-
return _this3.runScript("init", _this3.prepareInitSettings(false)).then(() => {
|
|
1809
|
-
return _this3.runScript(name2, args);
|
|
1810
|
-
});
|
|
1811
|
-
}
|
|
1812
|
-
} else if (e.message === "UNKNOWN_CLIENT") {
|
|
1813
|
-
return _this3.runScript("register_client", [_this3.instance.queued()]).then(() => {
|
|
1814
|
-
return _this3.runScript(name2, args);
|
|
1815
|
-
});
|
|
1816
|
-
} else {
|
|
1817
|
-
return _this3.Promise.reject(e);
|
|
1818
|
-
}
|
|
1819
|
-
});
|
|
1820
|
-
})();
|
|
1821
|
-
}
|
|
1822
|
-
prepareArray(arr) {
|
|
1823
|
-
var i, len, results, x;
|
|
1824
|
-
results = [];
|
|
1825
|
-
for (i = 0, len = arr.length; i < len; i++) {
|
|
1826
|
-
x = arr[i];
|
|
1827
|
-
results.push(x != null ? x.toString() : "");
|
|
1828
|
-
}
|
|
1829
|
-
return results;
|
|
1830
|
-
}
|
|
1831
|
-
prepareObject(obj) {
|
|
1832
|
-
var arr, k, v;
|
|
1833
|
-
arr = [];
|
|
1834
|
-
for (k in obj) {
|
|
1835
|
-
v = obj[k];
|
|
1836
|
-
arr.push(k, v != null ? v.toString() : "");
|
|
1837
|
-
}
|
|
1838
|
-
return arr;
|
|
1839
|
-
}
|
|
1840
|
-
prepareInitSettings(clear) {
|
|
1841
|
-
var args;
|
|
1842
|
-
args = this.prepareObject(Object.assign({}, this.storeOptions, {
|
|
1843
|
-
id: this.originalId,
|
|
1844
|
-
version: this.instance.version,
|
|
1845
|
-
groupTimeout: this.timeout,
|
|
1846
|
-
clientTimeout: this.clientTimeout
|
|
1847
|
-
}));
|
|
1848
|
-
args.unshift(clear ? 1 : 0, this.instance.version);
|
|
1849
|
-
return args;
|
|
1850
|
-
}
|
|
1851
|
-
convertBool(b) {
|
|
1852
|
-
return !!b;
|
|
1853
|
-
}
|
|
1854
|
-
__updateSettings__(options2) {
|
|
1855
|
-
var _this4 = this;
|
|
1856
|
-
return _asyncToGenerator2(function* () {
|
|
1857
|
-
yield _this4.runScript("update_settings", _this4.prepareObject(options2));
|
|
1858
|
-
return parser2.overwrite(options2, options2, _this4.storeOptions);
|
|
1859
|
-
})();
|
|
1860
|
-
}
|
|
1861
|
-
__running__() {
|
|
1862
|
-
return this.runScript("running", []);
|
|
1863
|
-
}
|
|
1864
|
-
__queued__() {
|
|
1865
|
-
return this.runScript("queued", []);
|
|
1866
|
-
}
|
|
1867
|
-
__done__() {
|
|
1868
|
-
return this.runScript("done", []);
|
|
1869
|
-
}
|
|
1870
|
-
__groupCheck__() {
|
|
1871
|
-
var _this5 = this;
|
|
1872
|
-
return _asyncToGenerator2(function* () {
|
|
1873
|
-
return _this5.convertBool(yield _this5.runScript("group_check", []));
|
|
1874
|
-
})();
|
|
1875
|
-
}
|
|
1876
|
-
__incrementReservoir__(incr) {
|
|
1877
|
-
return this.runScript("increment_reservoir", [incr]);
|
|
1878
|
-
}
|
|
1879
|
-
__currentReservoir__() {
|
|
1880
|
-
return this.runScript("current_reservoir", []);
|
|
1881
|
-
}
|
|
1882
|
-
__check__(weight) {
|
|
1883
|
-
var _this6 = this;
|
|
1884
|
-
return _asyncToGenerator2(function* () {
|
|
1885
|
-
return _this6.convertBool(yield _this6.runScript("check", _this6.prepareArray([weight])));
|
|
1886
|
-
})();
|
|
1887
|
-
}
|
|
1888
|
-
__register__(index, weight, expiration) {
|
|
1889
|
-
var _this7 = this;
|
|
1890
|
-
return _asyncToGenerator2(function* () {
|
|
1891
|
-
var reservoir, success, wait;
|
|
1892
|
-
var _ref4 = yield _this7.runScript("register", _this7.prepareArray([index, weight, expiration]));
|
|
1893
|
-
var _ref5 = _slicedToArray2(_ref4, 3);
|
|
1894
|
-
success = _ref5[0];
|
|
1895
|
-
wait = _ref5[1];
|
|
1896
|
-
reservoir = _ref5[2];
|
|
1897
|
-
return {
|
|
1898
|
-
success: _this7.convertBool(success),
|
|
1899
|
-
wait,
|
|
1900
|
-
reservoir
|
|
1901
|
-
};
|
|
1902
|
-
})();
|
|
1903
|
-
}
|
|
1904
|
-
__submit__(queueLength, weight) {
|
|
1905
|
-
var _this8 = this;
|
|
1906
|
-
return _asyncToGenerator2(function* () {
|
|
1907
|
-
var blocked, e, maxConcurrent, overweight, reachedHWM, strategy;
|
|
1908
|
-
try {
|
|
1909
|
-
var _ref6 = yield _this8.runScript("submit", _this8.prepareArray([queueLength, weight]));
|
|
1910
|
-
var _ref7 = _slicedToArray2(_ref6, 3);
|
|
1911
|
-
reachedHWM = _ref7[0];
|
|
1912
|
-
blocked = _ref7[1];
|
|
1913
|
-
strategy = _ref7[2];
|
|
1914
|
-
return {
|
|
1915
|
-
reachedHWM: _this8.convertBool(reachedHWM),
|
|
1916
|
-
blocked: _this8.convertBool(blocked),
|
|
1917
|
-
strategy
|
|
1918
|
-
};
|
|
1919
|
-
} catch (error) {
|
|
1920
|
-
e = error;
|
|
1921
|
-
if (e.message.indexOf("OVERWEIGHT") === 0) {
|
|
1922
|
-
var _e$message$split = e.message.split(":");
|
|
1923
|
-
var _e$message$split2 = _slicedToArray2(_e$message$split, 3);
|
|
1924
|
-
overweight = _e$message$split2[0];
|
|
1925
|
-
weight = _e$message$split2[1];
|
|
1926
|
-
maxConcurrent = _e$message$split2[2];
|
|
1927
|
-
throw new BottleneckError(`Impossible to add a job having a weight of ${weight} to a limiter having a maxConcurrent setting of ${maxConcurrent}`);
|
|
1928
|
-
} else {
|
|
1929
|
-
throw e;
|
|
1930
|
-
}
|
|
1931
|
-
}
|
|
1932
|
-
})();
|
|
1933
|
-
}
|
|
1934
|
-
__free__(index, weight) {
|
|
1935
|
-
var _this9 = this;
|
|
1936
|
-
return _asyncToGenerator2(function* () {
|
|
1937
|
-
var running;
|
|
1938
|
-
running = yield _this9.runScript("free", _this9.prepareArray([index]));
|
|
1939
|
-
return {
|
|
1940
|
-
running
|
|
1941
|
-
};
|
|
1942
|
-
})();
|
|
1943
|
-
}
|
|
1944
|
-
};
|
|
1945
|
-
module2.exports = RedisDatastore;
|
|
1946
|
-
}
|
|
1947
|
-
});
|
|
1948
|
-
|
|
1949
|
-
// node_modules/bottleneck/lib/States.js
|
|
1950
|
-
var require_States = __commonJS({
|
|
1951
|
-
"node_modules/bottleneck/lib/States.js"(exports2, module2) {
|
|
1952
|
-
"use strict";
|
|
1953
|
-
var BottleneckError;
|
|
1954
|
-
var States;
|
|
1955
|
-
BottleneckError = require_BottleneckError();
|
|
1956
|
-
States = class States {
|
|
1957
|
-
static {
|
|
1958
|
-
__name(this, "States");
|
|
1959
|
-
}
|
|
1960
|
-
constructor(status1) {
|
|
1961
|
-
this.status = status1;
|
|
1962
|
-
this._jobs = {};
|
|
1963
|
-
this.counts = this.status.map(function() {
|
|
1964
|
-
return 0;
|
|
1965
|
-
});
|
|
1966
|
-
}
|
|
1967
|
-
next(id) {
|
|
1968
|
-
var current, next;
|
|
1969
|
-
current = this._jobs[id];
|
|
1970
|
-
next = current + 1;
|
|
1971
|
-
if (current != null && next < this.status.length) {
|
|
1972
|
-
this.counts[current]--;
|
|
1973
|
-
this.counts[next]++;
|
|
1974
|
-
return this._jobs[id]++;
|
|
1975
|
-
} else if (current != null) {
|
|
1976
|
-
this.counts[current]--;
|
|
1977
|
-
return delete this._jobs[id];
|
|
1978
|
-
}
|
|
1979
|
-
}
|
|
1980
|
-
start(id) {
|
|
1981
|
-
var initial;
|
|
1982
|
-
initial = 0;
|
|
1983
|
-
this._jobs[id] = initial;
|
|
1984
|
-
return this.counts[initial]++;
|
|
1985
|
-
}
|
|
1986
|
-
remove(id) {
|
|
1987
|
-
var current;
|
|
1988
|
-
current = this._jobs[id];
|
|
1989
|
-
if (current != null) {
|
|
1990
|
-
this.counts[current]--;
|
|
1991
|
-
delete this._jobs[id];
|
|
1992
|
-
}
|
|
1993
|
-
return current != null;
|
|
1994
|
-
}
|
|
1995
|
-
jobStatus(id) {
|
|
1996
|
-
var ref;
|
|
1997
|
-
return (ref = this.status[this._jobs[id]]) != null ? ref : null;
|
|
1998
|
-
}
|
|
1999
|
-
statusJobs(status) {
|
|
2000
|
-
var k, pos, ref, results, v;
|
|
2001
|
-
if (status != null) {
|
|
2002
|
-
pos = this.status.indexOf(status);
|
|
2003
|
-
if (pos < 0) {
|
|
2004
|
-
throw new BottleneckError(`status must be one of ${this.status.join(", ")}`);
|
|
2005
|
-
}
|
|
2006
|
-
ref = this._jobs;
|
|
2007
|
-
results = [];
|
|
2008
|
-
for (k in ref) {
|
|
2009
|
-
v = ref[k];
|
|
2010
|
-
if (v === pos) {
|
|
2011
|
-
results.push(k);
|
|
2012
|
-
}
|
|
2013
|
-
}
|
|
2014
|
-
return results;
|
|
2015
|
-
} else {
|
|
2016
|
-
return Object.keys(this._jobs);
|
|
2017
|
-
}
|
|
2018
|
-
}
|
|
2019
|
-
statusCounts() {
|
|
2020
|
-
return this.counts.reduce((acc, v, i) => {
|
|
2021
|
-
acc[this.status[i]] = v;
|
|
2022
|
-
return acc;
|
|
2023
|
-
}, {});
|
|
2024
|
-
}
|
|
2025
|
-
};
|
|
2026
|
-
module2.exports = States;
|
|
2027
|
-
}
|
|
2028
|
-
});
|
|
2029
|
-
|
|
2030
|
-
// node_modules/bottleneck/lib/Sync.js
|
|
2031
|
-
var require_Sync = __commonJS({
|
|
2032
|
-
"node_modules/bottleneck/lib/Sync.js"(exports2, module2) {
|
|
2033
|
-
"use strict";
|
|
2034
|
-
function asyncGeneratorStep2(gen, resolve3, reject, _next, _throw, key, arg) {
|
|
2035
|
-
try {
|
|
2036
|
-
var info = gen[key](arg);
|
|
2037
|
-
var value = info.value;
|
|
2038
|
-
} catch (error) {
|
|
2039
|
-
reject(error);
|
|
2040
|
-
return;
|
|
2041
|
-
}
|
|
2042
|
-
if (info.done) {
|
|
2043
|
-
resolve3(value);
|
|
2044
|
-
} else {
|
|
2045
|
-
Promise.resolve(value).then(_next, _throw);
|
|
2046
|
-
}
|
|
2047
|
-
}
|
|
2048
|
-
__name(asyncGeneratorStep2, "asyncGeneratorStep");
|
|
2049
|
-
function _asyncToGenerator2(fn) {
|
|
2050
|
-
return function() {
|
|
2051
|
-
var self2 = this, args = arguments;
|
|
2052
|
-
return new Promise(function(resolve3, reject) {
|
|
2053
|
-
var gen = fn.apply(self2, args);
|
|
2054
|
-
function _next(value) {
|
|
2055
|
-
asyncGeneratorStep2(gen, resolve3, reject, _next, _throw, "next", value);
|
|
2056
|
-
}
|
|
2057
|
-
__name(_next, "_next");
|
|
2058
|
-
function _throw(err) {
|
|
2059
|
-
asyncGeneratorStep2(gen, resolve3, reject, _next, _throw, "throw", err);
|
|
2060
|
-
}
|
|
2061
|
-
__name(_throw, "_throw");
|
|
2062
|
-
_next(void 0);
|
|
2063
|
-
});
|
|
2064
|
-
};
|
|
2065
|
-
}
|
|
2066
|
-
__name(_asyncToGenerator2, "_asyncToGenerator");
|
|
2067
|
-
var DLList;
|
|
2068
|
-
var Sync;
|
|
2069
|
-
DLList = require_DLList();
|
|
2070
|
-
Sync = class Sync {
|
|
2071
|
-
static {
|
|
2072
|
-
__name(this, "Sync");
|
|
2073
|
-
}
|
|
2074
|
-
constructor(name2, Promise2) {
|
|
2075
|
-
this.schedule = this.schedule.bind(this);
|
|
2076
|
-
this.name = name2;
|
|
2077
|
-
this.Promise = Promise2;
|
|
2078
|
-
this._running = 0;
|
|
2079
|
-
this._queue = new DLList();
|
|
2080
|
-
}
|
|
2081
|
-
isEmpty() {
|
|
2082
|
-
return this._queue.length === 0;
|
|
2083
|
-
}
|
|
2084
|
-
_tryToRun() {
|
|
2085
|
-
var _this = this;
|
|
2086
|
-
return _asyncToGenerator2(function* () {
|
|
2087
|
-
var args, cb, error, reject, resolve3, returned, task;
|
|
2088
|
-
if (_this._running < 1 && _this._queue.length > 0) {
|
|
2089
|
-
_this._running++;
|
|
2090
|
-
var _this$_queue$shift = _this._queue.shift();
|
|
2091
|
-
task = _this$_queue$shift.task;
|
|
2092
|
-
args = _this$_queue$shift.args;
|
|
2093
|
-
resolve3 = _this$_queue$shift.resolve;
|
|
2094
|
-
reject = _this$_queue$shift.reject;
|
|
2095
|
-
cb = yield _asyncToGenerator2(function* () {
|
|
2096
|
-
try {
|
|
2097
|
-
returned = yield task(...args);
|
|
2098
|
-
return function() {
|
|
2099
|
-
return resolve3(returned);
|
|
2100
|
-
};
|
|
2101
|
-
} catch (error1) {
|
|
2102
|
-
error = error1;
|
|
2103
|
-
return function() {
|
|
2104
|
-
return reject(error);
|
|
2105
|
-
};
|
|
2106
|
-
}
|
|
2107
|
-
})();
|
|
2108
|
-
_this._running--;
|
|
2109
|
-
_this._tryToRun();
|
|
2110
|
-
return cb();
|
|
2111
|
-
}
|
|
2112
|
-
})();
|
|
2113
|
-
}
|
|
2114
|
-
schedule(task, ...args) {
|
|
2115
|
-
var promise, reject, resolve3;
|
|
2116
|
-
resolve3 = reject = null;
|
|
2117
|
-
promise = new this.Promise(function(_resolve, _reject) {
|
|
2118
|
-
resolve3 = _resolve;
|
|
2119
|
-
return reject = _reject;
|
|
2120
|
-
});
|
|
2121
|
-
this._queue.push({
|
|
2122
|
-
task,
|
|
2123
|
-
args,
|
|
2124
|
-
resolve: resolve3,
|
|
2125
|
-
reject
|
|
2126
|
-
});
|
|
2127
|
-
this._tryToRun();
|
|
2128
|
-
return promise;
|
|
2129
|
-
}
|
|
2130
|
-
};
|
|
2131
|
-
module2.exports = Sync;
|
|
2132
|
-
}
|
|
2133
|
-
});
|
|
2134
|
-
|
|
2135
|
-
// node_modules/bottleneck/lib/version.json
|
|
2136
|
-
var require_version = __commonJS({
|
|
2137
|
-
"node_modules/bottleneck/lib/version.json"(exports2, module2) {
|
|
2138
|
-
module2.exports = { version: "2.19.5" };
|
|
2139
|
-
}
|
|
2140
|
-
});
|
|
2141
|
-
|
|
2142
|
-
// node_modules/bottleneck/lib/Group.js
|
|
2143
|
-
var require_Group = __commonJS({
|
|
2144
|
-
"node_modules/bottleneck/lib/Group.js"(exports2, module2) {
|
|
2145
|
-
"use strict";
|
|
2146
|
-
function _slicedToArray2(arr, i) {
|
|
2147
|
-
return _arrayWithHoles2(arr) || _iterableToArrayLimit2(arr, i) || _nonIterableRest2();
|
|
2148
|
-
}
|
|
2149
|
-
__name(_slicedToArray2, "_slicedToArray");
|
|
2150
|
-
function _nonIterableRest2() {
|
|
2151
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
|
2152
|
-
}
|
|
2153
|
-
__name(_nonIterableRest2, "_nonIterableRest");
|
|
2154
|
-
function _iterableToArrayLimit2(arr, i) {
|
|
2155
|
-
var _arr = [];
|
|
2156
|
-
var _n = true;
|
|
2157
|
-
var _d = false;
|
|
2158
|
-
var _e = void 0;
|
|
2159
|
-
try {
|
|
2160
|
-
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
2161
|
-
_arr.push(_s.value);
|
|
2162
|
-
if (i && _arr.length === i) break;
|
|
2163
|
-
}
|
|
2164
|
-
} catch (err) {
|
|
2165
|
-
_d = true;
|
|
2166
|
-
_e = err;
|
|
2167
|
-
} finally {
|
|
2168
|
-
try {
|
|
2169
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
2170
|
-
} finally {
|
|
2171
|
-
if (_d) throw _e;
|
|
2172
|
-
}
|
|
2173
|
-
}
|
|
2174
|
-
return _arr;
|
|
2175
|
-
}
|
|
2176
|
-
__name(_iterableToArrayLimit2, "_iterableToArrayLimit");
|
|
2177
|
-
function _arrayWithHoles2(arr) {
|
|
2178
|
-
if (Array.isArray(arr)) return arr;
|
|
2179
|
-
}
|
|
2180
|
-
__name(_arrayWithHoles2, "_arrayWithHoles");
|
|
2181
|
-
function asyncGeneratorStep2(gen, resolve3, reject, _next, _throw, key, arg) {
|
|
2182
|
-
try {
|
|
2183
|
-
var info = gen[key](arg);
|
|
2184
|
-
var value = info.value;
|
|
2185
|
-
} catch (error) {
|
|
2186
|
-
reject(error);
|
|
2187
|
-
return;
|
|
2188
|
-
}
|
|
2189
|
-
if (info.done) {
|
|
2190
|
-
resolve3(value);
|
|
2191
|
-
} else {
|
|
2192
|
-
Promise.resolve(value).then(_next, _throw);
|
|
2193
|
-
}
|
|
2194
|
-
}
|
|
2195
|
-
__name(asyncGeneratorStep2, "asyncGeneratorStep");
|
|
2196
|
-
function _asyncToGenerator2(fn) {
|
|
2197
|
-
return function() {
|
|
2198
|
-
var self2 = this, args = arguments;
|
|
2199
|
-
return new Promise(function(resolve3, reject) {
|
|
2200
|
-
var gen = fn.apply(self2, args);
|
|
2201
|
-
function _next(value) {
|
|
2202
|
-
asyncGeneratorStep2(gen, resolve3, reject, _next, _throw, "next", value);
|
|
2203
|
-
}
|
|
2204
|
-
__name(_next, "_next");
|
|
2205
|
-
function _throw(err) {
|
|
2206
|
-
asyncGeneratorStep2(gen, resolve3, reject, _next, _throw, "throw", err);
|
|
2207
|
-
}
|
|
2208
|
-
__name(_throw, "_throw");
|
|
2209
|
-
_next(void 0);
|
|
2210
|
-
});
|
|
2211
|
-
};
|
|
2212
|
-
}
|
|
2213
|
-
__name(_asyncToGenerator2, "_asyncToGenerator");
|
|
2214
|
-
var Events2;
|
|
2215
|
-
var Group;
|
|
2216
|
-
var IORedisConnection2;
|
|
2217
|
-
var RedisConnection2;
|
|
2218
|
-
var Scripts2;
|
|
2219
|
-
var parser2;
|
|
2220
|
-
parser2 = require_parser();
|
|
2221
|
-
Events2 = require_Events();
|
|
2222
|
-
RedisConnection2 = require_RedisConnection();
|
|
2223
|
-
IORedisConnection2 = require_IORedisConnection();
|
|
2224
|
-
Scripts2 = require_Scripts();
|
|
2225
|
-
Group = function() {
|
|
2226
|
-
class Group2 {
|
|
2227
|
-
static {
|
|
2228
|
-
__name(this, "Group");
|
|
2229
|
-
}
|
|
2230
|
-
constructor(limiterOptions = {}) {
|
|
2231
|
-
this.deleteKey = this.deleteKey.bind(this);
|
|
2232
|
-
this.limiterOptions = limiterOptions;
|
|
2233
|
-
parser2.load(this.limiterOptions, this.defaults, this);
|
|
2234
|
-
this.Events = new Events2(this);
|
|
2235
|
-
this.instances = {};
|
|
2236
|
-
this.Bottleneck = require_Bottleneck();
|
|
2237
|
-
this._startAutoCleanup();
|
|
2238
|
-
this.sharedConnection = this.connection != null;
|
|
2239
|
-
if (this.connection == null) {
|
|
2240
|
-
if (this.limiterOptions.datastore === "redis") {
|
|
2241
|
-
this.connection = new RedisConnection2(Object.assign({}, this.limiterOptions, {
|
|
2242
|
-
Events: this.Events
|
|
2243
|
-
}));
|
|
2244
|
-
} else if (this.limiterOptions.datastore === "ioredis") {
|
|
2245
|
-
this.connection = new IORedisConnection2(Object.assign({}, this.limiterOptions, {
|
|
2246
|
-
Events: this.Events
|
|
2247
|
-
}));
|
|
2248
|
-
}
|
|
2249
|
-
}
|
|
2250
|
-
}
|
|
2251
|
-
key(key = "") {
|
|
2252
|
-
var ref;
|
|
2253
|
-
return (ref = this.instances[key]) != null ? ref : (() => {
|
|
2254
|
-
var limiter;
|
|
2255
|
-
limiter = this.instances[key] = new this.Bottleneck(Object.assign(this.limiterOptions, {
|
|
2256
|
-
id: `${this.id}-${key}`,
|
|
2257
|
-
timeout: this.timeout,
|
|
2258
|
-
connection: this.connection
|
|
2259
|
-
}));
|
|
2260
|
-
this.Events.trigger("created", limiter, key);
|
|
2261
|
-
return limiter;
|
|
2262
|
-
})();
|
|
2263
|
-
}
|
|
2264
|
-
deleteKey(key = "") {
|
|
2265
|
-
var _this = this;
|
|
2266
|
-
return _asyncToGenerator2(function* () {
|
|
2267
|
-
var deleted, instance;
|
|
2268
|
-
instance = _this.instances[key];
|
|
2269
|
-
if (_this.connection) {
|
|
2270
|
-
deleted = yield _this.connection.__runCommand__(["del", ...Scripts2.allKeys(`${_this.id}-${key}`)]);
|
|
2271
|
-
}
|
|
2272
|
-
if (instance != null) {
|
|
2273
|
-
delete _this.instances[key];
|
|
2274
|
-
yield instance.disconnect();
|
|
2275
|
-
}
|
|
2276
|
-
return instance != null || deleted > 0;
|
|
2277
|
-
})();
|
|
2278
|
-
}
|
|
2279
|
-
limiters() {
|
|
2280
|
-
var k, ref, results, v;
|
|
2281
|
-
ref = this.instances;
|
|
2282
|
-
results = [];
|
|
2283
|
-
for (k in ref) {
|
|
2284
|
-
v = ref[k];
|
|
2285
|
-
results.push({
|
|
2286
|
-
key: k,
|
|
2287
|
-
limiter: v
|
|
2288
|
-
});
|
|
2289
|
-
}
|
|
2290
|
-
return results;
|
|
2291
|
-
}
|
|
2292
|
-
keys() {
|
|
2293
|
-
return Object.keys(this.instances);
|
|
2294
|
-
}
|
|
2295
|
-
clusterKeys() {
|
|
2296
|
-
var _this2 = this;
|
|
2297
|
-
return _asyncToGenerator2(function* () {
|
|
2298
|
-
var cursor, end, found, i, k, keys, len, next, start;
|
|
2299
|
-
if (_this2.connection == null) {
|
|
2300
|
-
return _this2.Promise.resolve(_this2.keys());
|
|
2301
|
-
}
|
|
2302
|
-
keys = [];
|
|
2303
|
-
cursor = null;
|
|
2304
|
-
start = `b_${_this2.id}-`.length;
|
|
2305
|
-
end = "_settings".length;
|
|
2306
|
-
while (cursor !== 0) {
|
|
2307
|
-
var _ref = yield _this2.connection.__runCommand__(["scan", cursor != null ? cursor : 0, "match", `b_${_this2.id}-*_settings`, "count", 1e4]);
|
|
2308
|
-
var _ref2 = _slicedToArray2(_ref, 2);
|
|
2309
|
-
next = _ref2[0];
|
|
2310
|
-
found = _ref2[1];
|
|
2311
|
-
cursor = ~~next;
|
|
2312
|
-
for (i = 0, len = found.length; i < len; i++) {
|
|
2313
|
-
k = found[i];
|
|
2314
|
-
keys.push(k.slice(start, -end));
|
|
2315
|
-
}
|
|
2316
|
-
}
|
|
2317
|
-
return keys;
|
|
2318
|
-
})();
|
|
2319
|
-
}
|
|
2320
|
-
_startAutoCleanup() {
|
|
2321
|
-
var _this3 = this;
|
|
2322
|
-
var base;
|
|
2323
|
-
clearInterval(this.interval);
|
|
2324
|
-
return typeof (base = this.interval = setInterval(
|
|
2325
|
-
/* @__PURE__ */ _asyncToGenerator2(function* () {
|
|
2326
|
-
var e, k, ref, results, time2, v;
|
|
2327
|
-
time2 = Date.now();
|
|
2328
|
-
ref = _this3.instances;
|
|
2329
|
-
results = [];
|
|
2330
|
-
for (k in ref) {
|
|
2331
|
-
v = ref[k];
|
|
2332
|
-
try {
|
|
2333
|
-
if (yield v._store.__groupCheck__(time2)) {
|
|
2334
|
-
results.push(_this3.deleteKey(k));
|
|
2335
|
-
} else {
|
|
2336
|
-
results.push(void 0);
|
|
2337
|
-
}
|
|
2338
|
-
} catch (error) {
|
|
2339
|
-
e = error;
|
|
2340
|
-
results.push(v.Events.trigger("error", e));
|
|
2341
|
-
}
|
|
2342
|
-
}
|
|
2343
|
-
return results;
|
|
2344
|
-
}),
|
|
2345
|
-
this.timeout / 2
|
|
2346
|
-
)).unref === "function" ? base.unref() : void 0;
|
|
2347
|
-
}
|
|
2348
|
-
updateSettings(options2 = {}) {
|
|
2349
|
-
parser2.overwrite(options2, this.defaults, this);
|
|
2350
|
-
parser2.overwrite(options2, options2, this.limiterOptions);
|
|
2351
|
-
if (options2.timeout != null) {
|
|
2352
|
-
return this._startAutoCleanup();
|
|
2353
|
-
}
|
|
2354
|
-
}
|
|
2355
|
-
disconnect(flush = true) {
|
|
2356
|
-
var ref;
|
|
2357
|
-
if (!this.sharedConnection) {
|
|
2358
|
-
return (ref = this.connection) != null ? ref.disconnect(flush) : void 0;
|
|
2359
|
-
}
|
|
2360
|
-
}
|
|
2361
|
-
}
|
|
2362
|
-
;
|
|
2363
|
-
Group2.prototype.defaults = {
|
|
2364
|
-
timeout: 1e3 * 60 * 5,
|
|
2365
|
-
connection: null,
|
|
2366
|
-
Promise,
|
|
2367
|
-
id: "group-key"
|
|
2368
|
-
};
|
|
2369
|
-
return Group2;
|
|
2370
|
-
}.call(void 0);
|
|
2371
|
-
module2.exports = Group;
|
|
2372
|
-
}
|
|
2373
|
-
});
|
|
2374
|
-
|
|
2375
|
-
// node_modules/bottleneck/lib/Batcher.js
|
|
2376
|
-
var require_Batcher = __commonJS({
|
|
2377
|
-
"node_modules/bottleneck/lib/Batcher.js"(exports2, module2) {
|
|
2378
|
-
"use strict";
|
|
2379
|
-
var Batcher;
|
|
2380
|
-
var Events2;
|
|
2381
|
-
var parser2;
|
|
2382
|
-
parser2 = require_parser();
|
|
2383
|
-
Events2 = require_Events();
|
|
2384
|
-
Batcher = function() {
|
|
2385
|
-
class Batcher2 {
|
|
2386
|
-
static {
|
|
2387
|
-
__name(this, "Batcher");
|
|
2388
|
-
}
|
|
2389
|
-
constructor(options2 = {}) {
|
|
2390
|
-
this.options = options2;
|
|
2391
|
-
parser2.load(this.options, this.defaults, this);
|
|
2392
|
-
this.Events = new Events2(this);
|
|
2393
|
-
this._arr = [];
|
|
2394
|
-
this._resetPromise();
|
|
2395
|
-
this._lastFlush = Date.now();
|
|
2396
|
-
}
|
|
2397
|
-
_resetPromise() {
|
|
2398
|
-
return this._promise = new this.Promise((res, rej) => {
|
|
2399
|
-
return this._resolve = res;
|
|
2400
|
-
});
|
|
2401
|
-
}
|
|
2402
|
-
_flush() {
|
|
2403
|
-
clearTimeout(this._timeout);
|
|
2404
|
-
this._lastFlush = Date.now();
|
|
2405
|
-
this._resolve();
|
|
2406
|
-
this.Events.trigger("batch", this._arr);
|
|
2407
|
-
this._arr = [];
|
|
2408
|
-
return this._resetPromise();
|
|
2409
|
-
}
|
|
2410
|
-
add(data) {
|
|
2411
|
-
var ret;
|
|
2412
|
-
this._arr.push(data);
|
|
2413
|
-
ret = this._promise;
|
|
2414
|
-
if (this._arr.length === this.maxSize) {
|
|
2415
|
-
this._flush();
|
|
2416
|
-
} else if (this.maxTime != null && this._arr.length === 1) {
|
|
2417
|
-
this._timeout = setTimeout(() => {
|
|
2418
|
-
return this._flush();
|
|
2419
|
-
}, this.maxTime);
|
|
2420
|
-
}
|
|
2421
|
-
return ret;
|
|
2422
|
-
}
|
|
2423
|
-
}
|
|
2424
|
-
;
|
|
2425
|
-
Batcher2.prototype.defaults = {
|
|
2426
|
-
maxTime: null,
|
|
2427
|
-
maxSize: null,
|
|
2428
|
-
Promise
|
|
2429
|
-
};
|
|
2430
|
-
return Batcher2;
|
|
2431
|
-
}.call(void 0);
|
|
2432
|
-
module2.exports = Batcher;
|
|
2433
|
-
}
|
|
2434
|
-
});
|
|
2435
|
-
|
|
2436
|
-
// node_modules/bottleneck/lib/Bottleneck.js
|
|
2437
|
-
var require_Bottleneck = __commonJS({
|
|
2438
|
-
"node_modules/bottleneck/lib/Bottleneck.js"(exports2, module2) {
|
|
2439
|
-
"use strict";
|
|
2440
|
-
function _slicedToArray2(arr, i) {
|
|
2441
|
-
return _arrayWithHoles2(arr) || _iterableToArrayLimit2(arr, i) || _nonIterableRest2();
|
|
2442
|
-
}
|
|
2443
|
-
__name(_slicedToArray2, "_slicedToArray");
|
|
2444
|
-
function _iterableToArrayLimit2(arr, i) {
|
|
2445
|
-
var _arr = [];
|
|
2446
|
-
var _n = true;
|
|
2447
|
-
var _d = false;
|
|
2448
|
-
var _e = void 0;
|
|
2449
|
-
try {
|
|
2450
|
-
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
2451
|
-
_arr.push(_s.value);
|
|
2452
|
-
if (i && _arr.length === i) break;
|
|
2453
|
-
}
|
|
2454
|
-
} catch (err) {
|
|
2455
|
-
_d = true;
|
|
2456
|
-
_e = err;
|
|
2457
|
-
} finally {
|
|
2458
|
-
try {
|
|
2459
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
2460
|
-
} finally {
|
|
2461
|
-
if (_d) throw _e;
|
|
2462
|
-
}
|
|
2463
|
-
}
|
|
2464
|
-
return _arr;
|
|
2465
|
-
}
|
|
2466
|
-
__name(_iterableToArrayLimit2, "_iterableToArrayLimit");
|
|
2467
|
-
function _toArray(arr) {
|
|
2468
|
-
return _arrayWithHoles2(arr) || _iterableToArray(arr) || _nonIterableRest2();
|
|
2469
|
-
}
|
|
2470
|
-
__name(_toArray, "_toArray");
|
|
2471
|
-
function _nonIterableRest2() {
|
|
2472
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
|
2473
|
-
}
|
|
2474
|
-
__name(_nonIterableRest2, "_nonIterableRest");
|
|
2475
|
-
function _iterableToArray(iter) {
|
|
2476
|
-
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
|
|
2477
|
-
}
|
|
2478
|
-
__name(_iterableToArray, "_iterableToArray");
|
|
2479
|
-
function _arrayWithHoles2(arr) {
|
|
2480
|
-
if (Array.isArray(arr)) return arr;
|
|
2481
|
-
}
|
|
2482
|
-
__name(_arrayWithHoles2, "_arrayWithHoles");
|
|
2483
|
-
function asyncGeneratorStep2(gen, resolve3, reject, _next, _throw, key, arg) {
|
|
2484
|
-
try {
|
|
2485
|
-
var info = gen[key](arg);
|
|
2486
|
-
var value = info.value;
|
|
2487
|
-
} catch (error) {
|
|
2488
|
-
reject(error);
|
|
2489
|
-
return;
|
|
2490
|
-
}
|
|
2491
|
-
if (info.done) {
|
|
2492
|
-
resolve3(value);
|
|
2493
|
-
} else {
|
|
2494
|
-
Promise.resolve(value).then(_next, _throw);
|
|
2495
|
-
}
|
|
2496
|
-
}
|
|
2497
|
-
__name(asyncGeneratorStep2, "asyncGeneratorStep");
|
|
2498
|
-
function _asyncToGenerator2(fn) {
|
|
2499
|
-
return function() {
|
|
2500
|
-
var self2 = this, args = arguments;
|
|
2501
|
-
return new Promise(function(resolve3, reject) {
|
|
2502
|
-
var gen = fn.apply(self2, args);
|
|
2503
|
-
function _next(value) {
|
|
2504
|
-
asyncGeneratorStep2(gen, resolve3, reject, _next, _throw, "next", value);
|
|
2505
|
-
}
|
|
2506
|
-
__name(_next, "_next");
|
|
2507
|
-
function _throw(err) {
|
|
2508
|
-
asyncGeneratorStep2(gen, resolve3, reject, _next, _throw, "throw", err);
|
|
2509
|
-
}
|
|
2510
|
-
__name(_throw, "_throw");
|
|
2511
|
-
_next(void 0);
|
|
2512
|
-
});
|
|
2513
|
-
};
|
|
2514
|
-
}
|
|
2515
|
-
__name(_asyncToGenerator2, "_asyncToGenerator");
|
|
2516
|
-
var Bottleneck2;
|
|
2517
|
-
var DEFAULT_PRIORITY;
|
|
2518
|
-
var Events2;
|
|
2519
|
-
var Job;
|
|
2520
|
-
var LocalDatastore;
|
|
2521
|
-
var NUM_PRIORITIES;
|
|
2522
|
-
var Queues;
|
|
2523
|
-
var RedisDatastore;
|
|
2524
|
-
var States;
|
|
2525
|
-
var Sync;
|
|
2526
|
-
var parser2;
|
|
2527
|
-
var splice = [].splice;
|
|
2528
|
-
NUM_PRIORITIES = 10;
|
|
2529
|
-
DEFAULT_PRIORITY = 5;
|
|
2530
|
-
parser2 = require_parser();
|
|
2531
|
-
Queues = require_Queues();
|
|
2532
|
-
Job = require_Job();
|
|
2533
|
-
LocalDatastore = require_LocalDatastore();
|
|
2534
|
-
RedisDatastore = require_RedisDatastore();
|
|
2535
|
-
Events2 = require_Events();
|
|
2536
|
-
States = require_States();
|
|
2537
|
-
Sync = require_Sync();
|
|
2538
|
-
Bottleneck2 = function() {
|
|
2539
|
-
class Bottleneck3 {
|
|
2540
|
-
static {
|
|
2541
|
-
__name(this, "Bottleneck");
|
|
2542
|
-
}
|
|
2543
|
-
constructor(options2 = {}, ...invalid) {
|
|
2544
|
-
var storeInstanceOptions, storeOptions;
|
|
2545
|
-
this._addToQueue = this._addToQueue.bind(this);
|
|
2546
|
-
this._validateOptions(options2, invalid);
|
|
2547
|
-
parser2.load(options2, this.instanceDefaults, this);
|
|
2548
|
-
this._queues = new Queues(NUM_PRIORITIES);
|
|
2549
|
-
this._scheduled = {};
|
|
2550
|
-
this._states = new States(["RECEIVED", "QUEUED", "RUNNING", "EXECUTING"].concat(this.trackDoneStatus ? ["DONE"] : []));
|
|
2551
|
-
this._limiter = null;
|
|
2552
|
-
this.Events = new Events2(this);
|
|
2553
|
-
this._submitLock = new Sync("submit", this.Promise);
|
|
2554
|
-
this._registerLock = new Sync("register", this.Promise);
|
|
2555
|
-
storeOptions = parser2.load(options2, this.storeDefaults, {});
|
|
2556
|
-
this._store = function() {
|
|
2557
|
-
if (this.datastore === "redis" || this.datastore === "ioredis" || this.connection != null) {
|
|
2558
|
-
storeInstanceOptions = parser2.load(options2, this.redisStoreDefaults, {});
|
|
2559
|
-
return new RedisDatastore(this, storeOptions, storeInstanceOptions);
|
|
2560
|
-
} else if (this.datastore === "local") {
|
|
2561
|
-
storeInstanceOptions = parser2.load(options2, this.localStoreDefaults, {});
|
|
2562
|
-
return new LocalDatastore(this, storeOptions, storeInstanceOptions);
|
|
2563
|
-
} else {
|
|
2564
|
-
throw new Bottleneck3.prototype.BottleneckError(`Invalid datastore type: ${this.datastore}`);
|
|
2565
|
-
}
|
|
2566
|
-
}.call(this);
|
|
2567
|
-
this._queues.on("leftzero", () => {
|
|
2568
|
-
var ref;
|
|
2569
|
-
return (ref = this._store.heartbeat) != null ? typeof ref.ref === "function" ? ref.ref() : void 0 : void 0;
|
|
2570
|
-
});
|
|
2571
|
-
this._queues.on("zero", () => {
|
|
2572
|
-
var ref;
|
|
2573
|
-
return (ref = this._store.heartbeat) != null ? typeof ref.unref === "function" ? ref.unref() : void 0 : void 0;
|
|
2574
|
-
});
|
|
2575
|
-
}
|
|
2576
|
-
_validateOptions(options2, invalid) {
|
|
2577
|
-
if (!(options2 != null && typeof options2 === "object" && invalid.length === 0)) {
|
|
2578
|
-
throw new Bottleneck3.prototype.BottleneckError("Bottleneck v2 takes a single object argument. Refer to https://github.com/SGrondin/bottleneck#upgrading-to-v2 if you're upgrading from Bottleneck v1.");
|
|
2579
|
-
}
|
|
2580
|
-
}
|
|
2581
|
-
ready() {
|
|
2582
|
-
return this._store.ready;
|
|
2583
|
-
}
|
|
2584
|
-
clients() {
|
|
2585
|
-
return this._store.clients;
|
|
2586
|
-
}
|
|
2587
|
-
channel() {
|
|
2588
|
-
return `b_${this.id}`;
|
|
2589
|
-
}
|
|
2590
|
-
channel_client() {
|
|
2591
|
-
return `b_${this.id}_${this._store.clientId}`;
|
|
2592
|
-
}
|
|
2593
|
-
publish(message) {
|
|
2594
|
-
return this._store.__publish__(message);
|
|
2595
|
-
}
|
|
2596
|
-
disconnect(flush = true) {
|
|
2597
|
-
return this._store.__disconnect__(flush);
|
|
2598
|
-
}
|
|
2599
|
-
chain(_limiter) {
|
|
2600
|
-
this._limiter = _limiter;
|
|
2601
|
-
return this;
|
|
2602
|
-
}
|
|
2603
|
-
queued(priority) {
|
|
2604
|
-
return this._queues.queued(priority);
|
|
2605
|
-
}
|
|
2606
|
-
clusterQueued() {
|
|
2607
|
-
return this._store.__queued__();
|
|
2608
|
-
}
|
|
2609
|
-
empty() {
|
|
2610
|
-
return this.queued() === 0 && this._submitLock.isEmpty();
|
|
2611
|
-
}
|
|
2612
|
-
running() {
|
|
2613
|
-
return this._store.__running__();
|
|
2614
|
-
}
|
|
2615
|
-
done() {
|
|
2616
|
-
return this._store.__done__();
|
|
2617
|
-
}
|
|
2618
|
-
jobStatus(id) {
|
|
2619
|
-
return this._states.jobStatus(id);
|
|
2620
|
-
}
|
|
2621
|
-
jobs(status) {
|
|
2622
|
-
return this._states.statusJobs(status);
|
|
2623
|
-
}
|
|
2624
|
-
counts() {
|
|
2625
|
-
return this._states.statusCounts();
|
|
2626
|
-
}
|
|
2627
|
-
_randomIndex() {
|
|
2628
|
-
return Math.random().toString(36).slice(2);
|
|
2629
|
-
}
|
|
2630
|
-
check(weight = 1) {
|
|
2631
|
-
return this._store.__check__(weight);
|
|
2632
|
-
}
|
|
2633
|
-
_clearGlobalState(index) {
|
|
2634
|
-
if (this._scheduled[index] != null) {
|
|
2635
|
-
clearTimeout(this._scheduled[index].expiration);
|
|
2636
|
-
delete this._scheduled[index];
|
|
2637
|
-
return true;
|
|
2638
|
-
} else {
|
|
2639
|
-
return false;
|
|
2640
|
-
}
|
|
2641
|
-
}
|
|
2642
|
-
_free(index, job, options2, eventInfo) {
|
|
2643
|
-
var _this = this;
|
|
2644
|
-
return _asyncToGenerator2(function* () {
|
|
2645
|
-
var e, running;
|
|
2646
|
-
try {
|
|
2647
|
-
var _ref = yield _this._store.__free__(index, options2.weight);
|
|
2648
|
-
running = _ref.running;
|
|
2649
|
-
_this.Events.trigger("debug", `Freed ${options2.id}`, eventInfo);
|
|
2650
|
-
if (running === 0 && _this.empty()) {
|
|
2651
|
-
return _this.Events.trigger("idle");
|
|
2652
|
-
}
|
|
2653
|
-
} catch (error1) {
|
|
2654
|
-
e = error1;
|
|
2655
|
-
return _this.Events.trigger("error", e);
|
|
2656
|
-
}
|
|
2657
|
-
})();
|
|
2658
|
-
}
|
|
2659
|
-
_run(index, job, wait) {
|
|
2660
|
-
var clearGlobalState, free, run;
|
|
2661
|
-
job.doRun();
|
|
2662
|
-
clearGlobalState = this._clearGlobalState.bind(this, index);
|
|
2663
|
-
run = this._run.bind(this, index, job);
|
|
2664
|
-
free = this._free.bind(this, index, job);
|
|
2665
|
-
return this._scheduled[index] = {
|
|
2666
|
-
timeout: setTimeout(() => {
|
|
2667
|
-
return job.doExecute(this._limiter, clearGlobalState, run, free);
|
|
2668
|
-
}, wait),
|
|
2669
|
-
expiration: job.options.expiration != null ? setTimeout(function() {
|
|
2670
|
-
return job.doExpire(clearGlobalState, run, free);
|
|
2671
|
-
}, wait + job.options.expiration) : void 0,
|
|
2672
|
-
job
|
|
2673
|
-
};
|
|
2674
|
-
}
|
|
2675
|
-
_drainOne(capacity) {
|
|
2676
|
-
return this._registerLock.schedule(() => {
|
|
2677
|
-
var args, index, next, options2, queue;
|
|
2678
|
-
if (this.queued() === 0) {
|
|
2679
|
-
return this.Promise.resolve(null);
|
|
2680
|
-
}
|
|
2681
|
-
queue = this._queues.getFirst();
|
|
2682
|
-
var _next2 = next = queue.first();
|
|
2683
|
-
options2 = _next2.options;
|
|
2684
|
-
args = _next2.args;
|
|
2685
|
-
if (capacity != null && options2.weight > capacity) {
|
|
2686
|
-
return this.Promise.resolve(null);
|
|
2687
|
-
}
|
|
2688
|
-
this.Events.trigger("debug", `Draining ${options2.id}`, {
|
|
2689
|
-
args,
|
|
2690
|
-
options: options2
|
|
2691
|
-
});
|
|
2692
|
-
index = this._randomIndex();
|
|
2693
|
-
return this._store.__register__(index, options2.weight, options2.expiration).then(({
|
|
2694
|
-
success,
|
|
2695
|
-
wait,
|
|
2696
|
-
reservoir
|
|
2697
|
-
}) => {
|
|
2698
|
-
var empty;
|
|
2699
|
-
this.Events.trigger("debug", `Drained ${options2.id}`, {
|
|
2700
|
-
success,
|
|
2701
|
-
args,
|
|
2702
|
-
options: options2
|
|
2703
|
-
});
|
|
2704
|
-
if (success) {
|
|
2705
|
-
queue.shift();
|
|
2706
|
-
empty = this.empty();
|
|
2707
|
-
if (empty) {
|
|
2708
|
-
this.Events.trigger("empty");
|
|
2709
|
-
}
|
|
2710
|
-
if (reservoir === 0) {
|
|
2711
|
-
this.Events.trigger("depleted", empty);
|
|
2712
|
-
}
|
|
2713
|
-
this._run(index, next, wait);
|
|
2714
|
-
return this.Promise.resolve(options2.weight);
|
|
2715
|
-
} else {
|
|
2716
|
-
return this.Promise.resolve(null);
|
|
2717
|
-
}
|
|
2718
|
-
});
|
|
2719
|
-
});
|
|
2720
|
-
}
|
|
2721
|
-
_drainAll(capacity, total = 0) {
|
|
2722
|
-
return this._drainOne(capacity).then((drained) => {
|
|
2723
|
-
var newCapacity;
|
|
2724
|
-
if (drained != null) {
|
|
2725
|
-
newCapacity = capacity != null ? capacity - drained : capacity;
|
|
2726
|
-
return this._drainAll(newCapacity, total + drained);
|
|
2727
|
-
} else {
|
|
2728
|
-
return this.Promise.resolve(total);
|
|
2729
|
-
}
|
|
2730
|
-
}).catch((e) => {
|
|
2731
|
-
return this.Events.trigger("error", e);
|
|
2732
|
-
});
|
|
2733
|
-
}
|
|
2734
|
-
_dropAllQueued(message) {
|
|
2735
|
-
return this._queues.shiftAll(function(job) {
|
|
2736
|
-
return job.doDrop({
|
|
2737
|
-
message
|
|
2738
|
-
});
|
|
2739
|
-
});
|
|
2740
|
-
}
|
|
2741
|
-
stop(options2 = {}) {
|
|
2742
|
-
var done, waitForExecuting;
|
|
2743
|
-
options2 = parser2.load(options2, this.stopDefaults);
|
|
2744
|
-
waitForExecuting = /* @__PURE__ */ __name((at) => {
|
|
2745
|
-
var finished;
|
|
2746
|
-
finished = /* @__PURE__ */ __name(() => {
|
|
2747
|
-
var counts;
|
|
2748
|
-
counts = this._states.counts;
|
|
2749
|
-
return counts[0] + counts[1] + counts[2] + counts[3] === at;
|
|
2750
|
-
}, "finished");
|
|
2751
|
-
return new this.Promise((resolve3, reject) => {
|
|
2752
|
-
if (finished()) {
|
|
2753
|
-
return resolve3();
|
|
2754
|
-
} else {
|
|
2755
|
-
return this.on("done", () => {
|
|
2756
|
-
if (finished()) {
|
|
2757
|
-
this.removeAllListeners("done");
|
|
2758
|
-
return resolve3();
|
|
2759
|
-
}
|
|
2760
|
-
});
|
|
2761
|
-
}
|
|
2762
|
-
});
|
|
2763
|
-
}, "waitForExecuting");
|
|
2764
|
-
done = options2.dropWaitingJobs ? (this._run = function(index, next) {
|
|
2765
|
-
return next.doDrop({
|
|
2766
|
-
message: options2.dropErrorMessage
|
|
2767
|
-
});
|
|
2768
|
-
}, this._drainOne = () => {
|
|
2769
|
-
return this.Promise.resolve(null);
|
|
2770
|
-
}, this._registerLock.schedule(() => {
|
|
2771
|
-
return this._submitLock.schedule(() => {
|
|
2772
|
-
var k, ref, v;
|
|
2773
|
-
ref = this._scheduled;
|
|
2774
|
-
for (k in ref) {
|
|
2775
|
-
v = ref[k];
|
|
2776
|
-
if (this.jobStatus(v.job.options.id) === "RUNNING") {
|
|
2777
|
-
clearTimeout(v.timeout);
|
|
2778
|
-
clearTimeout(v.expiration);
|
|
2779
|
-
v.job.doDrop({
|
|
2780
|
-
message: options2.dropErrorMessage
|
|
2781
|
-
});
|
|
2782
|
-
}
|
|
2783
|
-
}
|
|
2784
|
-
this._dropAllQueued(options2.dropErrorMessage);
|
|
2785
|
-
return waitForExecuting(0);
|
|
2786
|
-
});
|
|
2787
|
-
})) : this.schedule({
|
|
2788
|
-
priority: NUM_PRIORITIES - 1,
|
|
2789
|
-
weight: 0
|
|
2790
|
-
}, () => {
|
|
2791
|
-
return waitForExecuting(1);
|
|
2792
|
-
});
|
|
2793
|
-
this._receive = function(job) {
|
|
2794
|
-
return job._reject(new Bottleneck3.prototype.BottleneckError(options2.enqueueErrorMessage));
|
|
2795
|
-
};
|
|
2796
|
-
this.stop = () => {
|
|
2797
|
-
return this.Promise.reject(new Bottleneck3.prototype.BottleneckError("stop() has already been called"));
|
|
2798
|
-
};
|
|
2799
|
-
return done;
|
|
2800
|
-
}
|
|
2801
|
-
_addToQueue(job) {
|
|
2802
|
-
var _this2 = this;
|
|
2803
|
-
return _asyncToGenerator2(function* () {
|
|
2804
|
-
var args, blocked, error, options2, reachedHWM, shifted, strategy;
|
|
2805
|
-
args = job.args;
|
|
2806
|
-
options2 = job.options;
|
|
2807
|
-
try {
|
|
2808
|
-
var _ref2 = yield _this2._store.__submit__(_this2.queued(), options2.weight);
|
|
2809
|
-
reachedHWM = _ref2.reachedHWM;
|
|
2810
|
-
blocked = _ref2.blocked;
|
|
2811
|
-
strategy = _ref2.strategy;
|
|
2812
|
-
} catch (error1) {
|
|
2813
|
-
error = error1;
|
|
2814
|
-
_this2.Events.trigger("debug", `Could not queue ${options2.id}`, {
|
|
2815
|
-
args,
|
|
2816
|
-
options: options2,
|
|
2817
|
-
error
|
|
2818
|
-
});
|
|
2819
|
-
job.doDrop({
|
|
2820
|
-
error
|
|
2821
|
-
});
|
|
2822
|
-
return false;
|
|
2823
|
-
}
|
|
2824
|
-
if (blocked) {
|
|
2825
|
-
job.doDrop();
|
|
2826
|
-
return true;
|
|
2827
|
-
} else if (reachedHWM) {
|
|
2828
|
-
shifted = strategy === Bottleneck3.prototype.strategy.LEAK ? _this2._queues.shiftLastFrom(options2.priority) : strategy === Bottleneck3.prototype.strategy.OVERFLOW_PRIORITY ? _this2._queues.shiftLastFrom(options2.priority + 1) : strategy === Bottleneck3.prototype.strategy.OVERFLOW ? job : void 0;
|
|
2829
|
-
if (shifted != null) {
|
|
2830
|
-
shifted.doDrop();
|
|
2831
|
-
}
|
|
2832
|
-
if (shifted == null || strategy === Bottleneck3.prototype.strategy.OVERFLOW) {
|
|
2833
|
-
if (shifted == null) {
|
|
2834
|
-
job.doDrop();
|
|
2835
|
-
}
|
|
2836
|
-
return reachedHWM;
|
|
2837
|
-
}
|
|
2838
|
-
}
|
|
2839
|
-
job.doQueue(reachedHWM, blocked);
|
|
2840
|
-
_this2._queues.push(job);
|
|
2841
|
-
yield _this2._drainAll();
|
|
2842
|
-
return reachedHWM;
|
|
2843
|
-
})();
|
|
2844
|
-
}
|
|
2845
|
-
_receive(job) {
|
|
2846
|
-
if (this._states.jobStatus(job.options.id) != null) {
|
|
2847
|
-
job._reject(new Bottleneck3.prototype.BottleneckError(`A job with the same id already exists (id=${job.options.id})`));
|
|
2848
|
-
return false;
|
|
2849
|
-
} else {
|
|
2850
|
-
job.doReceive();
|
|
2851
|
-
return this._submitLock.schedule(this._addToQueue, job);
|
|
2852
|
-
}
|
|
2853
|
-
}
|
|
2854
|
-
submit(...args) {
|
|
2855
|
-
var cb, fn, job, options2, ref, ref1, task;
|
|
2856
|
-
if (typeof args[0] === "function") {
|
|
2857
|
-
var _ref3, _ref4, _splice$call, _splice$call2;
|
|
2858
|
-
ref = args, _ref3 = ref, _ref4 = _toArray(_ref3), fn = _ref4[0], args = _ref4.slice(1), _ref3, _splice$call = splice.call(args, -1), _splice$call2 = _slicedToArray2(_splice$call, 1), cb = _splice$call2[0], _splice$call;
|
|
2859
|
-
options2 = parser2.load({}, this.jobDefaults);
|
|
2860
|
-
} else {
|
|
2861
|
-
var _ref5, _ref6, _splice$call3, _splice$call4;
|
|
2862
|
-
ref1 = args, _ref5 = ref1, _ref6 = _toArray(_ref5), options2 = _ref6[0], fn = _ref6[1], args = _ref6.slice(2), _ref5, _splice$call3 = splice.call(args, -1), _splice$call4 = _slicedToArray2(_splice$call3, 1), cb = _splice$call4[0], _splice$call3;
|
|
2863
|
-
options2 = parser2.load(options2, this.jobDefaults);
|
|
2864
|
-
}
|
|
2865
|
-
task = /* @__PURE__ */ __name((...args2) => {
|
|
2866
|
-
return new this.Promise(function(resolve3, reject) {
|
|
2867
|
-
return fn(...args2, function(...args3) {
|
|
2868
|
-
return (args3[0] != null ? reject : resolve3)(args3);
|
|
2869
|
-
});
|
|
2870
|
-
});
|
|
2871
|
-
}, "task");
|
|
2872
|
-
job = new Job(task, args, options2, this.jobDefaults, this.rejectOnDrop, this.Events, this._states, this.Promise);
|
|
2873
|
-
job.promise.then(function(args2) {
|
|
2874
|
-
return typeof cb === "function" ? cb(...args2) : void 0;
|
|
2875
|
-
}).catch(function(args2) {
|
|
2876
|
-
if (Array.isArray(args2)) {
|
|
2877
|
-
return typeof cb === "function" ? cb(...args2) : void 0;
|
|
2878
|
-
} else {
|
|
2879
|
-
return typeof cb === "function" ? cb(args2) : void 0;
|
|
2880
|
-
}
|
|
2881
|
-
});
|
|
2882
|
-
return this._receive(job);
|
|
2883
|
-
}
|
|
2884
|
-
schedule(...args) {
|
|
2885
|
-
var job, options2, task;
|
|
2886
|
-
if (typeof args[0] === "function") {
|
|
2887
|
-
var _args = args;
|
|
2888
|
-
var _args2 = _toArray(_args);
|
|
2889
|
-
task = _args2[0];
|
|
2890
|
-
args = _args2.slice(1);
|
|
2891
|
-
options2 = {};
|
|
2892
|
-
} else {
|
|
2893
|
-
var _args3 = args;
|
|
2894
|
-
var _args4 = _toArray(_args3);
|
|
2895
|
-
options2 = _args4[0];
|
|
2896
|
-
task = _args4[1];
|
|
2897
|
-
args = _args4.slice(2);
|
|
2898
|
-
}
|
|
2899
|
-
job = new Job(task, args, options2, this.jobDefaults, this.rejectOnDrop, this.Events, this._states, this.Promise);
|
|
2900
|
-
this._receive(job);
|
|
2901
|
-
return job.promise;
|
|
2902
|
-
}
|
|
2903
|
-
wrap(fn) {
|
|
2904
|
-
var schedule, wrapped;
|
|
2905
|
-
schedule = this.schedule.bind(this);
|
|
2906
|
-
wrapped = /* @__PURE__ */ __name(function wrapped2(...args) {
|
|
2907
|
-
return schedule(fn.bind(this), ...args);
|
|
2908
|
-
}, "wrapped");
|
|
2909
|
-
wrapped.withOptions = function(options2, ...args) {
|
|
2910
|
-
return schedule(options2, fn, ...args);
|
|
2911
|
-
};
|
|
2912
|
-
return wrapped;
|
|
2913
|
-
}
|
|
2914
|
-
updateSettings(options2 = {}) {
|
|
2915
|
-
var _this3 = this;
|
|
2916
|
-
return _asyncToGenerator2(function* () {
|
|
2917
|
-
yield _this3._store.__updateSettings__(parser2.overwrite(options2, _this3.storeDefaults));
|
|
2918
|
-
parser2.overwrite(options2, _this3.instanceDefaults, _this3);
|
|
2919
|
-
return _this3;
|
|
2920
|
-
})();
|
|
2921
|
-
}
|
|
2922
|
-
currentReservoir() {
|
|
2923
|
-
return this._store.__currentReservoir__();
|
|
2924
|
-
}
|
|
2925
|
-
incrementReservoir(incr = 0) {
|
|
2926
|
-
return this._store.__incrementReservoir__(incr);
|
|
2927
|
-
}
|
|
2928
|
-
}
|
|
2929
|
-
;
|
|
2930
|
-
Bottleneck3.default = Bottleneck3;
|
|
2931
|
-
Bottleneck3.Events = Events2;
|
|
2932
|
-
Bottleneck3.version = Bottleneck3.prototype.version = require_version().version;
|
|
2933
|
-
Bottleneck3.strategy = Bottleneck3.prototype.strategy = {
|
|
2934
|
-
LEAK: 1,
|
|
2935
|
-
OVERFLOW: 2,
|
|
2936
|
-
OVERFLOW_PRIORITY: 4,
|
|
2937
|
-
BLOCK: 3
|
|
2938
|
-
};
|
|
2939
|
-
Bottleneck3.BottleneckError = Bottleneck3.prototype.BottleneckError = require_BottleneckError();
|
|
2940
|
-
Bottleneck3.Group = Bottleneck3.prototype.Group = require_Group();
|
|
2941
|
-
Bottleneck3.RedisConnection = Bottleneck3.prototype.RedisConnection = require_RedisConnection();
|
|
2942
|
-
Bottleneck3.IORedisConnection = Bottleneck3.prototype.IORedisConnection = require_IORedisConnection();
|
|
2943
|
-
Bottleneck3.Batcher = Bottleneck3.prototype.Batcher = require_Batcher();
|
|
2944
|
-
Bottleneck3.prototype.jobDefaults = {
|
|
2945
|
-
priority: DEFAULT_PRIORITY,
|
|
2946
|
-
weight: 1,
|
|
2947
|
-
expiration: null,
|
|
2948
|
-
id: "<no-id>"
|
|
2949
|
-
};
|
|
2950
|
-
Bottleneck3.prototype.storeDefaults = {
|
|
2951
|
-
maxConcurrent: null,
|
|
2952
|
-
minTime: 0,
|
|
2953
|
-
highWater: null,
|
|
2954
|
-
strategy: Bottleneck3.prototype.strategy.LEAK,
|
|
2955
|
-
penalty: null,
|
|
2956
|
-
reservoir: null,
|
|
2957
|
-
reservoirRefreshInterval: null,
|
|
2958
|
-
reservoirRefreshAmount: null,
|
|
2959
|
-
reservoirIncreaseInterval: null,
|
|
2960
|
-
reservoirIncreaseAmount: null,
|
|
2961
|
-
reservoirIncreaseMaximum: null
|
|
2962
|
-
};
|
|
2963
|
-
Bottleneck3.prototype.localStoreDefaults = {
|
|
2964
|
-
Promise,
|
|
2965
|
-
timeout: null,
|
|
2966
|
-
heartbeatInterval: 250
|
|
2967
|
-
};
|
|
2968
|
-
Bottleneck3.prototype.redisStoreDefaults = {
|
|
2969
|
-
Promise,
|
|
2970
|
-
timeout: null,
|
|
2971
|
-
heartbeatInterval: 5e3,
|
|
2972
|
-
clientTimeout: 1e4,
|
|
2973
|
-
Redis: null,
|
|
2974
|
-
clientOptions: {},
|
|
2975
|
-
clusterNodes: null,
|
|
2976
|
-
clearDatastore: false,
|
|
2977
|
-
connection: null
|
|
2978
|
-
};
|
|
2979
|
-
Bottleneck3.prototype.instanceDefaults = {
|
|
2980
|
-
datastore: "local",
|
|
2981
|
-
connection: null,
|
|
2982
|
-
id: "<no-id>",
|
|
2983
|
-
rejectOnDrop: true,
|
|
2984
|
-
trackDoneStatus: false,
|
|
2985
|
-
Promise
|
|
2986
|
-
};
|
|
2987
|
-
Bottleneck3.prototype.stopDefaults = {
|
|
2988
|
-
enqueueErrorMessage: "This limiter has been stopped and cannot accept new jobs.",
|
|
2989
|
-
dropWaitingJobs: true,
|
|
2990
|
-
dropErrorMessage: "This limiter has been stopped."
|
|
2991
|
-
};
|
|
2992
|
-
return Bottleneck3;
|
|
2993
|
-
}.call(void 0);
|
|
2994
|
-
module2.exports = Bottleneck2;
|
|
2995
|
-
}
|
|
2996
|
-
});
|
|
2997
|
-
|
|
2998
|
-
// node_modules/bottleneck/lib/index.js
|
|
2999
|
-
var require_lib = __commonJS({
|
|
3000
|
-
"node_modules/bottleneck/lib/index.js"(exports2, module2) {
|
|
3001
|
-
"use strict";
|
|
3002
|
-
module2.exports = require_Bottleneck();
|
|
3003
|
-
}
|
|
3004
|
-
});
|
|
3005
|
-
|
|
3006
37
|
// node_modules/reflect-metadata/Reflect.js
|
|
3007
38
|
var require_Reflect = __commonJS({
|
|
3008
39
|
"node_modules/reflect-metadata/Reflect.js"() {
|
|
@@ -4254,6 +1285,7 @@ var messages = {
|
|
|
4254
1285
|
"relic.dataLoading": "遗物数据未加载完成,请稍后再试",
|
|
4255
1286
|
"relic.notFound": "未找到对应遗物信息",
|
|
4256
1287
|
"arbitration.invalidDayRange": "天数需小于等于14且大于0",
|
|
1288
|
+
"bounty.unavailable": "当前该地点暂无可用赏金",
|
|
4257
1289
|
"voidTrader.drifting": "虚空商人仍在未知地带漂流...",
|
|
4258
1290
|
"voidTrader.arriving": "距离虚空商人到达还有: {time}",
|
|
4259
1291
|
"riven.imageNotFound": "未检测到图片",
|
|
@@ -4576,7 +1608,7 @@ async function getHotRivenWeapons2() {
|
|
|
4576
1608
|
__name(getHotRivenWeapons2, "getHotRivenWeapons");
|
|
4577
1609
|
|
|
4578
1610
|
// src/warframe/services/wf-service.ts
|
|
4579
|
-
var
|
|
1611
|
+
var import_warframe_public_export_plus7 = require("warframe-public-export-plus");
|
|
4580
1612
|
|
|
4581
1613
|
// src/warframe/assets/index.ts
|
|
4582
1614
|
var {
|
|
@@ -4601,14 +1633,29 @@ var arbitrationSchedule = arbitrationScheduleText.split("\n").map((line) => line
|
|
|
4601
1633
|
};
|
|
4602
1634
|
});
|
|
4603
1635
|
|
|
4604
|
-
// src/warframe/data/wf/globalWorldState.ts
|
|
4605
|
-
var import_warframe_public_export_plus3 = require("warframe-public-export-plus");
|
|
4606
|
-
|
|
4607
1636
|
// src/warframe/infrastructure/wf/wf-api.ts
|
|
4608
1637
|
var apiBase = "https://api.warframe.com/cdn/";
|
|
1638
|
+
var oracleBountyCycleUrl = "https://oracle.browse.wf/bounty-cycle";
|
|
1639
|
+
function extractSyndicateMissionsRaw(json) {
|
|
1640
|
+
try {
|
|
1641
|
+
const data = JSON.parse(json);
|
|
1642
|
+
return Array.isArray(data.SyndicateMissions) ? data.SyndicateMissions : [];
|
|
1643
|
+
} catch {
|
|
1644
|
+
return [];
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
__name(extractSyndicateMissionsRaw, "extractSyndicateMissionsRaw");
|
|
1648
|
+
async function fetchWorldStateJson() {
|
|
1649
|
+
return fetchAsyncText(`${apiBase}worldState.php`);
|
|
1650
|
+
}
|
|
1651
|
+
__name(fetchWorldStateJson, "fetchWorldStateJson");
|
|
1652
|
+
async function fetchOracleBountyCycle() {
|
|
1653
|
+
return fetchAsyncData(oracleBountyCycleUrl);
|
|
1654
|
+
}
|
|
1655
|
+
__name(fetchOracleBountyCycle, "fetchOracleBountyCycle");
|
|
4609
1656
|
async function getWorldState(json) {
|
|
4610
1657
|
if (!json) {
|
|
4611
|
-
json = await
|
|
1658
|
+
json = await fetchWorldStateJson();
|
|
4612
1659
|
}
|
|
4613
1660
|
if (!json) {
|
|
4614
1661
|
throw new Error("获取游戏信息失败");
|
|
@@ -4776,6 +1823,19 @@ async function getVoidTraderHistory(data) {
|
|
|
4776
1823
|
}
|
|
4777
1824
|
__name(getVoidTraderHistory, "getVoidTraderHistory");
|
|
4778
1825
|
|
|
1826
|
+
// src/warframe/data/wf/globalOracleBountyCycle.ts
|
|
1827
|
+
async function globalOracleBountyCycleFactory() {
|
|
1828
|
+
return fetchOracleBountyCycle();
|
|
1829
|
+
}
|
|
1830
|
+
__name(globalOracleBountyCycleFactory, "globalOracleBountyCycleFactory");
|
|
1831
|
+
var globalOracleBountyCycle = createAsyncCache(
|
|
1832
|
+
globalOracleBountyCycleFactory,
|
|
1833
|
+
6e4
|
|
1834
|
+
);
|
|
1835
|
+
|
|
1836
|
+
// src/warframe/data/wf/globalWorldState.ts
|
|
1837
|
+
var import_warframe_public_export_plus3 = require("warframe-public-export-plus");
|
|
1838
|
+
|
|
4779
1839
|
// src/warframe/infrastructure/wf/wf-export-adapter.ts
|
|
4780
1840
|
var import_warframe_public_export_plus = require("warframe-public-export-plus");
|
|
4781
1841
|
function regionToShort(region, dict) {
|
|
@@ -4923,7 +1983,12 @@ async function adaptFissure(fissure) {
|
|
|
4923
1983
|
}
|
|
4924
1984
|
__name(adaptFissure, "adaptFissure");
|
|
4925
1985
|
var globalWorldState = createAsyncCache(async () => {
|
|
4926
|
-
const
|
|
1986
|
+
const json = await fetchWorldStateJson();
|
|
1987
|
+
if (!json) {
|
|
1988
|
+
throw new Error("获取游戏信息失败");
|
|
1989
|
+
}
|
|
1990
|
+
const syndicateMissionsRaw = extractSyndicateMissionsRaw(json);
|
|
1991
|
+
const worldState = await getWorldState(json);
|
|
4927
1992
|
const fissures = [];
|
|
4928
1993
|
const rjFissures = [];
|
|
4929
1994
|
const spFissures = [];
|
|
@@ -4940,7 +2005,13 @@ var globalWorldState = createAsyncCache(async () => {
|
|
|
4940
2005
|
fissures.sort((a, b) => a.tierNum - b.tierNum);
|
|
4941
2006
|
spFissures.sort((a, b) => a.tierNum - b.tierNum);
|
|
4942
2007
|
rjFissures.sort((a, b) => a.tierNum - b.tierNum);
|
|
4943
|
-
return {
|
|
2008
|
+
return {
|
|
2009
|
+
raw: worldState,
|
|
2010
|
+
syndicateMissionsRaw,
|
|
2011
|
+
fissures,
|
|
2012
|
+
spFissures,
|
|
2013
|
+
rjFissures
|
|
2014
|
+
};
|
|
4944
2015
|
}, -1);
|
|
4945
2016
|
|
|
4946
2017
|
// src/warframe/data/wf/relics.ts
|
|
@@ -5057,191 +2128,42 @@ var rivenStatFixFactor = {
|
|
|
5057
2128
|
}
|
|
5058
2129
|
};
|
|
5059
2130
|
|
|
5060
|
-
//
|
|
5061
|
-
var
|
|
5062
|
-
|
|
5063
|
-
// packages/wfm-api-client/lib/cache.js
|
|
5064
|
-
var WfmMemoryCache = class {
|
|
5065
|
-
static {
|
|
5066
|
-
__name(this, "WfmMemoryCache");
|
|
5067
|
-
}
|
|
5068
|
-
maxSize;
|
|
5069
|
-
storage = /* @__PURE__ */ new Map();
|
|
5070
|
-
constructor(maxSize) {
|
|
5071
|
-
this.maxSize = maxSize;
|
|
5072
|
-
}
|
|
5073
|
-
get(key, ttlSeconds, factory) {
|
|
5074
|
-
const now = Date.now();
|
|
5075
|
-
const existing = this.storage.get(key);
|
|
5076
|
-
if (existing && existing.expiresAt > now) {
|
|
5077
|
-
this.storage.delete(key);
|
|
5078
|
-
this.storage.set(key, existing);
|
|
5079
|
-
return existing.promise;
|
|
5080
|
-
}
|
|
5081
|
-
if (existing) {
|
|
5082
|
-
this.storage.delete(key);
|
|
5083
|
-
}
|
|
5084
|
-
const promise = factory().catch((err) => {
|
|
5085
|
-
const existing2 = this.storage.get(key);
|
|
5086
|
-
if (existing2 && existing2.promise === promise) {
|
|
5087
|
-
this.storage.delete(key);
|
|
5088
|
-
}
|
|
5089
|
-
throw err;
|
|
5090
|
-
});
|
|
5091
|
-
this.storage.set(key, {
|
|
5092
|
-
expiresAt: now + ttlSeconds * 1e3,
|
|
5093
|
-
promise
|
|
5094
|
-
});
|
|
5095
|
-
while (this.storage.size > this.maxSize) {
|
|
5096
|
-
const oldest = this.storage.keys().next().value;
|
|
5097
|
-
if (!oldest)
|
|
5098
|
-
break;
|
|
5099
|
-
this.storage.delete(oldest);
|
|
5100
|
-
}
|
|
5101
|
-
return promise;
|
|
5102
|
-
}
|
|
5103
|
-
};
|
|
5104
|
-
|
|
5105
|
-
// packages/wfm-api-client/lib/endpoints/items.js
|
|
5106
|
-
var wfmApiV1Base = "https://api.warframe.market/v1/";
|
|
5107
|
-
var wfmApiV2Base = "https://api.warframe.market/v2/";
|
|
5108
|
-
function createItemEndpoints(get, cacheOptions) {
|
|
5109
|
-
return {
|
|
5110
|
-
getList: /* @__PURE__ */ __name(async () => {
|
|
5111
|
-
const response = await get(`${wfmApiV2Base}items`, cacheOptions?.itemListTtl ?? 0);
|
|
5112
|
-
return response?.data;
|
|
5113
|
-
}, "getList"),
|
|
5114
|
-
getStatistics: /* @__PURE__ */ __name(async (itemId) => {
|
|
5115
|
-
const response = await get(`${wfmApiV1Base}items/${itemId}/statistics`, cacheOptions?.statisticsTtl ?? 0);
|
|
5116
|
-
return response?.payload;
|
|
5117
|
-
}, "getStatistics"),
|
|
5118
|
-
getOrders: /* @__PURE__ */ __name(async (itemId) => {
|
|
5119
|
-
const response = await get(`${wfmApiV2Base}orders/item/${itemId}`, cacheOptions?.orderListTtl ?? 0);
|
|
5120
|
-
return response?.data;
|
|
5121
|
-
}, "getOrders")
|
|
5122
|
-
};
|
|
5123
|
-
}
|
|
5124
|
-
__name(createItemEndpoints, "createItemEndpoints");
|
|
5125
|
-
|
|
5126
|
-
// packages/wfm-api-client/lib/endpoints/rivens.js
|
|
5127
|
-
var wfmApiV1Base2 = "https://api.warframe.market/v1/";
|
|
5128
|
-
var wfmApiV2Base2 = "https://api.warframe.market/v2/";
|
|
5129
|
-
function createRivenEndpoints(get, cacheOptions) {
|
|
5130
|
-
return {
|
|
5131
|
-
getItems: /* @__PURE__ */ __name(async () => {
|
|
5132
|
-
const response = await get(`${wfmApiV2Base2}riven/weapons`, cacheOptions?.rivenItemListTtl ?? 0);
|
|
5133
|
-
return response?.data;
|
|
5134
|
-
}, "getItems"),
|
|
5135
|
-
getOrders: /* @__PURE__ */ __name(async (itemId) => {
|
|
5136
|
-
const response = await get(`${wfmApiV1Base2}auctions/search?type=riven&sort_by=price_asc&weapon_url_name=${itemId}`, cacheOptions?.rivenOrderListTtl ?? 0);
|
|
5137
|
-
return response?.payload?.auctions;
|
|
5138
|
-
}, "getOrders"),
|
|
5139
|
-
getAttributes: /* @__PURE__ */ __name(async () => {
|
|
5140
|
-
const response = await get(`${wfmApiV2Base2}riven/attributes`, cacheOptions?.rivenAttributeListTtl ?? 0);
|
|
5141
|
-
return response?.data;
|
|
5142
|
-
}, "getAttributes")
|
|
5143
|
-
};
|
|
5144
|
-
}
|
|
5145
|
-
__name(createRivenEndpoints, "createRivenEndpoints");
|
|
5146
|
-
|
|
5147
|
-
// packages/wfm-api-client/lib/endpoints/tools.js
|
|
5148
|
-
var wfmApiV1Base3 = "https://api.warframe.market/v1/";
|
|
5149
|
-
function createToolEndpoints(get, cacheOptions) {
|
|
2131
|
+
// src/warframe/infrastructure/wfm-client.ts
|
|
2132
|
+
var import_wfm_api_client = require("wfm-api-client");
|
|
2133
|
+
function softFailPlugin() {
|
|
5150
2134
|
return {
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
2135
|
+
wrap: /* @__PURE__ */ __name((next) => {
|
|
2136
|
+
return async (ctx) => {
|
|
2137
|
+
try {
|
|
2138
|
+
return await next(ctx);
|
|
2139
|
+
} catch {
|
|
2140
|
+
return void 0;
|
|
2141
|
+
}
|
|
5158
2142
|
};
|
|
5159
|
-
}, "
|
|
2143
|
+
}, "wrap")
|
|
5160
2144
|
};
|
|
5161
2145
|
}
|
|
5162
|
-
__name(
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
retryDelay: 500,
|
|
5176
|
-
retryStatusCodes: [408, 429, 500, 502, 503, 504],
|
|
5177
|
-
timeout: 1e4
|
|
2146
|
+
__name(softFailPlugin, "softFailPlugin");
|
|
2147
|
+
function createPluginWfmClient(fetcher) {
|
|
2148
|
+
const plugins = [
|
|
2149
|
+
softFailPlugin(),
|
|
2150
|
+
(0, import_wfm_api_client.memoryCachePlugin)({ maxSize: 1024, ttl: 60 })
|
|
2151
|
+
];
|
|
2152
|
+
if (!fetcher)
|
|
2153
|
+
plugins.push((0, import_wfm_api_client.rateLimitPlugin)({ minTime: 400 }));
|
|
2154
|
+
return (0, import_wfm_api_client.createWfmApiClient)({
|
|
2155
|
+
fetcher,
|
|
2156
|
+
language: "zh-hans",
|
|
2157
|
+
timeoutMs: 1e4,
|
|
2158
|
+
plugins
|
|
5178
2159
|
});
|
|
5179
|
-
}, "defaultFetcher");
|
|
5180
|
-
function fetchWithLimiter(fetcher, url, limiter) {
|
|
5181
|
-
const run = /* @__PURE__ */ __name(() => fetcher(url), "run");
|
|
5182
|
-
return limiter ? limiter.schedule(run) : run();
|
|
5183
|
-
}
|
|
5184
|
-
__name(fetchWithLimiter, "fetchWithLimiter");
|
|
5185
|
-
|
|
5186
|
-
// packages/wfm-api-client/lib/client.js
|
|
5187
|
-
var defaultCacheOptions = {
|
|
5188
|
-
maxSize: 1024,
|
|
5189
|
-
itemListTtl: 3600,
|
|
5190
|
-
orderListTtl: 30,
|
|
5191
|
-
statisticsTtl: 60,
|
|
5192
|
-
rivenItemListTtl: 3600,
|
|
5193
|
-
rivenOrderListTtl: 30,
|
|
5194
|
-
rivenAttributeListTtl: 3600,
|
|
5195
|
-
ducatnatorTtl: 60
|
|
5196
|
-
};
|
|
5197
|
-
var defaultRateLimitOptions = {
|
|
5198
|
-
minTime: 500
|
|
5199
|
-
};
|
|
5200
|
-
function createWfmApiClient(options2 = {}) {
|
|
5201
|
-
const fetcher = options2.fetcher ?? defaultFetcher;
|
|
5202
|
-
const cacheOptions = resolveCacheOptions(options2.cache);
|
|
5203
|
-
const limiter = resolveLimiter(options2.rateLimit);
|
|
5204
|
-
const cache = cacheOptions ? new WfmMemoryCache(cacheOptions.maxSize) : void 0;
|
|
5205
|
-
async function get(url, ttl) {
|
|
5206
|
-
try {
|
|
5207
|
-
if (!cache || ttl <= 0) {
|
|
5208
|
-
return await fetchWithLimiter(fetcher, url, limiter);
|
|
5209
|
-
}
|
|
5210
|
-
return await cache.get(url, ttl, () => fetchWithLimiter(fetcher, url, limiter));
|
|
5211
|
-
} catch {
|
|
5212
|
-
return void 0;
|
|
5213
|
-
}
|
|
5214
|
-
}
|
|
5215
|
-
__name(get, "get");
|
|
5216
|
-
return {
|
|
5217
|
-
items: createItemEndpoints(get, cacheOptions),
|
|
5218
|
-
rivens: createRivenEndpoints(get, cacheOptions),
|
|
5219
|
-
tools: createToolEndpoints(get, cacheOptions)
|
|
5220
|
-
};
|
|
5221
|
-
}
|
|
5222
|
-
__name(createWfmApiClient, "createWfmApiClient");
|
|
5223
|
-
function resolveCacheOptions(cache) {
|
|
5224
|
-
if (cache === false)
|
|
5225
|
-
return void 0;
|
|
5226
|
-
if (cache === true || cache === void 0)
|
|
5227
|
-
return defaultCacheOptions;
|
|
5228
|
-
return { ...defaultCacheOptions, ...cache };
|
|
5229
|
-
}
|
|
5230
|
-
__name(resolveCacheOptions, "resolveCacheOptions");
|
|
5231
|
-
function resolveLimiter(rateLimit) {
|
|
5232
|
-
if (rateLimit === false)
|
|
5233
|
-
return void 0;
|
|
5234
|
-
const options2 = rateLimit === true || rateLimit === void 0 ? defaultRateLimitOptions : { ...defaultRateLimitOptions, ...rateLimit };
|
|
5235
|
-
return new import_bottleneck.default({ minTime: options2.minTime });
|
|
5236
2160
|
}
|
|
5237
|
-
__name(
|
|
5238
|
-
|
|
5239
|
-
// src/warframe/infrastructure/wfm-client.ts
|
|
5240
|
-
var wfmClient = createWfmApiClient();
|
|
2161
|
+
__name(createPluginWfmClient, "createPluginWfmClient");
|
|
2162
|
+
var wfmClient = createPluginWfmClient();
|
|
5241
2163
|
|
|
5242
2164
|
// src/warframe/data/wfm/globalRivenAttribute.ts
|
|
5243
2165
|
async function globalRivenAttributeFactory(rivenAttributeData) {
|
|
5244
|
-
rivenAttributeData ??= await wfmClient.rivens.
|
|
2166
|
+
rivenAttributeData ??= await wfmClient.rivens.listAttributes();
|
|
5245
2167
|
if (!rivenAttributeData) {
|
|
5246
2168
|
throw new Error(
|
|
5247
2169
|
"Failed to fetch riven attributes from Warframe Market API."
|
|
@@ -5305,7 +2227,7 @@ function buildGlobalRivenItemWordPrefixCandidates(globalRivenItemList) {
|
|
|
5305
2227
|
}
|
|
5306
2228
|
__name(buildGlobalRivenItemWordPrefixCandidates, "buildGlobalRivenItemWordPrefixCandidates");
|
|
5307
2229
|
async function globalRivenItemFactory(rivenData) {
|
|
5308
|
-
rivenData ??= await wfmClient.rivens.
|
|
2230
|
+
rivenData ??= await wfmClient.rivens.listWeapons();
|
|
5309
2231
|
if (!rivenData) {
|
|
5310
2232
|
throw new Error("Failed to fetch riven items from Warframe Market API.");
|
|
5311
2233
|
}
|
|
@@ -5396,6 +2318,414 @@ async function extractTextFromImage(image, secret) {
|
|
|
5396
2318
|
}
|
|
5397
2319
|
__name(extractTextFromImage, "extractTextFromImage");
|
|
5398
2320
|
|
|
2321
|
+
// src/warframe/infrastructure/wf/bounty-adapter.ts
|
|
2322
|
+
var import_warframe_public_export_plus6 = require("warframe-public-export-plus");
|
|
2323
|
+
var bountyLocationTag = {
|
|
2324
|
+
cetus: "CetusSyndicate",
|
|
2325
|
+
fortuna: "SolarisSyndicate",
|
|
2326
|
+
deimos: "EntratiSyndicate",
|
|
2327
|
+
zariman: "ZarimanSyndicate",
|
|
2328
|
+
cavia: "EntratiLabSyndicate",
|
|
2329
|
+
hex: "HexSyndicate"
|
|
2330
|
+
};
|
|
2331
|
+
var oracleBountyLocations = /* @__PURE__ */ new Set([
|
|
2332
|
+
"zariman",
|
|
2333
|
+
"cavia",
|
|
2334
|
+
"hex"
|
|
2335
|
+
]);
|
|
2336
|
+
var locationFallbackTitle = {
|
|
2337
|
+
cetus: "希图斯赏金",
|
|
2338
|
+
fortuna: "福尔图娜赏金",
|
|
2339
|
+
deimos: "火卫二赏金",
|
|
2340
|
+
zariman: "坚守者赏金",
|
|
2341
|
+
cavia: "科维兽赏金",
|
|
2342
|
+
hex: "六人组赏金"
|
|
2343
|
+
};
|
|
2344
|
+
var hexNodesWithoutMissionSuffix = /* @__PURE__ */ new Set([
|
|
2345
|
+
"SolNode850",
|
|
2346
|
+
"SolNode853",
|
|
2347
|
+
"SolNode854",
|
|
2348
|
+
"SolNode856"
|
|
2349
|
+
]);
|
|
2350
|
+
var hexAllyNames = {
|
|
2351
|
+
"/Lotus/Types/Gameplay/1999Wf/ProtoframeAllies/AmirAllyAgent": "Amir",
|
|
2352
|
+
"/Lotus/Types/Gameplay/1999Wf/ProtoframeAllies/AoiAllyAgent": "Aoi",
|
|
2353
|
+
"/Lotus/Types/Gameplay/1999Wf/ProtoframeAllies/ArthurAllyAgent": "Arthur",
|
|
2354
|
+
"/Lotus/Types/Gameplay/1999Wf/ProtoframeAllies/EleanorAllyAgent": "Eleanor",
|
|
2355
|
+
"/Lotus/Types/Gameplay/1999Wf/ProtoframeAllies/LettieAllyAgent": "Lettie",
|
|
2356
|
+
"/Lotus/Types/Gameplay/1999Wf/ProtoframeAllies/QuincyAllyAgent": "Quincy"
|
|
2357
|
+
};
|
|
2358
|
+
var oracleTierTables = {
|
|
2359
|
+
zariman: [
|
|
2360
|
+
{
|
|
2361
|
+
levels: [50, 55],
|
|
2362
|
+
standing: [1, 2],
|
|
2363
|
+
rewards: "/Lotus/Types/Game/MissionDecks/ZarimanJobMissionRewards/TierATableRewards"
|
|
2364
|
+
},
|
|
2365
|
+
{
|
|
2366
|
+
levels: [60, 65],
|
|
2367
|
+
standing: [2, 3],
|
|
2368
|
+
rewards: "/Lotus/Types/Game/MissionDecks/ZarimanJobMissionRewards/TierBTableRewards"
|
|
2369
|
+
},
|
|
2370
|
+
{
|
|
2371
|
+
levels: [70, 75],
|
|
2372
|
+
standing: [3, 5],
|
|
2373
|
+
rewards: "/Lotus/Types/Game/MissionDecks/ZarimanJobMissionRewards/TierCTableARewards"
|
|
2374
|
+
},
|
|
2375
|
+
{
|
|
2376
|
+
levels: [90, 95],
|
|
2377
|
+
standing: [4, 6],
|
|
2378
|
+
rewards: "/Lotus/Types/Game/MissionDecks/ZarimanJobMissionRewards/TierDTableRewards"
|
|
2379
|
+
},
|
|
2380
|
+
{
|
|
2381
|
+
levels: [110, 115],
|
|
2382
|
+
standing: [5, 8],
|
|
2383
|
+
rewards: "/Lotus/Types/Game/MissionDecks/ZarimanJobMissionRewards/TierETableRewards"
|
|
2384
|
+
}
|
|
2385
|
+
],
|
|
2386
|
+
cavia: [
|
|
2387
|
+
{
|
|
2388
|
+
levels: [55, 60],
|
|
2389
|
+
standing: [1e3, 1500],
|
|
2390
|
+
rewards: "/Lotus/Types/Game/MissionDecks/EntratiLabJobMissionReward/TierATableRewards"
|
|
2391
|
+
},
|
|
2392
|
+
{
|
|
2393
|
+
levels: [65, 70],
|
|
2394
|
+
standing: [2e3, 3e3],
|
|
2395
|
+
rewards: "/Lotus/Types/Game/MissionDecks/EntratiLabJobMissionReward/TierBTableRewards"
|
|
2396
|
+
},
|
|
2397
|
+
{
|
|
2398
|
+
levels: [75, 80],
|
|
2399
|
+
standing: [3e3, 4500],
|
|
2400
|
+
rewards: "/Lotus/Types/Game/MissionDecks/EntratiLabJobMissionReward/TierCTableRewards"
|
|
2401
|
+
},
|
|
2402
|
+
{
|
|
2403
|
+
levels: [95, 100],
|
|
2404
|
+
standing: [4e3, 6e3],
|
|
2405
|
+
rewards: "/Lotus/Types/Game/MissionDecks/EntratiLabJobMissionReward/TierDTableRewards"
|
|
2406
|
+
},
|
|
2407
|
+
{
|
|
2408
|
+
levels: [115, 120],
|
|
2409
|
+
standing: [5e3, 7500],
|
|
2410
|
+
rewards: "/Lotus/Types/Game/MissionDecks/EntratiLabJobMissionReward/TierETableRewards"
|
|
2411
|
+
}
|
|
2412
|
+
],
|
|
2413
|
+
hex: [
|
|
2414
|
+
{
|
|
2415
|
+
levels: [65, 70],
|
|
2416
|
+
standing: [1e3, 1500],
|
|
2417
|
+
rewards: "/Lotus/Types/Game/MissionDecks/1999MissionRewards/TierABountyRewards"
|
|
2418
|
+
},
|
|
2419
|
+
{
|
|
2420
|
+
levels: [75, 80],
|
|
2421
|
+
standing: [2e3, 3e3],
|
|
2422
|
+
rewards: "/Lotus/Types/Game/MissionDecks/1999MissionRewards/TierBBountyRewards"
|
|
2423
|
+
},
|
|
2424
|
+
{
|
|
2425
|
+
levels: [85, 90],
|
|
2426
|
+
standing: [3e3, 4500],
|
|
2427
|
+
rewards: "/Lotus/Types/Game/MissionDecks/1999MissionRewards/TierCBountyRewards"
|
|
2428
|
+
},
|
|
2429
|
+
{
|
|
2430
|
+
levels: [95, 100],
|
|
2431
|
+
standing: [4e3, 6e3],
|
|
2432
|
+
rewards: "/Lotus/Types/Game/MissionDecks/1999MissionRewards/TierDBountyRewards"
|
|
2433
|
+
},
|
|
2434
|
+
{
|
|
2435
|
+
levels: [105, 110],
|
|
2436
|
+
standing: [5e3, 7500],
|
|
2437
|
+
rewards: "/Lotus/Types/Game/MissionDecks/1999MissionRewards/TierEBountyRewards"
|
|
2438
|
+
},
|
|
2439
|
+
{
|
|
2440
|
+
levels: [115, 120],
|
|
2441
|
+
standing: [6e3, 9e3],
|
|
2442
|
+
rewards: "/Lotus/Types/Game/MissionDecks/1999MissionRewards/TierFBountyRewards"
|
|
2443
|
+
},
|
|
2444
|
+
{
|
|
2445
|
+
levels: [125, 130],
|
|
2446
|
+
standing: [7500, 11250],
|
|
2447
|
+
rewards: "/Lotus/Types/Game/MissionDecks/1999MissionRewards/InfestedLichBountyRewards"
|
|
2448
|
+
}
|
|
2449
|
+
]
|
|
2450
|
+
};
|
|
2451
|
+
function mongoDateMs(value) {
|
|
2452
|
+
const raw = value?.$date?.$numberLong;
|
|
2453
|
+
return raw ? Number(raw) : 0;
|
|
2454
|
+
}
|
|
2455
|
+
__name(mongoDateMs, "mongoDateMs");
|
|
2456
|
+
function rarityFromStageProbabilities(probability, uniqueSortedDesc) {
|
|
2457
|
+
if (uniqueSortedDesc.length <= 1) {
|
|
2458
|
+
return "bronze";
|
|
2459
|
+
}
|
|
2460
|
+
const idx = uniqueSortedDesc.indexOf(probability);
|
|
2461
|
+
if (idx <= 0) {
|
|
2462
|
+
return "bronze";
|
|
2463
|
+
}
|
|
2464
|
+
if (uniqueSortedDesc.length === 2) {
|
|
2465
|
+
return "silver";
|
|
2466
|
+
}
|
|
2467
|
+
if (idx === uniqueSortedDesc.length - 1) {
|
|
2468
|
+
return "gold";
|
|
2469
|
+
}
|
|
2470
|
+
return "silver";
|
|
2471
|
+
}
|
|
2472
|
+
__name(rarityFromStageProbabilities, "rarityFromStageProbabilities");
|
|
2473
|
+
var blueprintNameCache = /* @__PURE__ */ new Map();
|
|
2474
|
+
function resolveBlueprintNameViaDictZh(pathLeaf) {
|
|
2475
|
+
if (!/Blueprint$/i.test(pathLeaf)) {
|
|
2476
|
+
return void 0;
|
|
2477
|
+
}
|
|
2478
|
+
const base = pathLeaf.replace(/Blueprint$/i, "");
|
|
2479
|
+
if (!base) {
|
|
2480
|
+
return void 0;
|
|
2481
|
+
}
|
|
2482
|
+
if (blueprintNameCache.has(base)) {
|
|
2483
|
+
return blueprintNameCache.get(base) ?? void 0;
|
|
2484
|
+
}
|
|
2485
|
+
const needle = `${base}Name`.toLowerCase();
|
|
2486
|
+
let translated;
|
|
2487
|
+
for (const key of Object.keys(import_warframe_public_export_plus6.dict_zh)) {
|
|
2488
|
+
if (!key.toLowerCase().endsWith(needle)) {
|
|
2489
|
+
continue;
|
|
2490
|
+
}
|
|
2491
|
+
const boundary = key.length - needle.length;
|
|
2492
|
+
if (boundary === 0 || key[boundary - 1] === "/" || key[boundary - 1] === "_") {
|
|
2493
|
+
translated = import_warframe_public_export_plus6.dict_zh[key];
|
|
2494
|
+
break;
|
|
2495
|
+
}
|
|
2496
|
+
}
|
|
2497
|
+
if (!translated) {
|
|
2498
|
+
blueprintNameCache.set(base, null);
|
|
2499
|
+
return void 0;
|
|
2500
|
+
}
|
|
2501
|
+
const withBlueprint = translated.includes("蓝图") ? translated : `${translated} 蓝图`;
|
|
2502
|
+
blueprintNameCache.set(base, withBlueprint);
|
|
2503
|
+
return withBlueprint;
|
|
2504
|
+
}
|
|
2505
|
+
__name(resolveBlueprintNameViaDictZh, "resolveBlueprintNameViaDictZh");
|
|
2506
|
+
function resolveExportItemNameZh(sourceKey) {
|
|
2507
|
+
const creditMatch = sourceKey.match(/\/(\d+)Credits(?:$|\?)/);
|
|
2508
|
+
if (creditMatch) {
|
|
2509
|
+
return `${creditMatch[1]} 现金`;
|
|
2510
|
+
}
|
|
2511
|
+
const fixedKey = sourceKey.replace("/StoreItems", "");
|
|
2512
|
+
const flavour = import_warframe_public_export_plus6.ExportFlavour[fixedKey];
|
|
2513
|
+
if (flavour?.name) {
|
|
2514
|
+
return import_warframe_public_export_plus6.dict_zh[flavour.name] ?? flavour.name;
|
|
2515
|
+
}
|
|
2516
|
+
const weapon = import_warframe_public_export_plus6.ExportWeapons[fixedKey];
|
|
2517
|
+
if (weapon?.name) {
|
|
2518
|
+
return import_warframe_public_export_plus6.dict_zh[weapon.name] ?? weapon.name;
|
|
2519
|
+
}
|
|
2520
|
+
const mod = import_warframe_public_export_plus6.ExportUpgrades[fixedKey];
|
|
2521
|
+
if (mod?.name) {
|
|
2522
|
+
return import_warframe_public_export_plus6.dict_zh[mod.name] ?? mod.name;
|
|
2523
|
+
}
|
|
2524
|
+
const arcane = import_warframe_public_export_plus6.ExportArcanes[fixedKey];
|
|
2525
|
+
if (arcane?.name) {
|
|
2526
|
+
return import_warframe_public_export_plus6.dict_zh[arcane.name] ?? arcane.name;
|
|
2527
|
+
}
|
|
2528
|
+
const fusion = import_warframe_public_export_plus6.ExportFusionBundles[fixedKey];
|
|
2529
|
+
if (fusion?.name) {
|
|
2530
|
+
return import_warframe_public_export_plus6.dict_zh[fusion.name] ?? fusion.name;
|
|
2531
|
+
}
|
|
2532
|
+
const relic = import_warframe_public_export_plus6.ExportRelics[fixedKey];
|
|
2533
|
+
if (relic) {
|
|
2534
|
+
const era = import_warframe_public_export_plus6.dict_zh[relicEraToTransKey(relic.era)] ?? toPascalCase(relic.era);
|
|
2535
|
+
return `${era} ${relic.category} 遗物`;
|
|
2536
|
+
}
|
|
2537
|
+
const skin = import_warframe_public_export_plus6.ExportCustoms[fixedKey];
|
|
2538
|
+
if (skin?.name) {
|
|
2539
|
+
return import_warframe_public_export_plus6.dict_zh[skin.name] ?? skin.name;
|
|
2540
|
+
}
|
|
2541
|
+
const recipe = import_warframe_public_export_plus6.ExportRecipes[fixedKey];
|
|
2542
|
+
if (recipe?.resultType) {
|
|
2543
|
+
const recipeResult = import_warframe_public_export_plus6.ExportKeys[recipe.resultType] ?? import_warframe_public_export_plus6.ExportResources[recipe.resultType] ?? import_warframe_public_export_plus6.ExportWeapons[recipe.resultType] ?? import_warframe_public_export_plus6.ExportWarframes[recipe.resultType];
|
|
2544
|
+
if (recipeResult?.name) {
|
|
2545
|
+
const translated = import_warframe_public_export_plus6.dict_zh[recipeResult.name] ?? recipeResult.name;
|
|
2546
|
+
return translated.includes("蓝图") ? translated : `${translated} 蓝图`;
|
|
2547
|
+
}
|
|
2548
|
+
}
|
|
2549
|
+
const virtual = import_warframe_public_export_plus6.ExportVirtuals[fixedKey];
|
|
2550
|
+
if (virtual?.name) {
|
|
2551
|
+
return import_warframe_public_export_plus6.dict_zh[virtual.name] ?? virtual.name;
|
|
2552
|
+
}
|
|
2553
|
+
const resource = import_warframe_public_export_plus6.ExportResources[fixedKey];
|
|
2554
|
+
if (resource?.name) {
|
|
2555
|
+
return import_warframe_public_export_plus6.dict_zh[resource.name] ?? resource.name;
|
|
2556
|
+
}
|
|
2557
|
+
const gear = import_warframe_public_export_plus6.ExportGear[fixedKey];
|
|
2558
|
+
if (gear?.name) {
|
|
2559
|
+
return import_warframe_public_export_plus6.dict_zh[gear.name] ?? gear.name;
|
|
2560
|
+
}
|
|
2561
|
+
const bundle = import_warframe_public_export_plus6.ExportBundles[sourceKey] ?? import_warframe_public_export_plus6.ExportBundles[fixedKey];
|
|
2562
|
+
if (bundle?.name) {
|
|
2563
|
+
return import_warframe_public_export_plus6.dict_zh[bundle.name] ?? bundle.name;
|
|
2564
|
+
}
|
|
2565
|
+
const boosterPack = import_warframe_public_export_plus6.ExportBoosterPacks[fixedKey];
|
|
2566
|
+
if (boosterPack?.name) {
|
|
2567
|
+
return import_warframe_public_export_plus6.dict_zh[boosterPack.name] ?? boosterPack.name;
|
|
2568
|
+
}
|
|
2569
|
+
const pathLeaf = fixedKey.split("/").pop() ?? sourceKey;
|
|
2570
|
+
return resolveBlueprintNameViaDictZh(pathLeaf) ?? pathLeaf;
|
|
2571
|
+
}
|
|
2572
|
+
__name(resolveExportItemNameZh, "resolveExportItemNameZh");
|
|
2573
|
+
function rewardsFromDeck(rewardsKey) {
|
|
2574
|
+
const deck = import_warframe_public_export_plus6.ExportRewards[rewardsKey];
|
|
2575
|
+
if (!deck?.length) {
|
|
2576
|
+
return [];
|
|
2577
|
+
}
|
|
2578
|
+
return deck.map((tier) => {
|
|
2579
|
+
const uniqueSortedDesc = [...new Set(
|
|
2580
|
+
tier.map((reward) => reward.probability).filter((value) => typeof value === "number")
|
|
2581
|
+
)].sort((a, b) => b - a);
|
|
2582
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2583
|
+
const rewards = [];
|
|
2584
|
+
for (const reward of tier) {
|
|
2585
|
+
const name2 = resolveExportItemNameZh(reward.type);
|
|
2586
|
+
const rarity = rarityFromStageProbabilities(
|
|
2587
|
+
reward.probability ?? uniqueSortedDesc[0] ?? 0,
|
|
2588
|
+
uniqueSortedDesc
|
|
2589
|
+
);
|
|
2590
|
+
const key = `${rarity}:${name2}`;
|
|
2591
|
+
if (seen.has(key)) {
|
|
2592
|
+
continue;
|
|
2593
|
+
}
|
|
2594
|
+
seen.add(key);
|
|
2595
|
+
rewards.push({ name: name2, rarity });
|
|
2596
|
+
}
|
|
2597
|
+
return rewards;
|
|
2598
|
+
});
|
|
2599
|
+
}
|
|
2600
|
+
__name(rewardsFromDeck, "rewardsFromDeck");
|
|
2601
|
+
function jobName(job) {
|
|
2602
|
+
if (job.isVault) {
|
|
2603
|
+
const chamber = (job.locationTag || "").replace(/([a-z])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").trim();
|
|
2604
|
+
return chamber ? `隔离库 ${chamber}` : "隔离库";
|
|
2605
|
+
}
|
|
2606
|
+
if (job.jobType) {
|
|
2607
|
+
const bounty = import_warframe_public_export_plus6.ExportBounties[job.jobType];
|
|
2608
|
+
if (bounty?.name) {
|
|
2609
|
+
return import_warframe_public_export_plus6.dict_zh[bounty.name] ?? bounty.name;
|
|
2610
|
+
}
|
|
2611
|
+
return job.jobType.split("/").pop() ?? "未知赏金";
|
|
2612
|
+
}
|
|
2613
|
+
return "未知赏金";
|
|
2614
|
+
}
|
|
2615
|
+
__name(jobName, "jobName");
|
|
2616
|
+
function boardTitle(location, tag) {
|
|
2617
|
+
const syndicate = import_warframe_public_export_plus6.ExportSyndicates[tag];
|
|
2618
|
+
if (syndicate?.name) {
|
|
2619
|
+
const name2 = import_warframe_public_export_plus6.dict_zh[syndicate.name] ?? syndicate.name;
|
|
2620
|
+
return name2.endsWith("赏金") ? name2 : `${name2}赏金`;
|
|
2621
|
+
}
|
|
2622
|
+
return locationFallbackTitle[location];
|
|
2623
|
+
}
|
|
2624
|
+
__name(boardTitle, "boardTitle");
|
|
2625
|
+
function adaptJob(job) {
|
|
2626
|
+
return {
|
|
2627
|
+
name: jobName(job),
|
|
2628
|
+
enemyLevels: [job.minEnemyLevel, job.maxEnemyLevel],
|
|
2629
|
+
standingStages: job.xpAmounts ?? [],
|
|
2630
|
+
minMR: job.masteryReq ?? 0,
|
|
2631
|
+
...job.isVault ? { isVault: true } : {},
|
|
2632
|
+
...job.locationTag ? { locationTag: job.locationTag } : {},
|
|
2633
|
+
...job.jobType?.includes("Narmer") ? { isNarmer: true } : {},
|
|
2634
|
+
stages: rewardsFromDeck(job.rewards)
|
|
2635
|
+
};
|
|
2636
|
+
}
|
|
2637
|
+
__name(adaptJob, "adaptJob");
|
|
2638
|
+
function adaptBountyBoard(location, mission) {
|
|
2639
|
+
if (!mission?.Jobs?.length) {
|
|
2640
|
+
return void 0;
|
|
2641
|
+
}
|
|
2642
|
+
return {
|
|
2643
|
+
location,
|
|
2644
|
+
title: boardTitle(location, mission.Tag),
|
|
2645
|
+
expiry: mongoDateMs(mission.Expiry),
|
|
2646
|
+
jobs: mission.Jobs.map(adaptJob)
|
|
2647
|
+
};
|
|
2648
|
+
}
|
|
2649
|
+
__name(adaptBountyBoard, "adaptBountyBoard");
|
|
2650
|
+
function findRawSyndicateMission(missions, location) {
|
|
2651
|
+
const tag = bountyLocationTag[location];
|
|
2652
|
+
return missions.find((mission) => mission.Tag === tag);
|
|
2653
|
+
}
|
|
2654
|
+
__name(findRawSyndicateMission, "findRawSyndicateMission");
|
|
2655
|
+
function formatOracleMission(nodeKey) {
|
|
2656
|
+
const region = import_warframe_public_export_plus6.ExportRegions[nodeKey];
|
|
2657
|
+
if (!region?.name) {
|
|
2658
|
+
return nodeKey;
|
|
2659
|
+
}
|
|
2660
|
+
const name2 = import_warframe_public_export_plus6.dict_zh[region.name] ?? region.name;
|
|
2661
|
+
if (hexNodesWithoutMissionSuffix.has(nodeKey) || !region.missionName) {
|
|
2662
|
+
return name2;
|
|
2663
|
+
}
|
|
2664
|
+
const mission = import_warframe_public_export_plus6.dict_zh[region.missionName] ?? region.missionName;
|
|
2665
|
+
if (!mission || mission === name2) {
|
|
2666
|
+
return name2;
|
|
2667
|
+
}
|
|
2668
|
+
return `${name2}(${mission})`;
|
|
2669
|
+
}
|
|
2670
|
+
__name(formatOracleMission, "formatOracleMission");
|
|
2671
|
+
function formatOracleChallenge(challengePath) {
|
|
2672
|
+
const challenge = import_warframe_public_export_plus6.ExportChallenges[challengePath];
|
|
2673
|
+
if (!challenge?.description) {
|
|
2674
|
+
return challengePath.split("/").pop() ?? challengePath;
|
|
2675
|
+
}
|
|
2676
|
+
const raw = import_warframe_public_export_plus6.dict_zh[challenge.description] ?? challenge.description;
|
|
2677
|
+
const lastLine = raw.split(/\r?\n/).pop() ?? raw;
|
|
2678
|
+
return lastLine.split("|COUNT|").join(String(challenge.requiredCount ?? 0));
|
|
2679
|
+
}
|
|
2680
|
+
__name(formatOracleChallenge, "formatOracleChallenge");
|
|
2681
|
+
function zarimanFactionZh(faction) {
|
|
2682
|
+
if (faction === "FC_GRINEER") {
|
|
2683
|
+
return import_warframe_public_export_plus6.dict_zh["/Lotus/Language/Game/Faction_GrineerUC"] ?? "Grineer";
|
|
2684
|
+
}
|
|
2685
|
+
if (faction === "FC_CORPUS") {
|
|
2686
|
+
return import_warframe_public_export_plus6.dict_zh["/Lotus/Language/Game/Faction_CorpusUC"] ?? "Corpus";
|
|
2687
|
+
}
|
|
2688
|
+
return void 0;
|
|
2689
|
+
}
|
|
2690
|
+
__name(zarimanFactionZh, "zarimanFactionZh");
|
|
2691
|
+
function adaptOracleJob(location, entry, index) {
|
|
2692
|
+
const tiers = oracleTierTables[location];
|
|
2693
|
+
const tier = tiers[Math.min(index, tiers.length - 1)];
|
|
2694
|
+
const ally = entry.ally ? hexAllyNames[entry.ally] : void 0;
|
|
2695
|
+
return {
|
|
2696
|
+
name: formatOracleMission(entry.node),
|
|
2697
|
+
enemyLevels: tier.levels,
|
|
2698
|
+
standingStages: tier.standing,
|
|
2699
|
+
minMR: 0,
|
|
2700
|
+
stages: rewardsFromDeck(tier.rewards),
|
|
2701
|
+
challenge: formatOracleChallenge(entry.challenge),
|
|
2702
|
+
...ally ? { ally } : {},
|
|
2703
|
+
...location === "zariman" ? { standingUnit: "vq" } : {}
|
|
2704
|
+
};
|
|
2705
|
+
}
|
|
2706
|
+
__name(adaptOracleJob, "adaptOracleJob");
|
|
2707
|
+
function adaptOracleBountyBoard(location, cycle) {
|
|
2708
|
+
if (!cycle) {
|
|
2709
|
+
return void 0;
|
|
2710
|
+
}
|
|
2711
|
+
const tag = bountyLocationTag[location];
|
|
2712
|
+
const entries = cycle.bounties?.[tag];
|
|
2713
|
+
if (!entries?.length) {
|
|
2714
|
+
return void 0;
|
|
2715
|
+
}
|
|
2716
|
+
return {
|
|
2717
|
+
location,
|
|
2718
|
+
title: boardTitle(location, tag),
|
|
2719
|
+
expiry: cycle.expiry,
|
|
2720
|
+
jobs: entries.map((entry, index) => adaptOracleJob(location, entry, index)),
|
|
2721
|
+
source: "oracle",
|
|
2722
|
+
rotation: cycle.rot,
|
|
2723
|
+
vaultRotation: cycle.vaultRot,
|
|
2724
|
+
...location === "zariman" ? { zarimanFaction: zarimanFactionZh(cycle.zarimanFaction) } : {}
|
|
2725
|
+
};
|
|
2726
|
+
}
|
|
2727
|
+
__name(adaptOracleBountyBoard, "adaptOracleBountyBoard");
|
|
2728
|
+
|
|
5399
2729
|
// src/warframe/services/wf-service.ts
|
|
5400
2730
|
async function getRelic(input) {
|
|
5401
2731
|
if (!input) {
|
|
@@ -5457,7 +2787,7 @@ function getArbitrations(day = 3) {
|
|
|
5457
2787
|
return {
|
|
5458
2788
|
ok: true,
|
|
5459
2789
|
data: weekArbys.filter((a) => arbyRewards[a.node]).map((a) => {
|
|
5460
|
-
const obj = regionToShort(
|
|
2790
|
+
const obj = regionToShort(import_warframe_public_export_plus7.ExportRegions[a.node], import_warframe_public_export_plus7.dict_zh);
|
|
5461
2791
|
return {
|
|
5462
2792
|
...obj,
|
|
5463
2793
|
time: new Date(a.time * 1e3).toLocaleString("zh-cn", {
|
|
@@ -5484,7 +2814,7 @@ async function getWeekly() {
|
|
|
5484
2814
|
return failure("common.fetchFailed", true);
|
|
5485
2815
|
}
|
|
5486
2816
|
const archon = {
|
|
5487
|
-
name:
|
|
2817
|
+
name: import_warframe_public_export_plus7.dict_zh[`/Lotus/Language/Narmer/${removeSpace(worldState.archonHunt.boss)}`],
|
|
5488
2818
|
missions: []
|
|
5489
2819
|
};
|
|
5490
2820
|
const stringToDebuff = /* @__PURE__ */ __name((key, name2, prefix) => {
|
|
@@ -5509,7 +2839,7 @@ async function getWeekly() {
|
|
|
5509
2839
|
const deepArchimMissions = await Promise.all(
|
|
5510
2840
|
deepArchim.missions.map(async (m) => {
|
|
5511
2841
|
const receivedType = await getMissionTypeKey(m.missionType);
|
|
5512
|
-
const type =
|
|
2842
|
+
const type = import_warframe_public_export_plus7.dict_zh[import_warframe_public_export_plus7.ExportMissionTypes[receivedType]?.name ?? ""] ?? m.missionType;
|
|
5513
2843
|
const deviation = stringToDebuff(
|
|
5514
2844
|
m.deviation.key,
|
|
5515
2845
|
m.deviation.name,
|
|
@@ -5537,7 +2867,7 @@ async function getWeekly() {
|
|
|
5537
2867
|
const temporalArchimMissions = await Promise.all(
|
|
5538
2868
|
temporalArchim.missions.map(async (m) => {
|
|
5539
2869
|
const receivedType = await getMissionTypeKey(m.missionType);
|
|
5540
|
-
const type =
|
|
2870
|
+
const type = import_warframe_public_export_plus7.dict_zh[import_warframe_public_export_plus7.ExportMissionTypes[receivedType]?.name ?? ""] ?? receivedType;
|
|
5541
2871
|
const deviation = stringToDebuff(
|
|
5542
2872
|
m.deviation.key,
|
|
5543
2873
|
m.deviation.name,
|
|
@@ -5601,13 +2931,43 @@ ${duviri}
|
|
|
5601
2931
|
${zariman}`;
|
|
5602
2932
|
}
|
|
5603
2933
|
__name(getEnvironment, "getEnvironment");
|
|
2934
|
+
async function getBounty(location) {
|
|
2935
|
+
if (oracleBountyLocations.has(location)) {
|
|
2936
|
+
const cycle = await globalOracleBountyCycle.get();
|
|
2937
|
+
if (!cycle) {
|
|
2938
|
+
return failure("common.fetchFailed", true);
|
|
2939
|
+
}
|
|
2940
|
+
const board2 = adaptOracleBountyBoard(
|
|
2941
|
+
location,
|
|
2942
|
+
cycle
|
|
2943
|
+
);
|
|
2944
|
+
if (!board2) {
|
|
2945
|
+
return failure("bounty.unavailable");
|
|
2946
|
+
}
|
|
2947
|
+
return { ok: true, data: board2 };
|
|
2948
|
+
}
|
|
2949
|
+
const { syndicateMissionsRaw } = await globalWorldState.get();
|
|
2950
|
+
if (!syndicateMissionsRaw) {
|
|
2951
|
+
return failure("common.fetchFailed", true);
|
|
2952
|
+
}
|
|
2953
|
+
const mission = findRawSyndicateMission(syndicateMissionsRaw, location);
|
|
2954
|
+
if (!mission) {
|
|
2955
|
+
return failure("common.fetchFailed", true);
|
|
2956
|
+
}
|
|
2957
|
+
const board = adaptBountyBoard(location, mission);
|
|
2958
|
+
if (!board) {
|
|
2959
|
+
return failure("bounty.unavailable");
|
|
2960
|
+
}
|
|
2961
|
+
return { ok: true, data: board };
|
|
2962
|
+
}
|
|
2963
|
+
__name(getBounty, "getBounty");
|
|
5604
2964
|
function getCircuitWeek() {
|
|
5605
2965
|
const EPOCH = 1734307200 * 1e3;
|
|
5606
2966
|
const week = Math.trunc((Date.now() - EPOCH) / 6048e5);
|
|
5607
2967
|
const index1 = (week + 1) % incarnons.length;
|
|
5608
2968
|
const index2 = (week + 8) % warframes.length;
|
|
5609
|
-
const incarnons2 = incarnons.map((v) => v.map((i) =>
|
|
5610
|
-
const warframes2 = warframes.map((v) => v.map((i) =>
|
|
2969
|
+
const incarnons2 = incarnons.map((v) => v.map((i) => import_warframe_public_export_plus7.dict_zh[i]));
|
|
2970
|
+
const warframes2 = warframes.map((v) => v.map((i) => import_warframe_public_export_plus7.dict_zh[i]));
|
|
5611
2971
|
return {
|
|
5612
2972
|
currentIncarnons: index1,
|
|
5613
2973
|
currentWarframes: index2,
|
|
@@ -5739,12 +3099,12 @@ async function getStaticRivenStats(weaponType, statType, disposition) {
|
|
|
5739
3099
|
const { globalRivenAttributeList } = await globalRivenAttribute.get();
|
|
5740
3100
|
for (const key in rivenAttrValues2) {
|
|
5741
3101
|
const data = globalRivenAttributeList.find(
|
|
5742
|
-
(v) => normalizeName(v.i18n.en.name) === key
|
|
3102
|
+
(v) => v.i18n?.en?.name !== void 0 && normalizeName(v.i18n.en.name) === key
|
|
5743
3103
|
);
|
|
5744
3104
|
const baseValue = rivenAttrValues2[key];
|
|
5745
3105
|
const buffValue = baseValue * disposition * factor.buffFactor;
|
|
5746
3106
|
result.positive[key] = {
|
|
5747
|
-
name: data?.i18n["zh-hans"]
|
|
3107
|
+
name: data?.i18n?.["zh-hans"]?.name ?? data?.i18n?.en?.name ?? key,
|
|
5748
3108
|
max: buffValue * 1.1,
|
|
5749
3109
|
min: buffValue * 0.9,
|
|
5750
3110
|
unit: data?.unit ?? ""
|
|
@@ -5752,7 +3112,7 @@ async function getStaticRivenStats(weaponType, statType, disposition) {
|
|
|
5752
3112
|
if (result.negative) {
|
|
5753
3113
|
const curseValue = baseValue * disposition * factor.curseFactor;
|
|
5754
3114
|
result.negative[key] = {
|
|
5755
|
-
name: data?.i18n["zh-hans"]
|
|
3115
|
+
name: data?.i18n?.["zh-hans"]?.name ?? data?.i18n?.en?.name ?? key,
|
|
5756
3116
|
max: curseValue * 0.9,
|
|
5757
3117
|
min: curseValue * 1.1,
|
|
5758
3118
|
unit: data?.unit ?? ""
|
|
@@ -5820,7 +3180,7 @@ async function parseOCRResult(ocrResult) {
|
|
|
5820
3180
|
const attr = globalRivenAttributeList.find((a) => {
|
|
5821
3181
|
if (!a)
|
|
5822
3182
|
return false;
|
|
5823
|
-
const zhName = a.i18n["zh-hans"]?.name;
|
|
3183
|
+
const zhName = a.i18n?.["zh-hans"]?.name;
|
|
5824
3184
|
if (!zhName)
|
|
5825
3185
|
return false;
|
|
5826
3186
|
const sim = similarity(zhName, attrNamePart);
|
|
@@ -5921,54 +3281,65 @@ function analyzeRivenStat(parseResult) {
|
|
|
5921
3281
|
}
|
|
5922
3282
|
const disposition = weaponRiven.calc.disposition;
|
|
5923
3283
|
const weaponType = weaponRiven.calc.riventype;
|
|
5924
|
-
const
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
5928
|
-
return "
|
|
5929
|
-
}
|
|
3284
|
+
const lookupBaseValue = /* @__PURE__ */ __name((enName) => rivenAttrValueDict[weaponType]?.[normalizeName(enName)], "lookupBaseValue");
|
|
3285
|
+
const buildStat = /* @__PURE__ */ __name((entry, factor, invertPercent) => {
|
|
3286
|
+
const enName = entry.attr.i18n?.en?.name;
|
|
3287
|
+
if (!enName) {
|
|
3288
|
+
return failure("riven.statTypeError");
|
|
3289
|
+
}
|
|
3290
|
+
const baseValue = lookupBaseValue(enName);
|
|
3291
|
+
if (baseValue === void 0) {
|
|
3292
|
+
return failure("riven.statTypeError");
|
|
3293
|
+
}
|
|
3294
|
+
const unit = entry.attr.unit ?? "";
|
|
3295
|
+
const value = unit === "multiply" ? entry.value - 1 : entry.value;
|
|
3296
|
+
const standardValue = baseValue * factor * disposition;
|
|
3297
|
+
const percent = invertPercent ? (value - standardValue) / standardValue * -1 : (value - standardValue) / standardValue;
|
|
3298
|
+
return {
|
|
3299
|
+
ok: true,
|
|
3300
|
+
data: {
|
|
3301
|
+
name: entry.attr.i18n?.["zh-hans"]?.name ?? enName,
|
|
3302
|
+
unit,
|
|
3303
|
+
value: entry.value,
|
|
3304
|
+
percent,
|
|
3305
|
+
max: invertPercent ? standardValue * 0.9 : standardValue * 1.1,
|
|
3306
|
+
min: invertPercent ? standardValue * 1.1 : standardValue * 0.9
|
|
3307
|
+
}
|
|
3308
|
+
};
|
|
3309
|
+
}, "buildStat");
|
|
3310
|
+
const firstStatName = parseResult.attributes[0]?.attr.i18n?.en?.name;
|
|
3311
|
+
if (!firstStatName) {
|
|
3312
|
+
return failure("riven.statTypeError");
|
|
3313
|
+
}
|
|
3314
|
+
let rivenStatCountType;
|
|
3315
|
+
if (parseResult.attributes.length === 4) {
|
|
3316
|
+
rivenStatCountType = "31";
|
|
3317
|
+
} else if (parseResult.attributes.length === 2) {
|
|
3318
|
+
rivenStatCountType = "2";
|
|
3319
|
+
} else {
|
|
5930
3320
|
const firstStat = parseResult.attributes[0];
|
|
5931
|
-
const firstStatBaseValue =
|
|
5932
|
-
if (
|
|
5933
|
-
return "
|
|
5934
|
-
} else {
|
|
5935
|
-
return "3";
|
|
3321
|
+
const firstStatBaseValue = lookupBaseValue(firstStatName);
|
|
3322
|
+
if (firstStatBaseValue === void 0) {
|
|
3323
|
+
return failure("riven.statTypeError");
|
|
5936
3324
|
}
|
|
5937
|
-
|
|
3325
|
+
rivenStatCountType = firstStat.value >= firstStatBaseValue * 1.2375 * 0.9 * disposition ? "21" : "3";
|
|
3326
|
+
}
|
|
5938
3327
|
const { buffFactor, buffCount, curseFactor, curseCount } = rivenStatFixFactor[rivenStatCountType];
|
|
5939
3328
|
const buffs = [];
|
|
5940
3329
|
for (let i = 0; i < buffCount; i++) {
|
|
5941
|
-
const
|
|
5942
|
-
|
|
5943
|
-
|
|
5944
|
-
|
|
5945
|
-
|
|
5946
|
-
buffs.push({
|
|
5947
|
-
name: attr.attr.i18n["zh-hans"].name,
|
|
5948
|
-
unit: attr.attr.unit,
|
|
5949
|
-
value: attr.value,
|
|
5950
|
-
percent,
|
|
5951
|
-
max: standardValue * 1.1,
|
|
5952
|
-
min: standardValue * 0.9
|
|
5953
|
-
});
|
|
3330
|
+
const result = buildStat(parseResult.attributes[i], buffFactor, false);
|
|
3331
|
+
if (!result.ok) {
|
|
3332
|
+
return result;
|
|
3333
|
+
}
|
|
3334
|
+
buffs.push(result.data);
|
|
5954
3335
|
}
|
|
5955
3336
|
const curses = [];
|
|
5956
|
-
|
|
5957
|
-
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
const value = attr.attr.unit === "multiply" ? attr.value - 1 : attr.value;
|
|
5961
|
-
const standardValue = baseValue * curseFactor * disposition;
|
|
5962
|
-
const percent = (value - standardValue) / standardValue * -1;
|
|
5963
|
-
curses.push({
|
|
5964
|
-
name: attr.attr.i18n["zh-hans"].name,
|
|
5965
|
-
unit: attr.attr.unit,
|
|
5966
|
-
value: attr.value,
|
|
5967
|
-
percent,
|
|
5968
|
-
max: standardValue * 0.9,
|
|
5969
|
-
min: standardValue * 1.1
|
|
5970
|
-
});
|
|
3337
|
+
for (let i = buffCount; i < buffCount + curseCount; i++) {
|
|
3338
|
+
const result = buildStat(parseResult.attributes[i], curseFactor, true);
|
|
3339
|
+
if (!result.ok) {
|
|
3340
|
+
return result;
|
|
5971
3341
|
}
|
|
3342
|
+
curses.push(result.data);
|
|
5972
3343
|
}
|
|
5973
3344
|
return {
|
|
5974
3345
|
ok: true,
|
|
@@ -5983,7 +3354,7 @@ function analyzeRivenStat(parseResult) {
|
|
|
5983
3354
|
__name(analyzeRivenStat, "analyzeRivenStat");
|
|
5984
3355
|
|
|
5985
3356
|
// src/warframe/services/wfm-service/index.ts
|
|
5986
|
-
var
|
|
3357
|
+
var import_warframe_public_export_plus8 = require("warframe-public-export-plus");
|
|
5987
3358
|
|
|
5988
3359
|
// src/warframe/data/wfm/globalDucatnator.ts
|
|
5989
3360
|
var globalDucatnatorIDDict = createAsyncCache(async () => {
|
|
@@ -6036,7 +3407,7 @@ function buildGlobalItemWordPrefixCandidates(globalItemList) {
|
|
|
6036
3407
|
}
|
|
6037
3408
|
__name(buildGlobalItemWordPrefixCandidates, "buildGlobalItemWordPrefixCandidates");
|
|
6038
3409
|
async function globalItemDataFactory(response) {
|
|
6039
|
-
response ??= await wfmClient.items.
|
|
3410
|
+
response ??= await wfmClient.items.list();
|
|
6040
3411
|
if (!response) {
|
|
6041
3412
|
return {
|
|
6042
3413
|
globalItemList: [],
|
|
@@ -6055,11 +3426,13 @@ async function globalItemDataFactory(response) {
|
|
|
6055
3426
|
const globalItemNameToSlugDict = ((list) => {
|
|
6056
3427
|
const result = {};
|
|
6057
3428
|
for (const item of list) {
|
|
6058
|
-
|
|
6059
|
-
|
|
3429
|
+
const zhName = item.i18n?.["zh-hans"]?.name;
|
|
3430
|
+
if (zhName) {
|
|
3431
|
+
result[normalizeName(zhName)] = item.slug;
|
|
6060
3432
|
}
|
|
6061
|
-
|
|
6062
|
-
|
|
3433
|
+
const enName = item.i18n?.en?.name;
|
|
3434
|
+
if (enName) {
|
|
3435
|
+
result[normalizeName(enName)] = item.slug;
|
|
6063
3436
|
}
|
|
6064
3437
|
}
|
|
6065
3438
|
return result;
|
|
@@ -6652,14 +4025,14 @@ async function getItemOrders(input) {
|
|
|
6652
4025
|
const itemId = targetItem.slug;
|
|
6653
4026
|
const targetRank = isFullLevel ? targetItem.maxRank : targetItem.maxRank === void 0 ? void 0 : 0;
|
|
6654
4027
|
const [data, statsData] = await Promise.all([
|
|
6655
|
-
wfmClient.
|
|
4028
|
+
wfmClient.orders.listByItem({ slug: itemId }),
|
|
6656
4029
|
wfmClient.items.getStatistics(itemId)
|
|
6657
4030
|
]);
|
|
6658
4031
|
if (!data) {
|
|
6659
4032
|
return failure("wfm.orderFetchFailed", true);
|
|
6660
4033
|
}
|
|
6661
4034
|
const result = data.filter(
|
|
6662
|
-
(order) => order.user
|
|
4035
|
+
(order) => order.user?.status === "ingame" && order.visible && order.type === "sell" && (!isFullLevel || order.rank === targetItem.maxRank)
|
|
6663
4036
|
).sort((a, b) => toTimeStamp(b.updatedAt) - toTimeStamp(a.updatedAt)).sort((a, b) => a.platinum - b.platinum).slice(0, 8);
|
|
6664
4037
|
if (result.length === 0) {
|
|
6665
4038
|
return failure("wfm.noOnlineSeller");
|
|
@@ -6694,7 +4067,7 @@ async function getRivenOrders(input) {
|
|
|
6694
4067
|
return failure("wfm.rivenOrderFetchFailed", true);
|
|
6695
4068
|
}
|
|
6696
4069
|
const top5 = data.filter(
|
|
6697
|
-
(order) => order.owner
|
|
4070
|
+
(order) => order.owner?.status === "ingame" && order.visible && !order.private && !order.closed && order.is_direct_sell
|
|
6698
4071
|
).sort((a, b) => toTimeStamp(b.updated) - toTimeStamp(a.updated)).sort((a, b) => a.starting_price - b.starting_price).slice(0, 5);
|
|
6699
4072
|
if (top5.length === 0) {
|
|
6700
4073
|
return failure("wfm.noOnlineRivenSeller");
|
|
@@ -6715,7 +4088,7 @@ async function getRivenOrders(input) {
|
|
|
6715
4088
|
}
|
|
6716
4089
|
__name(getRivenOrders, "getRivenOrders");
|
|
6717
4090
|
async function applyRelicData(relic) {
|
|
6718
|
-
const tier =
|
|
4091
|
+
const tier = import_warframe_public_export_plus8.dict_zh[relic.tierKey] ?? relic.tier;
|
|
6719
4092
|
const { globalItemGameRefDict } = await globalItemData.get();
|
|
6720
4093
|
const wfmDict = await globalDucatnatorIDDict.get();
|
|
6721
4094
|
const loadedItems = relic.items.map((element) => {
|
|
@@ -6788,13 +4161,13 @@ var primedModHistory = createAsyncCache(async () => {
|
|
|
6788
4161
|
const lastThree = zeroRankList.slice(-3);
|
|
6789
4162
|
const avg = lastThree.length > 0 ? Math.round(lastThree.reduce((acc, e) => acc + e.median, 0) / lastThree.length * 10) / 10 : void 0;
|
|
6790
4163
|
result.push({
|
|
6791
|
-
name: item.i18n["zh-hans"]?.name,
|
|
4164
|
+
name: item.i18n?.["zh-hans"]?.name ?? item.i18n?.en?.name,
|
|
6792
4165
|
last: mod.Last,
|
|
6793
4166
|
plats: avg
|
|
6794
4167
|
});
|
|
6795
4168
|
} else {
|
|
6796
4169
|
result.push({
|
|
6797
|
-
name: item.i18n["zh-hans"]?.name,
|
|
4170
|
+
name: item.i18n?.["zh-hans"]?.name ?? item.i18n?.en?.name,
|
|
6798
4171
|
last: mod.Last
|
|
6799
4172
|
});
|
|
6800
4173
|
}
|
|
@@ -6803,7 +4176,7 @@ var primedModHistory = createAsyncCache(async () => {
|
|
|
6803
4176
|
}, 432e5);
|
|
6804
4177
|
|
|
6805
4178
|
// src/warframe/services/world-state-refresh.ts
|
|
6806
|
-
var
|
|
4179
|
+
var import_warframe_public_export_plus9 = require("warframe-public-export-plus");
|
|
6807
4180
|
var ALLOWED_FISSURE_MISSION_TYPES = /* @__PURE__ */ new Set(["MT_EXTERMINATION", "MT_DEFENSE", "MT_ARTIFACT"]);
|
|
6808
4181
|
function time(value) {
|
|
6809
4182
|
return value?.getTime() ?? 0;
|
|
@@ -6822,7 +4195,7 @@ function fissureId(value) {
|
|
|
6822
4195
|
__name(fissureId, "fissureId");
|
|
6823
4196
|
async function fissureMissionType(fissure) {
|
|
6824
4197
|
const nodeKey = await getSolNodeKey(fissure.nodeKey);
|
|
6825
|
-
return
|
|
4198
|
+
return import_warframe_public_export_plus9.ExportRegions[nodeKey]?.missionType;
|
|
6826
4199
|
}
|
|
6827
4200
|
__name(fissureMissionType, "fissureMissionType");
|
|
6828
4201
|
function dailyDealId(value) {
|
|
@@ -7448,6 +4821,85 @@ function FissureComponent(fissures, type) {
|
|
|
7448
4821
|
] });
|
|
7449
4822
|
}
|
|
7450
4823
|
__name(FissureComponent, "FissureComponent");
|
|
4824
|
+
function BountyComponent(board) {
|
|
4825
|
+
const timeLeft = board.expiry - Date.now();
|
|
4826
|
+
const timeColor = timeLeft > 36e5 ? "var(--wf-success)" : timeLeft > 6e5 ? "var(--wf-info)" : "var(--wf-danger)";
|
|
4827
|
+
const rarityColor = {
|
|
4828
|
+
bronze: "var(--wf-rarity-common)",
|
|
4829
|
+
silver: "var(--wf-rarity-uncommon)",
|
|
4830
|
+
gold: "var(--wf-rarity-rare)"
|
|
4831
|
+
};
|
|
4832
|
+
const isOracle = board.source === "oracle";
|
|
4833
|
+
const metaParts = [];
|
|
4834
|
+
if (board.zarimanFaction) {
|
|
4835
|
+
metaParts.push(`阵营 ${board.zarimanFaction}`);
|
|
4836
|
+
}
|
|
4837
|
+
if (board.rotation) {
|
|
4838
|
+
metaParts.push(`轮换 ${board.rotation}`);
|
|
4839
|
+
}
|
|
4840
|
+
if (board.vaultRotation) {
|
|
4841
|
+
metaParts.push(`隔离库 ${board.vaultRotation}`);
|
|
4842
|
+
}
|
|
4843
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
4844
|
+
"div",
|
|
4845
|
+
{
|
|
4846
|
+
style: "width:640px;background-color:var(--wf-bg-card);border-radius:var(--wf-radius);padding:16px;box-shadow:var(--wf-shadow-card);border:1px solid var(--wf-border);font-family:'Segoe UI',Tahoma,Geneva,Verdana,sans-serif;color:var(--wf-text-body);",
|
|
4847
|
+
children: [
|
|
4848
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h1", { style: "font-size:22px;font-weight:bold;color:var(--wf-text-primary);margin:0 0 8px 0;text-align:center;", children: board.title }),
|
|
4849
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: `text-align:center;font-size:13px;margin-bottom:8px;color:${timeColor};`, children: [
|
|
4850
|
+
"剩余",
|
|
4851
|
+
msToHumanReadable(Math.max(timeLeft, 0))
|
|
4852
|
+
] }),
|
|
4853
|
+
metaParts.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: "text-align:center;font-size:12px;color:var(--wf-text-secondary);margin-bottom:12px;", children: metaParts.join(" · ") }) : null,
|
|
4854
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: "display:flex;flex-direction:column;gap:10px;", children: board.jobs.map((job) => {
|
|
4855
|
+
const tags = [];
|
|
4856
|
+
if (job.isVault)
|
|
4857
|
+
tags.push("隔离库");
|
|
4858
|
+
if (job.isNarmer)
|
|
4859
|
+
tags.push("合一众");
|
|
4860
|
+
if (job.ally)
|
|
4861
|
+
tags.push(job.ally);
|
|
4862
|
+
const hasRewards = job.stages.some((stage) => stage.length > 0);
|
|
4863
|
+
const standingLabel = job.standingUnit === "vq" ? "VQ" : "声望";
|
|
4864
|
+
const metaLine = [
|
|
4865
|
+
`等级 ${job.enemyLevels[0]}-${job.enemyLevels[1]}`,
|
|
4866
|
+
job.minMR > 0 ? `段位 ${job.minMR}+` : void 0,
|
|
4867
|
+
job.standingStages.length > 0 ? `${standingLabel} ${job.standingStages.join("/")}` : void 0
|
|
4868
|
+
].filter(Boolean).join(" · ");
|
|
4869
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
4870
|
+
"div",
|
|
4871
|
+
{
|
|
4872
|
+
style: "padding:10px 12px;background-color:var(--wf-bg-subtle);border-radius:var(--wf-radius-sm);border-left:3px solid var(--wf-accent);",
|
|
4873
|
+
children: [
|
|
4874
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: "display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:6px;", children: [
|
|
4875
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: "font-size:15px;font-weight:700;color:var(--wf-text-primary);", children: job.name }),
|
|
4876
|
+
tags.map((tag) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
4877
|
+
"span",
|
|
4878
|
+
{
|
|
4879
|
+
style: "font-size:11px;color:var(--wf-accent);background-color:rgba(71,181,165,0.12);padding:1px 6px;border-radius:var(--wf-radius-sm);",
|
|
4880
|
+
children: tag
|
|
4881
|
+
}
|
|
4882
|
+
))
|
|
4883
|
+
] }),
|
|
4884
|
+
metaLine ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: "font-size:12px;color:var(--wf-text-secondary);margin-bottom:6px;", children: metaLine }) : null,
|
|
4885
|
+
job.challenge ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: "font-size:12px;line-height:1.45;color:var(--wf-text-body);margin-bottom:4px;", children: job.challenge }) : null,
|
|
4886
|
+
hasRewards ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: "display:flex;flex-direction:column;gap:6px;", children: job.stages.map((stage, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: "font-size:12px;line-height:1.45;", children: [
|
|
4887
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: "color:var(--wf-text-secondary);margin-right:6px;", children: `阶段${index + 1}` }),
|
|
4888
|
+
stage.map((reward, rewardIndex) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
|
|
4889
|
+
rewardIndex > 0 ? "、" : "",
|
|
4890
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: `color:${rarityColor[reward.rarity]};`, children: reward.name })
|
|
4891
|
+
] }))
|
|
4892
|
+
] })) }) : !isOracle ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: "font-size:12px;color:var(--wf-text-body);", children: "奖励未知" }) : null
|
|
4893
|
+
]
|
|
4894
|
+
}
|
|
4895
|
+
);
|
|
4896
|
+
}) }),
|
|
4897
|
+
isOracle ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: "margin-top:12px;font-size:11px;color:var(--wf-text-muted);text-align:right;", children: "数据来源: browse.wf" }) : null
|
|
4898
|
+
]
|
|
4899
|
+
}
|
|
4900
|
+
);
|
|
4901
|
+
}
|
|
4902
|
+
__name(BountyComponent, "BountyComponent");
|
|
7451
4903
|
function WeeklyRivenComponent(items, minPrice) {
|
|
7452
4904
|
const formatPrice = /* @__PURE__ */ __name((value) => Number.isInteger(value) ? value.toString() : value.toFixed(1), "formatPrice");
|
|
7453
4905
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
@@ -8551,6 +6003,13 @@ __name(VoidTraderComponent, "VoidTraderComponent");
|
|
|
8551
6003
|
// src/commands/wf.ts
|
|
8552
6004
|
function createWfCommands(deps) {
|
|
8553
6005
|
const { config, render } = deps;
|
|
6006
|
+
const bountyCommand = /* @__PURE__ */ __name(async (location) => {
|
|
6007
|
+
const result = await getBounty(location);
|
|
6008
|
+
if (!result.ok) {
|
|
6009
|
+
return t(result);
|
|
6010
|
+
}
|
|
6011
|
+
return render(BountyComponent(result.data));
|
|
6012
|
+
}, "bountyCommand");
|
|
8554
6013
|
return {
|
|
8555
6014
|
arbitrationCommand: /* @__PURE__ */ __name(async (_action, input) => {
|
|
8556
6015
|
const result = getArbitrations(input);
|
|
@@ -8655,7 +6114,13 @@ function createWfCommands(deps) {
|
|
|
8655
6114
|
}, "weeklyRivenCommand"),
|
|
8656
6115
|
environmentCommand: /* @__PURE__ */ __name(async () => {
|
|
8657
6116
|
return getEnvironment();
|
|
8658
|
-
}, "environmentCommand")
|
|
6117
|
+
}, "environmentCommand"),
|
|
6118
|
+
bountyCetusCommand: /* @__PURE__ */ __name(async () => bountyCommand("cetus"), "bountyCetusCommand"),
|
|
6119
|
+
bountyFortunaCommand: /* @__PURE__ */ __name(async () => bountyCommand("fortuna"), "bountyFortunaCommand"),
|
|
6120
|
+
bountyDeimosCommand: /* @__PURE__ */ __name(async () => bountyCommand("deimos"), "bountyDeimosCommand"),
|
|
6121
|
+
bountyZarimanCommand: /* @__PURE__ */ __name(async () => bountyCommand("zariman"), "bountyZarimanCommand"),
|
|
6122
|
+
bountyCaviaCommand: /* @__PURE__ */ __name(async () => bountyCommand("cavia"), "bountyCaviaCommand"),
|
|
6123
|
+
bountyHexCommand: /* @__PURE__ */ __name(async () => bountyCommand("hex"), "bountyHexCommand")
|
|
8659
6124
|
};
|
|
8660
6125
|
}
|
|
8661
6126
|
__name(createWfCommands, "createWfCommands");
|
|
@@ -8821,8 +6286,8 @@ function ItemStatisticsComponent(stats) {
|
|
|
8821
6286
|
}
|
|
8822
6287
|
__name(ItemStatisticsComponent, "ItemStatisticsComponent");
|
|
8823
6288
|
function ItemOrderComponent(item, orders, statistics) {
|
|
8824
|
-
const itemNameCN = item.i18n["zh-hans"]?.name;
|
|
8825
|
-
const itemNameEN = item.i18n
|
|
6289
|
+
const itemNameCN = item.i18n?.["zh-hans"]?.name;
|
|
6290
|
+
const itemNameEN = item.i18n?.en?.name;
|
|
8826
6291
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: "display:flex;flex-direction:column;width:1600px;background-color:var(--wf-bg-card);border-radius:var(--wf-radius);padding:16px;border:1px solid var(--wf-border);box-shadow:var(--wf-shadow-card);color:var(--wf-text-body);", children: [
|
|
8827
6292
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("style", { children: `
|
|
8828
6293
|
th {
|
|
@@ -8862,12 +6327,12 @@ function ItemOrderComponent(item, orders, statistics) {
|
|
|
8862
6327
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("th", { style: "width:10%;", children: "好评" })
|
|
8863
6328
|
] }),
|
|
8864
6329
|
orders.map((order) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("tr", { children: [
|
|
8865
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { children: order.user
|
|
8866
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { children: order.user
|
|
6330
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { children: order.user?.ingameName ?? "未知" }),
|
|
6331
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { children: order.user?.status ?? "未知" }),
|
|
8867
6332
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { style: "color:var(--wf-platinum);font-weight:600;", children: order.platinum }),
|
|
8868
6333
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { children: order.quantity }),
|
|
8869
6334
|
item.maxRank && item.maxRank > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { children: order.rank }) : null,
|
|
8870
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { children: order.user
|
|
6335
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { children: order.user?.reputation ?? "未知" })
|
|
8871
6336
|
] }))
|
|
8872
6337
|
] }),
|
|
8873
6338
|
statistics ? ItemStatisticsComponent(statistics) : null
|
|
@@ -9038,14 +6503,10 @@ function RivenOrderItemComponent(order, cnName, enName, thumb) {
|
|
|
9038
6503
|
__name(RivenOrderItemComponent, "RivenOrderItemComponent");
|
|
9039
6504
|
function RivenAttributeComponent(attr, index) {
|
|
9040
6505
|
const attrInfo = attr.attribute;
|
|
9041
|
-
const attrName = attrInfo
|
|
9042
|
-
const
|
|
9043
|
-
const
|
|
9044
|
-
|
|
9045
|
-
second: "s",
|
|
9046
|
-
multiply: ""
|
|
9047
|
-
};
|
|
9048
|
-
const attrValueSuffix = unitSuffixMap[attrInfo.unit] || "";
|
|
6506
|
+
const attrName = attrInfo?.i18n?.["zh-hans"]?.name ?? attrInfo?.i18n?.en?.name ?? attr.url_name;
|
|
6507
|
+
const unit = attrInfo?.unit ?? "";
|
|
6508
|
+
const attrValuePrefix = unit === "multiply" ? "x" : "";
|
|
6509
|
+
const attrValueSuffix = unit === "percent" ? "%" : unit === "second" ? "s" : "";
|
|
9049
6510
|
const attrValue = attrValuePrefix + attr.value + attrValueSuffix;
|
|
9050
6511
|
const positiveColors = ["#2e7d32", "#4a8c5a", "#6b9b78"];
|
|
9051
6512
|
const negativeColor = "#e05050";
|
|
@@ -9336,7 +6797,7 @@ function buildStatisticsTextLine(stats) {
|
|
|
9336
6797
|
__name(buildStatisticsTextLine, "buildStatisticsTextLine");
|
|
9337
6798
|
function wmMessage(img, item, orders, statistics) {
|
|
9338
6799
|
const lines = orders.slice(0, 3).map((order) => `
|
|
9339
|
-
/w ${order.user
|
|
6800
|
+
/w ${order.user?.ingameName ?? "Unknown"} Hi! I want to buy: "${item.i18n?.en?.name ?? item.i18n?.["zh-hans"]?.name ?? item.slug}${!item.maxRank || item.maxRank === 0 ? "" : ` (rank ${order.rank})`}" for ${order.platinum} platinum. (warframe.market)`);
|
|
9340
6801
|
const statLine = statistics ? buildStatisticsTextLine(statistics) : "";
|
|
9341
6802
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("message", { children: [
|
|
9342
6803
|
img,
|
|
@@ -9397,7 +6858,13 @@ function setupCommands(ctx, deps) {
|
|
|
9397
6858
|
ctx.command("fissure-sp", "当前钢铁之路虚空裂隙").alias("spfissure").alias("钢铁裂缝").alias("钢铁裂隙").action(wf.steelPathFissureCommand);
|
|
9398
6859
|
ctx.command("fissure-rj", "当前九重天虚空裂隙").alias("rjfissure").alias("九重天裂缝").alias("九重天裂隙").action(wf.railjackFissureCommand);
|
|
9399
6860
|
ctx.command("relic <relic-name:text>", "查询遗物内容").alias("遗物").alias("核桃").action(wf.relicCommand);
|
|
9400
|
-
ctx.command("environment", "当前各区域状态").alias("env").alias("平原").alias("
|
|
6861
|
+
ctx.command("environment", "当前各区域状态").alias("env").alias("平原").alias("夜灵平野").alias("奥布山谷").alias("魔胎之境").alias("扎里曼").action(wf.environmentCommand);
|
|
6862
|
+
ctx.command("bounty-cetus", "希图斯赏金").alias("希图斯").alias("希图斯赏金").alias("赏金希图斯").alias("cetus").alias("ostron").action(wf.bountyCetusCommand);
|
|
6863
|
+
ctx.command("bounty-fortuna", "福尔图娜赏金").alias("福尔图娜").alias("福尔图娜赏金").alias("赏金福尔图娜").alias("fortuna").alias("solaris").action(wf.bountyFortunaCommand);
|
|
6864
|
+
ctx.command("bounty-deimos", "火卫二赏金").alias("火卫二").alias("火卫二赏金").alias("赏金火卫二").alias("deimos").alias("entrati").action(wf.bountyDeimosCommand);
|
|
6865
|
+
ctx.command("bounty-zariman", "扎里曼赏金").alias("扎里曼赏金").alias("赏金扎里曼").alias("zariman").alias("holdfasts").action(wf.bountyZarimanCommand);
|
|
6866
|
+
ctx.command("bounty-cavia", "科维兽赏金").alias("科维兽").alias("科维兽赏金").alias("赏金科维兽").alias("cavia").action(wf.bountyCaviaCommand);
|
|
6867
|
+
ctx.command("bounty-hex", "六人组赏金").alias("六人组").alias("六人组赏金").alias("赏金六人组").alias("hex").action(wf.bountyHexCommand);
|
|
9401
6868
|
ctx.command("weekly", "周常任务").alias("周常").alias("科研").alias("时光科研").alias("深层科研").alias("执行官").action(wf.weeklyCommand);
|
|
9402
6869
|
ctx.command("circuit", "本周回廊战甲及灵化之源").alias("灵化之源").alias("灵化").action(wf.circuitCommand);
|
|
9403
6870
|
ctx.command("riven <img:image>", "分析紫卡截图").action(wf.rivenCommand);
|