@shopify/cli 3.61.2 → 3.62.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/dist/assets/dev-console/extensions/dev-console/assets/index-dfaab2a5.css +1 -0
- package/dist/assets/dev-console/extensions/dev-console/assets/{index-f3e60690.js → index-e3682a83.js} +1 -1
- package/dist/assets/dev-console/index.html +2 -2
- package/dist/{chokidar-RFZXZKRQ.js → chokidar-5MKSECYV.js} +4 -3
- package/dist/{chunk-QDZF6IG4.js → chunk-22PYIFA2.js} +112 -17
- package/dist/{chunk-3MBQVTEX.js → chunk-2QVJZ5TG.js} +2 -1
- package/dist/{chunk-KBXWK6XB.js → chunk-2ZSNH7CD.js} +4 -5
- package/dist/{chunk-BYFLATOA.js → chunk-5FNE3T7E.js} +5 -4
- package/dist/{chunk-G4EQLT5B.js → chunk-5X4QXYEZ.js} +9 -7
- package/dist/chunk-66NABVCG.js +73 -0
- package/dist/{chunk-LAY4AEXX.js → chunk-6UDFXWNE.js} +2 -1
- package/dist/{chunk-QQP6JS5H.js → chunk-7MXLRMOY.js} +3 -2
- package/dist/{chunk-EHF6FVWH.js → chunk-A5STII7T.js} +3 -2
- package/dist/{chunk-UPM6XNBH.js → chunk-ADESJ2KG.js} +6 -5
- package/dist/{chunk-BZJX2NV6.js → chunk-AMAYT2P2.js} +3 -2
- package/dist/{chunk-QTBH3GO6.js → chunk-B62HZLMM.js} +3 -2
- package/dist/{chunk-3RM5SOXY.js → chunk-BMTG2VHL.js} +4 -3
- package/dist/{chunk-FWGRGI4R.js → chunk-BYC3NA2Y.js} +2 -1
- package/dist/{chunk-NJTSDTDU.js → chunk-BZFXXFUC.js} +6 -5
- package/dist/{chunk-7IZTLXJ5.js → chunk-CKFE55FX.js} +4 -3
- package/dist/{chunk-YP5UVIUW.js → chunk-CYQRKZVM.js} +6 -5
- package/dist/{chunk-HTYJDJRZ.js → chunk-DL3MKXVR.js} +2 -1
- package/dist/{chunk-IUHH3PST.js → chunk-DLK3F3DC.js} +2 -1
- package/dist/{chunk-4XNS74OG.js → chunk-EARPFFS7.js} +2 -1
- package/dist/chunk-EQPYUHNM.js +3642 -0
- package/dist/{chunk-LKGDG6WW.js → chunk-FMKVOTQK.js} +2 -1
- package/dist/{chunk-I434ZJQI.js → chunk-GEN4RXTD.js} +7 -6
- package/dist/{chunk-QSO3GQEK.js → chunk-HJ4AUFE7.js} +94 -160
- package/dist/{chunk-FQIRJADJ.js → chunk-JIJ65JT6.js} +2 -1
- package/dist/{chunk-JQPQJN44.js → chunk-JKYNFUD3.js} +11 -12
- package/dist/{chunk-4L37JOS5.js → chunk-JL3ESOD2.js} +3 -2
- package/dist/{chunk-4TTAP7NN.js → chunk-JOOYCYFU.js} +6 -5
- package/dist/{chunk-XMJDBJPP.js → chunk-K3GG6Y3J.js} +12 -12
- package/dist/{chunk-VQZ2SHRY.js → chunk-K6257PKA.js} +3 -2
- package/dist/{chunk-5KRK4DLX.js → chunk-LC6MEJT3.js} +4 -3
- package/dist/{chunk-KDOLMUJB.js → chunk-LH533WG4.js} +2 -1
- package/dist/{chunk-FBB6KUZG.js → chunk-LSCXQWNO.js} +2 -1
- package/dist/{chunk-VC6CC75R.js → chunk-MG6QFKFM.js} +5 -4
- package/dist/{chunk-ETSILRIY.js → chunk-MQ2RGCDU.js} +5 -4
- package/dist/{chunk-QOHDW3X5.js → chunk-MQGV3PCJ.js} +4 -3
- package/dist/{chunk-PBFWVFAQ.js → chunk-NABCTJNW.js} +3 -2
- package/dist/{chunk-YZGLFVKK.js → chunk-NNASIYCT.js} +3 -2
- package/dist/chunk-PIB2FEJJ.js +4385 -0
- package/dist/{chunk-TXXQWILO.js → chunk-PIVNWN2P.js} +4 -3
- package/dist/{chunk-Q3KADKQA.js → chunk-PO6SEYU4.js} +4 -3
- package/dist/{chunk-FAFQQMD4.js → chunk-PRJ3U7MR.js} +2 -1
- package/dist/{chunk-5B2D56W6.js → chunk-Q4XGXPUG.js} +2 -1
- package/dist/{chunk-ZE2ZPLYI.js → chunk-QGJLRFY4.js} +19 -89
- package/dist/{chunk-RP2ISWQN.js → chunk-QOUOFEGO.js} +3 -2
- package/dist/{chunk-CWYZA7C7.js → chunk-RUSG4O2Z.js} +13464 -5175
- package/dist/{chunk-CKKROMZF.js → chunk-S4VBXFXP.js} +3 -2
- package/dist/{chunk-BE73NZXB.js → chunk-SAR5HGRG.js} +2 -1
- package/dist/{chunk-GXPKATXW.js → chunk-T5LLJYYS.js} +2 -1
- package/dist/{chunk-NBIE3DNN.js → chunk-TCRWMUKX.js} +4 -3
- package/dist/{chunk-4757GPBG.js → chunk-UACSLX64.js} +6 -5
- package/dist/{chunk-4KKFUTH7.js → chunk-UJ3QKFA5.js} +2 -1
- package/dist/chunk-UNPXLODI.js +121 -0
- package/dist/{chunk-RQ24VTW4.js → chunk-VM4POVNV.js} +2 -1
- package/dist/{chunk-CTETXMMM.js → chunk-VS6RWOLM.js} +8 -7
- package/dist/{chunk-BUWM6JUU.js → chunk-W5VEUSWG.js} +5 -4
- package/dist/{chunk-PCQFWMMD.js → chunk-WADS2TV5.js} +63 -5
- package/dist/{chunk-M73YMW2C.js → chunk-WAEWSGBK.js} +2579 -1632
- package/dist/{chunk-6SL33DOA.js → chunk-XQFDS44U.js} +2 -1
- package/dist/{chunk-WCNR75S2.js → chunk-YC4FLMDD.js} +2 -1
- package/dist/{chunk-OXZ2SRCK.js → chunk-YECNACSF.js} +3 -2
- package/dist/{chunk-QLLSCNEC.js → chunk-YX5VXHSJ.js} +4 -3
- package/dist/{chunk-5MODHNUE.js → chunk-ZCMXEGSE.js} +5 -4
- package/dist/{chunk-4VEOJ5JD.js → chunk-ZEHQN47F.js} +2 -1
- package/dist/{chunk-3JLUTHGR.js → chunk-ZPFJOUKZ.js} +2 -1
- package/dist/{chunk-M63RTPGR.js → chunk-ZPL24Y2D.js} +1 -0
- package/dist/cli/commands/auth/logout.js +37 -39
- package/dist/cli/commands/auth/logout.test.js +39 -41
- package/dist/cli/commands/debug/command-flags.js +33 -35
- package/dist/cli/commands/demo/catalog.js +36 -38
- package/dist/cli/commands/demo/generate-file.js +37 -39
- package/dist/cli/commands/demo/index.js +35 -37
- package/dist/cli/commands/demo/print-ai-prompt.js +37 -39
- package/dist/cli/commands/docs/generate.js +33 -35
- package/dist/cli/commands/docs/generate.test.js +34 -36
- package/dist/cli/commands/help.js +33 -35
- package/dist/cli/commands/kitchen-sink/async.js +34 -36
- package/dist/cli/commands/kitchen-sink/async.test.js +35 -37
- package/dist/cli/commands/kitchen-sink/index.js +36 -38
- package/dist/cli/commands/kitchen-sink/index.test.js +37 -39
- package/dist/cli/commands/kitchen-sink/prompts.js +34 -36
- package/dist/cli/commands/kitchen-sink/prompts.test.js +35 -37
- package/dist/cli/commands/kitchen-sink/static.js +34 -36
- package/dist/cli/commands/kitchen-sink/static.test.js +35 -37
- package/dist/cli/commands/search.js +34 -36
- package/dist/cli/commands/upgrade.js +33 -35
- package/dist/cli/commands/upgrade.test.js +5 -4
- package/dist/cli/commands/version.js +34 -36
- package/dist/cli/commands/version.test.js +35 -37
- package/dist/cli/services/commands/search.js +19 -21
- package/dist/cli/services/commands/search.test.js +20 -22
- package/dist/cli/services/commands/version.js +23 -25
- package/dist/cli/services/commands/version.test.js +25 -27
- package/dist/cli/services/demo.js +21 -23
- package/dist/cli/services/demo.test.js +22 -24
- package/dist/cli/services/kitchen-sink/async.js +19 -21
- package/dist/cli/services/kitchen-sink/prompts.js +19 -21
- package/dist/cli/services/kitchen-sink/static.js +19 -21
- package/dist/cli/services/upgrade.js +22 -24
- package/dist/cli/services/upgrade.test.js +30 -27
- package/dist/{constants-XCWOF7M7.js → constants-3CLHB4LQ.js} +5 -6
- package/dist/{custom-oclif-loader-4SQGUQ7D-P5C4NLSX.js → custom-oclif-loader-ZH42ZTTC.js} +25 -28
- package/dist/{del-DGT5RCOW.js → del-KSMMBLCD.js} +9 -8
- package/dist/{devtools-SJTLOVKU.js → devtools-6ZZ3EAY7.js} +3 -2
- package/dist/error-handler-I6WJC3U2.js +43 -0
- package/dist/error-handler-JFX2TIYX.js +38 -0
- package/dist/hooks/postrun.js +28 -30
- package/dist/hooks/prerun.js +23 -25
- package/dist/{http-proxy-WYSSUHIT.js → http-proxy-KFHAZRTT.js} +3 -2
- package/dist/index.js +138858 -143506
- package/dist/lib-E7NFRKVR.js +14 -0
- package/dist/{lib-RZNRJEWB.js → lib-LY6ZCPIO.js} +2 -1
- package/dist/{lib-AAMRQUES.js → lib-MUDJYT6A.js} +4 -3
- package/dist/{local-YKOG4EUR-XRRBWLSI.js → local-QXPV4RF5.js} +18 -14
- package/dist/{magic-string.es-6DE547FE.js → magic-string.es-ATGURXGQ.js} +2 -1
- package/dist/{morph-DCIZUK2Q.js → morph-WKKSW22O.js} +6 -5
- package/dist/{multipart-parser-ENLY4BKU.js → multipart-parser-KYOHF24X.js} +3 -2
- package/dist/{node-3DKQAOFU.js → node-5XXX7TNJ.js} +30 -29
- package/dist/{node-package-manager-HYTHPJBI.js → node-package-manager-O65VOP6W.js} +23 -23
- package/dist/{npa-AYOTDW63.js → npa-L2ZRSPZ2.js} +4 -3
- package/dist/{open-B7XFJJCK.js → open-JRS7RW22.js} +3 -2
- package/dist/out-AS7GH6TC.js +7 -0
- package/dist/{path-2NNC3QGW.js → path-JVVXOELJ.js} +10 -6
- package/dist/{source-map-V6UVDDPX.js → source-map-37TX6JEW.js} +2 -1
- package/dist/system-EEQBTJMJ.js +31 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/{ui-5LSDG3C5.js → ui-3BAHGNCQ.js} +20 -20
- package/dist/{workerd-TFH7T6NI.js → workerd-WR22YQIS.js} +29 -28
- package/oclif.manifest.json +108 -93
- package/package.json +15 -5
- package/dist/assets/dev-console/extensions/dev-console/assets/index-792a0c8d.css +0 -1
- package/dist/chunk-3LWRRBH5.js +0 -75
- package/dist/chunk-3PIGYQSE.js +0 -36
- package/dist/chunk-CK7MF3LY.js +0 -28803
- package/dist/chunk-J4I3URIN.js +0 -893
- package/dist/chunk-MHMFNQE3.js +0 -76
- package/dist/chunk-MXHK26B3.js +0 -89
- package/dist/chunk-NJP5GFNN.js +0 -29224
- package/dist/chunk-OC4AY5G7.js +0 -11936
- package/dist/chunk-OQBI57X3.js +0 -22
- package/dist/chunk-RPRKZ6JC.js +0 -53861
- package/dist/chunk-RTZHOWFC.js +0 -5485
- package/dist/chunk-SZQX5J7X.js +0 -64
- package/dist/chunk-T77LT3XG.js +0 -4743
- package/dist/chunk-UV4APOMB.js +0 -273
- package/dist/chunk-VF4VWJWS.js +0 -213222
- package/dist/chunk-WZBNLCJ5.js +0 -13452
- package/dist/chunk-YWPV7MV2.js +0 -16432
- package/dist/chunk-ZLGRKPW3.js +0 -68
- package/dist/chunk-ZZGXXS5X.js +0 -819
- package/dist/cli/commands/auth/logout.js.map +0 -1
- package/dist/cli/commands/debug/command-flags.js.map +0 -1
- package/dist/cli/commands/demo/catalog.js.map +0 -1
- package/dist/cli/commands/demo/generate-file.js.map +0 -1
- package/dist/cli/commands/demo/index.js.map +0 -1
- package/dist/cli/commands/demo/print-ai-prompt.js.map +0 -1
- package/dist/cli/commands/docs/generate.js.map +0 -1
- package/dist/cli/commands/help.js.map +0 -1
- package/dist/cli/commands/kitchen-sink/async.js.map +0 -1
- package/dist/cli/commands/kitchen-sink/index.js.map +0 -1
- package/dist/cli/commands/kitchen-sink/prompts.js.map +0 -1
- package/dist/cli/commands/kitchen-sink/static.js.map +0 -1
- package/dist/cli/commands/search.js.map +0 -1
- package/dist/cli/commands/upgrade.js.map +0 -1
- package/dist/cli/commands/version.js.map +0 -1
- package/dist/cli/services/commands/search.js.map +0 -1
- package/dist/cli/services/commands/version.js.map +0 -1
- package/dist/cli/services/demo.js.map +0 -1
- package/dist/cli/services/kitchen-sink/async.js.map +0 -1
- package/dist/cli/services/kitchen-sink/prompts.js.map +0 -1
- package/dist/cli/services/kitchen-sink/static.js.map +0 -1
- package/dist/cli/services/upgrade.js.map +0 -1
- package/dist/custom-oclif-loader-OD47SFAU.js +0 -92
- package/dist/del-ICEHOC6W-GYLFYUKX.js +0 -2817
- package/dist/devtools-6HZ2IPFU-GLFJP63E.js +0 -3557
- package/dist/devtools-IHJDLLT4.js +0 -77
- package/dist/error-handler-EPMFPTYX.js +0 -37
- package/dist/error-handler-WI4YVJIS-U3BMMYNJ.js +0 -31
- package/dist/error-handler-WL3Q25NI.js +0 -45
- package/dist/hooks/postrun.js.map +0 -1
- package/dist/hooks/prerun.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib-76RCE6WZ-5IYGTKKK.js +0 -17
- package/dist/lib-UYK3ZLZK.js +0 -13
- package/dist/local-KISH2IRF.js +0 -67
- package/dist/multipart-parser-ENLY4BKU-IUS26CJU.js +0 -363
- package/dist/node-package-manager-S7TSAUJZ-KKDY6KSF.js +0 -70
- package/dist/open-B7XFJJCK-4XEFFVL7.js +0 -295
- package/dist/out-LRIJ35RZ.js +0 -6
- package/dist/out-M5MRQZP5-YHIOILKU.js +0 -14
- package/dist/path-HO4HBKK5-4Q2BBYUA.js +0 -33
- package/dist/system-LIP7AECY.js +0 -33
- package/dist/ui-FUZYK6S3-PVVDPVD5.js +0 -51
|
@@ -0,0 +1,3642 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__commonJS,
|
|
3
|
+
__require,
|
|
4
|
+
init_cjs_shims
|
|
5
|
+
} from "./chunk-ZPL24Y2D.js";
|
|
6
|
+
|
|
7
|
+
// ../../node_modules/.pnpm/find-process@1.4.7/node_modules/find-process/lib/utils.js
|
|
8
|
+
var require_utils = __commonJS({
|
|
9
|
+
"../../node_modules/.pnpm/find-process@1.4.7/node_modules/find-process/lib/utils.js"(exports2, module2) {
|
|
10
|
+
"use strict";
|
|
11
|
+
init_cjs_shims();
|
|
12
|
+
var cp = __require("child_process");
|
|
13
|
+
var UNIT_MB = 1024 * 1024;
|
|
14
|
+
var utils = {
|
|
15
|
+
/**
|
|
16
|
+
* exec command with maxBuffer size
|
|
17
|
+
*/
|
|
18
|
+
exec(cmd, callback) {
|
|
19
|
+
cp.exec(cmd, {
|
|
20
|
+
maxBuffer: 2 * UNIT_MB,
|
|
21
|
+
windowsHide: true
|
|
22
|
+
}, callback);
|
|
23
|
+
},
|
|
24
|
+
/**
|
|
25
|
+
* spawn command
|
|
26
|
+
*/
|
|
27
|
+
spawn(cmd, args, options2) {
|
|
28
|
+
return cp.spawn(cmd, args, options2);
|
|
29
|
+
},
|
|
30
|
+
/**
|
|
31
|
+
* Strip top lines of text
|
|
32
|
+
*
|
|
33
|
+
* @param {String} text
|
|
34
|
+
* @param {Number} num
|
|
35
|
+
* @return {String}
|
|
36
|
+
*/
|
|
37
|
+
stripLine(text, num) {
|
|
38
|
+
let idx = 0;
|
|
39
|
+
while (num-- > 0) {
|
|
40
|
+
const nIdx = text.indexOf("\n", idx);
|
|
41
|
+
if (nIdx >= 0) {
|
|
42
|
+
idx = nIdx + 1;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return idx > 0 ? text.substring(idx) : text;
|
|
46
|
+
},
|
|
47
|
+
/**
|
|
48
|
+
* Split string and stop at max parts
|
|
49
|
+
*
|
|
50
|
+
* @param {Number} line
|
|
51
|
+
* @param {Number} max
|
|
52
|
+
* @return {Array}
|
|
53
|
+
*/
|
|
54
|
+
split(line, max) {
|
|
55
|
+
const cols = line.trim().split(/\s+/);
|
|
56
|
+
if (cols.length > max) {
|
|
57
|
+
cols[max - 1] = cols.slice(max - 1).join(" ");
|
|
58
|
+
}
|
|
59
|
+
return cols;
|
|
60
|
+
},
|
|
61
|
+
/**
|
|
62
|
+
* Extract columns from table text
|
|
63
|
+
*
|
|
64
|
+
* Example:
|
|
65
|
+
*
|
|
66
|
+
* ```
|
|
67
|
+
* extractColumns(text, [0, 2], 3)
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* From:
|
|
71
|
+
* ```
|
|
72
|
+
* foo bar bar2
|
|
73
|
+
* valx valy valz
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* To:
|
|
77
|
+
* ```
|
|
78
|
+
* [ ['foo', 'bar2'], ['valx', 'valz'] ]
|
|
79
|
+
* ```
|
|
80
|
+
*
|
|
81
|
+
* @param {String} text raw table text
|
|
82
|
+
* @param {Array} idxes the column index list to extract
|
|
83
|
+
* @param {Number} max max column number of table
|
|
84
|
+
* @return {Array}
|
|
85
|
+
*/
|
|
86
|
+
extractColumns(text, idxes, max) {
|
|
87
|
+
const lines = text.split(/(\r\n|\n|\r)/);
|
|
88
|
+
const columns = [];
|
|
89
|
+
if (!max) {
|
|
90
|
+
max = Math.max.apply(null, idxes) + 1;
|
|
91
|
+
}
|
|
92
|
+
lines.forEach((line) => {
|
|
93
|
+
const cols = utils.split(line, max);
|
|
94
|
+
const column = [];
|
|
95
|
+
idxes.forEach((idx) => {
|
|
96
|
+
column.push(cols[idx] || "");
|
|
97
|
+
});
|
|
98
|
+
columns.push(column);
|
|
99
|
+
});
|
|
100
|
+
return columns;
|
|
101
|
+
},
|
|
102
|
+
/**
|
|
103
|
+
* parse table text to array
|
|
104
|
+
*
|
|
105
|
+
* From:
|
|
106
|
+
* ```
|
|
107
|
+
* Header1 : foo
|
|
108
|
+
* Header2 : bar
|
|
109
|
+
* Header3 : val
|
|
110
|
+
*
|
|
111
|
+
* Header1 : foo2
|
|
112
|
+
* Header2 : bar2
|
|
113
|
+
* Header3 : val2
|
|
114
|
+
* ```
|
|
115
|
+
*
|
|
116
|
+
* To:
|
|
117
|
+
* ```
|
|
118
|
+
* [{ Header1: 'foo', Header2: 'bar', Header3: 'val' }, ...]
|
|
119
|
+
* ```
|
|
120
|
+
*
|
|
121
|
+
* @param {String} data raw table data
|
|
122
|
+
* @return {Array}
|
|
123
|
+
*/
|
|
124
|
+
parseTable(data) {
|
|
125
|
+
const lines = data.split(/(\r\n\r\n|\r\n\n|\n\r\n)|\n\n/).filter((line) => {
|
|
126
|
+
return line.trim().length > 0;
|
|
127
|
+
}).map((e) => e.split(/(\r\n|\n|\r)/).filter((line) => line.trim().length > 0));
|
|
128
|
+
lines.forEach((line) => {
|
|
129
|
+
for (let index = 0; line[index]; ) {
|
|
130
|
+
const entry = line[index];
|
|
131
|
+
if (entry.startsWith(" ")) {
|
|
132
|
+
line[index - 1] += entry.trimLeft();
|
|
133
|
+
line.splice(index, 1);
|
|
134
|
+
} else {
|
|
135
|
+
index += 1;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
return lines.map((line) => {
|
|
140
|
+
const row = {};
|
|
141
|
+
line.forEach((string) => {
|
|
142
|
+
const splitterIndex = string.indexOf(":");
|
|
143
|
+
const key = string.slice(0, splitterIndex).trim();
|
|
144
|
+
row[key] = string.slice(splitterIndex + 1).trim();
|
|
145
|
+
});
|
|
146
|
+
return row;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
module2.exports = utils;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
// ../../node_modules/.pnpm/find-process@1.4.7/node_modules/find-process/lib/find_pid.js
|
|
155
|
+
var require_find_pid = __commonJS({
|
|
156
|
+
"../../node_modules/.pnpm/find-process@1.4.7/node_modules/find-process/lib/find_pid.js"(exports2, module2) {
|
|
157
|
+
"use strict";
|
|
158
|
+
init_cjs_shims();
|
|
159
|
+
var os = __require("os");
|
|
160
|
+
var fs = __require("fs");
|
|
161
|
+
var utils = require_utils();
|
|
162
|
+
var ensureDir = (path) => new Promise((resolve, reject) => {
|
|
163
|
+
if (fs.existsSync(path)) {
|
|
164
|
+
resolve();
|
|
165
|
+
} else {
|
|
166
|
+
fs.mkdir(path, (err) => {
|
|
167
|
+
err ? reject(err) : resolve();
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
var finders = {
|
|
172
|
+
darwin(port) {
|
|
173
|
+
return new Promise((resolve, reject) => {
|
|
174
|
+
utils.exec("netstat -anv -p TCP && netstat -anv -p UDP", function(err, stdout, stderr) {
|
|
175
|
+
if (err) {
|
|
176
|
+
reject(err);
|
|
177
|
+
} else {
|
|
178
|
+
err = stderr.toString().trim();
|
|
179
|
+
if (err) {
|
|
180
|
+
reject(err);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
const data = utils.stripLine(stdout.toString(), 2);
|
|
184
|
+
const found = utils.extractColumns(data, [0, 3, 8], 10).filter((row) => {
|
|
185
|
+
return !!String(row[0]).match(/^(udp|tcp)/);
|
|
186
|
+
}).find((row) => {
|
|
187
|
+
const matches = String(row[1]).match(/\.(\d+)$/);
|
|
188
|
+
if (matches && matches[1] === String(port)) {
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
if (found && found[2].length) {
|
|
193
|
+
resolve(parseInt(found[2], 10));
|
|
194
|
+
} else {
|
|
195
|
+
reject(new Error(`pid of port (${port}) not found`));
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
},
|
|
201
|
+
freebsd: "darwin",
|
|
202
|
+
sunos: "darwin",
|
|
203
|
+
linux(port) {
|
|
204
|
+
return new Promise((resolve, reject) => {
|
|
205
|
+
const cmd = "netstat -tunlp";
|
|
206
|
+
utils.exec(cmd, function(err, stdout, stderr) {
|
|
207
|
+
if (err) {
|
|
208
|
+
reject(err);
|
|
209
|
+
} else {
|
|
210
|
+
const warn = stderr.toString().trim();
|
|
211
|
+
if (warn) {
|
|
212
|
+
console.warn(warn);
|
|
213
|
+
}
|
|
214
|
+
const data = utils.stripLine(stdout.toString(), 2);
|
|
215
|
+
const columns = utils.extractColumns(data, [3, 6], 7).find((column) => {
|
|
216
|
+
const matches = String(column[0]).match(/:(\d+)$/);
|
|
217
|
+
if (matches && matches[1] === String(port)) {
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
if (columns && columns[1]) {
|
|
222
|
+
const pid = columns[1].split("/", 1)[0];
|
|
223
|
+
if (pid.length) {
|
|
224
|
+
resolve(parseInt(pid, 10));
|
|
225
|
+
} else {
|
|
226
|
+
reject(new Error(`pid of port (${port}) not found`));
|
|
227
|
+
}
|
|
228
|
+
} else {
|
|
229
|
+
reject(new Error(`pid of port (${port}) not found`));
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
},
|
|
235
|
+
win32(port) {
|
|
236
|
+
return new Promise((resolve, reject) => {
|
|
237
|
+
utils.exec("netstat -ano", function(err, stdout, stderr) {
|
|
238
|
+
if (err) {
|
|
239
|
+
reject(err);
|
|
240
|
+
} else {
|
|
241
|
+
err = stderr.toString().trim();
|
|
242
|
+
if (err) {
|
|
243
|
+
reject(err);
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
const data = utils.stripLine(stdout.toString(), 4);
|
|
247
|
+
const columns = utils.extractColumns(data, [1, 4], 5).find((column) => {
|
|
248
|
+
const matches = String(column[0]).match(/:(\d+)$/);
|
|
249
|
+
if (matches && matches[1] === String(port)) {
|
|
250
|
+
return true;
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
if (columns && columns[1].length && parseInt(columns[1], 10) > 0) {
|
|
254
|
+
resolve(parseInt(columns[1], 10));
|
|
255
|
+
} else {
|
|
256
|
+
reject(new Error(`pid of port (${port}) not found`));
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
},
|
|
262
|
+
android(port) {
|
|
263
|
+
return new Promise((resolve, reject) => {
|
|
264
|
+
const dir = os.tmpdir() + "/.find-process";
|
|
265
|
+
const file = dir + "/" + process.pid;
|
|
266
|
+
const cmd = 'netstat -tunp >> "' + file + '"';
|
|
267
|
+
ensureDir(dir).then(() => {
|
|
268
|
+
utils.exec(cmd, () => {
|
|
269
|
+
fs.readFile(file, "utf8", (err, data) => {
|
|
270
|
+
fs.unlink(file, () => {
|
|
271
|
+
});
|
|
272
|
+
if (err) {
|
|
273
|
+
reject(err);
|
|
274
|
+
} else {
|
|
275
|
+
data = utils.stripLine(data, 2);
|
|
276
|
+
const columns = utils.extractColumns(data, [3, 6], 7).find((column) => {
|
|
277
|
+
const matches = String(column[0]).match(/:(\d+)$/);
|
|
278
|
+
if (matches && matches[1] === String(port)) {
|
|
279
|
+
return true;
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
if (columns && columns[1]) {
|
|
283
|
+
const pid = columns[1].split("/", 1)[0];
|
|
284
|
+
if (pid.length) {
|
|
285
|
+
resolve(parseInt(pid, 10));
|
|
286
|
+
} else {
|
|
287
|
+
reject(new Error(`pid of port (${port}) not found`));
|
|
288
|
+
}
|
|
289
|
+
} else {
|
|
290
|
+
reject(new Error(`pid of port (${port}) not found`));
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
function findPidByPort(port) {
|
|
300
|
+
const platform = process.platform;
|
|
301
|
+
return new Promise((resolve, reject) => {
|
|
302
|
+
if (!(platform in finders)) {
|
|
303
|
+
return reject(new Error(`platform ${platform} is unsupported`));
|
|
304
|
+
}
|
|
305
|
+
let findPid = finders[platform];
|
|
306
|
+
if (typeof findPid === "string") {
|
|
307
|
+
findPid = finders[findPid];
|
|
308
|
+
}
|
|
309
|
+
findPid(port).then(resolve, reject);
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
module2.exports = findPidByPort;
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
// ../../node_modules/.pnpm/find-process@1.4.7/node_modules/find-process/lib/find_process.js
|
|
317
|
+
var require_find_process = __commonJS({
|
|
318
|
+
"../../node_modules/.pnpm/find-process@1.4.7/node_modules/find-process/lib/find_process.js"(exports2, module2) {
|
|
319
|
+
"use strict";
|
|
320
|
+
init_cjs_shims();
|
|
321
|
+
var path = __require("path");
|
|
322
|
+
var utils = require_utils();
|
|
323
|
+
function matchName(text, name) {
|
|
324
|
+
if (!name) {
|
|
325
|
+
return true;
|
|
326
|
+
}
|
|
327
|
+
if (text && text.match) {
|
|
328
|
+
return text.match(name);
|
|
329
|
+
}
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
function fetchBin(cmd) {
|
|
333
|
+
const pieces = cmd.split(path.sep);
|
|
334
|
+
const last = pieces[pieces.length - 1];
|
|
335
|
+
if (last) {
|
|
336
|
+
pieces[pieces.length - 1] = last.split(" ")[0];
|
|
337
|
+
}
|
|
338
|
+
const fixed = [];
|
|
339
|
+
for (const part of pieces) {
|
|
340
|
+
const optIdx = part.indexOf(" -");
|
|
341
|
+
if (optIdx >= 0) {
|
|
342
|
+
fixed.push(part.substring(0, optIdx).trim());
|
|
343
|
+
break;
|
|
344
|
+
} else if (part.endsWith(" ")) {
|
|
345
|
+
fixed.push(part.trim());
|
|
346
|
+
break;
|
|
347
|
+
}
|
|
348
|
+
fixed.push(part);
|
|
349
|
+
}
|
|
350
|
+
return fixed.join(path.sep);
|
|
351
|
+
}
|
|
352
|
+
function fetchName(fullpath) {
|
|
353
|
+
if (process.platform === "darwin") {
|
|
354
|
+
const idx = fullpath.indexOf(".app/");
|
|
355
|
+
if (idx >= 0) {
|
|
356
|
+
return path.basename(fullpath.substring(0, idx));
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return path.basename(fullpath);
|
|
360
|
+
}
|
|
361
|
+
var finders = {
|
|
362
|
+
darwin(cond) {
|
|
363
|
+
return new Promise((resolve, reject) => {
|
|
364
|
+
let cmd;
|
|
365
|
+
if ("pid" in cond) {
|
|
366
|
+
cmd = `ps -p ${cond.pid} -ww -o pid,ppid,uid,gid,args`;
|
|
367
|
+
} else {
|
|
368
|
+
cmd = "ps ax -ww -o pid,ppid,uid,gid,args";
|
|
369
|
+
}
|
|
370
|
+
utils.exec(cmd, function(err, stdout, stderr) {
|
|
371
|
+
if (err) {
|
|
372
|
+
if ("pid" in cond) {
|
|
373
|
+
resolve([]);
|
|
374
|
+
} else {
|
|
375
|
+
reject(err);
|
|
376
|
+
}
|
|
377
|
+
} else {
|
|
378
|
+
err = stderr.toString().trim();
|
|
379
|
+
if (err) {
|
|
380
|
+
reject(err);
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
const data = utils.stripLine(stdout.toString(), 1);
|
|
384
|
+
const columns = utils.extractColumns(data, [0, 1, 2, 3, 4], 5).filter((column) => {
|
|
385
|
+
if (column[0] && cond.pid) {
|
|
386
|
+
return column[0] === String(cond.pid);
|
|
387
|
+
} else if (column[4] && cond.name) {
|
|
388
|
+
return matchName(column[4], cond.name);
|
|
389
|
+
} else {
|
|
390
|
+
return !!column[0];
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
let list = columns.map((column) => {
|
|
394
|
+
const cmd2 = String(column[4]);
|
|
395
|
+
const bin = fetchBin(cmd2);
|
|
396
|
+
return {
|
|
397
|
+
pid: parseInt(column[0], 10),
|
|
398
|
+
ppid: parseInt(column[1], 10),
|
|
399
|
+
uid: parseInt(column[2], 10),
|
|
400
|
+
gid: parseInt(column[3], 10),
|
|
401
|
+
name: fetchName(bin),
|
|
402
|
+
bin,
|
|
403
|
+
cmd: column[4]
|
|
404
|
+
};
|
|
405
|
+
});
|
|
406
|
+
if (cond.strict && cond.name) {
|
|
407
|
+
list = list.filter((item) => item.name === cond.name);
|
|
408
|
+
}
|
|
409
|
+
resolve(list);
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
},
|
|
414
|
+
linux: "darwin",
|
|
415
|
+
sunos: "darwin",
|
|
416
|
+
freebsd: "darwin",
|
|
417
|
+
win32(cond) {
|
|
418
|
+
return new Promise((resolve, reject) => {
|
|
419
|
+
const cmd = "Get-CimInstance -className win32_process | select Name,ProcessId,ParentProcessId,CommandLine,ExecutablePath";
|
|
420
|
+
const lines = [];
|
|
421
|
+
const proc = utils.spawn("powershell.exe", ["/c", cmd], { detached: false, windowsHide: true });
|
|
422
|
+
proc.stdout.on("data", (data) => {
|
|
423
|
+
lines.push(data.toString());
|
|
424
|
+
});
|
|
425
|
+
proc.on("close", (code) => {
|
|
426
|
+
if (code !== 0) {
|
|
427
|
+
return reject(new Error("Command '" + cmd + "' terminated with code: " + code));
|
|
428
|
+
}
|
|
429
|
+
const list = utils.parseTable(lines.join("")).filter((row) => {
|
|
430
|
+
if ("pid" in cond) {
|
|
431
|
+
return row.ProcessId === String(cond.pid);
|
|
432
|
+
} else if (cond.name) {
|
|
433
|
+
const rowName = row.Name || "";
|
|
434
|
+
if (cond.strict) {
|
|
435
|
+
return rowName === cond.name || rowName.endsWith(".exe") && rowName.slice(0, -4) === cond.name;
|
|
436
|
+
} else {
|
|
437
|
+
return matchName(row.CommandLine || rowName, cond.name);
|
|
438
|
+
}
|
|
439
|
+
} else {
|
|
440
|
+
return true;
|
|
441
|
+
}
|
|
442
|
+
}).map((row) => ({
|
|
443
|
+
pid: parseInt(row.ProcessId, 10),
|
|
444
|
+
ppid: parseInt(row.ParentProcessId, 10),
|
|
445
|
+
// uid: void 0,
|
|
446
|
+
// gid: void 0,
|
|
447
|
+
bin: row.ExecutablePath,
|
|
448
|
+
name: row.Name || "",
|
|
449
|
+
cmd: row.CommandLine
|
|
450
|
+
}));
|
|
451
|
+
resolve(list);
|
|
452
|
+
});
|
|
453
|
+
});
|
|
454
|
+
},
|
|
455
|
+
android(cond) {
|
|
456
|
+
return new Promise((resolve, reject) => {
|
|
457
|
+
const cmd = "ps";
|
|
458
|
+
utils.exec(cmd, function(err, stdout, stderr) {
|
|
459
|
+
if (err) {
|
|
460
|
+
if ("pid" in cond) {
|
|
461
|
+
resolve([]);
|
|
462
|
+
} else {
|
|
463
|
+
reject(err);
|
|
464
|
+
}
|
|
465
|
+
} else {
|
|
466
|
+
err = stderr.toString().trim();
|
|
467
|
+
if (err) {
|
|
468
|
+
reject(err);
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
const data = utils.stripLine(stdout.toString(), 1);
|
|
472
|
+
const columns = utils.extractColumns(data, [0, 3], 4).filter((column) => {
|
|
473
|
+
if (column[0] && cond.pid) {
|
|
474
|
+
return column[0] === String(cond.pid);
|
|
475
|
+
} else if (column[1] && cond.name) {
|
|
476
|
+
return matchName(column[1], cond.name);
|
|
477
|
+
} else {
|
|
478
|
+
return !!column[0];
|
|
479
|
+
}
|
|
480
|
+
});
|
|
481
|
+
let list = columns.map((column) => {
|
|
482
|
+
const cmd2 = String(column[1]);
|
|
483
|
+
const bin = fetchBin(cmd2);
|
|
484
|
+
return {
|
|
485
|
+
pid: parseInt(column[0], 10),
|
|
486
|
+
// ppid: void 0,
|
|
487
|
+
// uid: void 0,
|
|
488
|
+
// gid: void 0,
|
|
489
|
+
name: fetchName(bin),
|
|
490
|
+
bin,
|
|
491
|
+
cmd: cmd2
|
|
492
|
+
};
|
|
493
|
+
});
|
|
494
|
+
if (cond.strict && cond.name) {
|
|
495
|
+
list = list.filter((item) => item.name === cond.name);
|
|
496
|
+
}
|
|
497
|
+
resolve(list);
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
};
|
|
503
|
+
function findProcess(cond) {
|
|
504
|
+
const platform = process.platform;
|
|
505
|
+
return new Promise((resolve, reject) => {
|
|
506
|
+
if (!(platform in finders)) {
|
|
507
|
+
return reject(new Error(`platform ${platform} is unsupported`));
|
|
508
|
+
}
|
|
509
|
+
let find = finders[platform];
|
|
510
|
+
if (typeof find === "string") {
|
|
511
|
+
find = finders[find];
|
|
512
|
+
}
|
|
513
|
+
find(cond).then(resolve, reject);
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
module2.exports = findProcess;
|
|
517
|
+
}
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
// ../../node_modules/.pnpm/find-process@1.4.7/node_modules/find-process/lib/find.js
|
|
521
|
+
var require_find = __commonJS({
|
|
522
|
+
"../../node_modules/.pnpm/find-process@1.4.7/node_modules/find-process/lib/find.js"(exports2, module2) {
|
|
523
|
+
"use strict";
|
|
524
|
+
init_cjs_shims();
|
|
525
|
+
var findPid = require_find_pid();
|
|
526
|
+
var findProcess = require_find_process();
|
|
527
|
+
var findBy = {
|
|
528
|
+
port(port, strict) {
|
|
529
|
+
return findPid(port, strict).then((pid) => {
|
|
530
|
+
return findBy.pid(pid, strict);
|
|
531
|
+
}, () => {
|
|
532
|
+
return [];
|
|
533
|
+
});
|
|
534
|
+
},
|
|
535
|
+
pid(pid, strict) {
|
|
536
|
+
return findProcess({
|
|
537
|
+
pid,
|
|
538
|
+
strict
|
|
539
|
+
});
|
|
540
|
+
},
|
|
541
|
+
name(name, strict) {
|
|
542
|
+
return findProcess({
|
|
543
|
+
name,
|
|
544
|
+
strict
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
function find(by, value, strict) {
|
|
549
|
+
return new Promise((resolve, reject) => {
|
|
550
|
+
if (!(by in findBy)) {
|
|
551
|
+
reject(new Error(`do not support find by "${by}"`));
|
|
552
|
+
} else {
|
|
553
|
+
const isNumber = /^\d+$/.test(value);
|
|
554
|
+
if (by === "pid" && !isNumber) {
|
|
555
|
+
reject(new Error("pid must be a number"));
|
|
556
|
+
} else if (by === "port" && !isNumber) {
|
|
557
|
+
reject(new Error("port must be a number"));
|
|
558
|
+
} else {
|
|
559
|
+
findBy[by](value, strict).then(resolve, reject);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
module2.exports = find;
|
|
565
|
+
}
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
// ../../node_modules/.pnpm/find-process@1.4.7/node_modules/find-process/index.js
|
|
569
|
+
var require_find_process2 = __commonJS({
|
|
570
|
+
"../../node_modules/.pnpm/find-process@1.4.7/node_modules/find-process/index.js"(exports2, module2) {
|
|
571
|
+
"use strict";
|
|
572
|
+
init_cjs_shims();
|
|
573
|
+
module2.exports = require_find();
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
|
|
577
|
+
// ../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/parser.js
|
|
578
|
+
var require_parser = __commonJS({
|
|
579
|
+
"../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/parser.js"(exports2) {
|
|
580
|
+
"use strict";
|
|
581
|
+
init_cjs_shims();
|
|
582
|
+
exports2.load = function(received, defaults, onto = {}) {
|
|
583
|
+
var k, ref, v;
|
|
584
|
+
for (k in defaults) {
|
|
585
|
+
v = defaults[k];
|
|
586
|
+
onto[k] = (ref = received[k]) != null ? ref : v;
|
|
587
|
+
}
|
|
588
|
+
return onto;
|
|
589
|
+
};
|
|
590
|
+
exports2.overwrite = function(received, defaults, onto = {}) {
|
|
591
|
+
var k, v;
|
|
592
|
+
for (k in received) {
|
|
593
|
+
v = received[k];
|
|
594
|
+
if (defaults[k] !== void 0) {
|
|
595
|
+
onto[k] = v;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
return onto;
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
});
|
|
602
|
+
|
|
603
|
+
// ../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/DLList.js
|
|
604
|
+
var require_DLList = __commonJS({
|
|
605
|
+
"../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/DLList.js"(exports2, module2) {
|
|
606
|
+
"use strict";
|
|
607
|
+
init_cjs_shims();
|
|
608
|
+
var DLList;
|
|
609
|
+
DLList = class DLList {
|
|
610
|
+
constructor(incr, decr) {
|
|
611
|
+
this.incr = incr;
|
|
612
|
+
this.decr = decr;
|
|
613
|
+
this._first = null;
|
|
614
|
+
this._last = null;
|
|
615
|
+
this.length = 0;
|
|
616
|
+
}
|
|
617
|
+
push(value) {
|
|
618
|
+
var node;
|
|
619
|
+
this.length++;
|
|
620
|
+
if (typeof this.incr === "function") {
|
|
621
|
+
this.incr();
|
|
622
|
+
}
|
|
623
|
+
node = {
|
|
624
|
+
value,
|
|
625
|
+
prev: this._last,
|
|
626
|
+
next: null
|
|
627
|
+
};
|
|
628
|
+
if (this._last != null) {
|
|
629
|
+
this._last.next = node;
|
|
630
|
+
this._last = node;
|
|
631
|
+
} else {
|
|
632
|
+
this._first = this._last = node;
|
|
633
|
+
}
|
|
634
|
+
return void 0;
|
|
635
|
+
}
|
|
636
|
+
shift() {
|
|
637
|
+
var value;
|
|
638
|
+
if (this._first == null) {
|
|
639
|
+
return;
|
|
640
|
+
} else {
|
|
641
|
+
this.length--;
|
|
642
|
+
if (typeof this.decr === "function") {
|
|
643
|
+
this.decr();
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
value = this._first.value;
|
|
647
|
+
if ((this._first = this._first.next) != null) {
|
|
648
|
+
this._first.prev = null;
|
|
649
|
+
} else {
|
|
650
|
+
this._last = null;
|
|
651
|
+
}
|
|
652
|
+
return value;
|
|
653
|
+
}
|
|
654
|
+
first() {
|
|
655
|
+
if (this._first != null) {
|
|
656
|
+
return this._first.value;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
getArray() {
|
|
660
|
+
var node, ref, results;
|
|
661
|
+
node = this._first;
|
|
662
|
+
results = [];
|
|
663
|
+
while (node != null) {
|
|
664
|
+
results.push((ref = node, node = node.next, ref.value));
|
|
665
|
+
}
|
|
666
|
+
return results;
|
|
667
|
+
}
|
|
668
|
+
forEachShift(cb) {
|
|
669
|
+
var node;
|
|
670
|
+
node = this.shift();
|
|
671
|
+
while (node != null) {
|
|
672
|
+
cb(node), node = this.shift();
|
|
673
|
+
}
|
|
674
|
+
return void 0;
|
|
675
|
+
}
|
|
676
|
+
debug() {
|
|
677
|
+
var node, ref, ref1, ref2, results;
|
|
678
|
+
node = this._first;
|
|
679
|
+
results = [];
|
|
680
|
+
while (node != null) {
|
|
681
|
+
results.push((ref = node, node = node.next, {
|
|
682
|
+
value: ref.value,
|
|
683
|
+
prev: (ref1 = ref.prev) != null ? ref1.value : void 0,
|
|
684
|
+
next: (ref2 = ref.next) != null ? ref2.value : void 0
|
|
685
|
+
}));
|
|
686
|
+
}
|
|
687
|
+
return results;
|
|
688
|
+
}
|
|
689
|
+
};
|
|
690
|
+
module2.exports = DLList;
|
|
691
|
+
}
|
|
692
|
+
});
|
|
693
|
+
|
|
694
|
+
// ../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/Events.js
|
|
695
|
+
var require_Events = __commonJS({
|
|
696
|
+
"../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/Events.js"(exports2, module2) {
|
|
697
|
+
"use strict";
|
|
698
|
+
init_cjs_shims();
|
|
699
|
+
function asyncGeneratorStep2(gen, resolve, reject, _next, _throw, key, arg) {
|
|
700
|
+
try {
|
|
701
|
+
var info = gen[key](arg);
|
|
702
|
+
var value = info.value;
|
|
703
|
+
} catch (error) {
|
|
704
|
+
reject(error);
|
|
705
|
+
return;
|
|
706
|
+
}
|
|
707
|
+
if (info.done) {
|
|
708
|
+
resolve(value);
|
|
709
|
+
} else {
|
|
710
|
+
Promise.resolve(value).then(_next, _throw);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
function _asyncToGenerator2(fn) {
|
|
714
|
+
return function() {
|
|
715
|
+
var self = this, args = arguments;
|
|
716
|
+
return new Promise(function(resolve, reject) {
|
|
717
|
+
var gen = fn.apply(self, args);
|
|
718
|
+
function _next(value) {
|
|
719
|
+
asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "next", value);
|
|
720
|
+
}
|
|
721
|
+
function _throw(err) {
|
|
722
|
+
asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "throw", err);
|
|
723
|
+
}
|
|
724
|
+
_next(void 0);
|
|
725
|
+
});
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
var Events2;
|
|
729
|
+
Events2 = class Events {
|
|
730
|
+
constructor(instance) {
|
|
731
|
+
this.instance = instance;
|
|
732
|
+
this._events = {};
|
|
733
|
+
if (this.instance.on != null || this.instance.once != null || this.instance.removeAllListeners != null) {
|
|
734
|
+
throw new Error("An Emitter already exists for this object");
|
|
735
|
+
}
|
|
736
|
+
this.instance.on = (name, cb) => {
|
|
737
|
+
return this._addListener(name, "many", cb);
|
|
738
|
+
};
|
|
739
|
+
this.instance.once = (name, cb) => {
|
|
740
|
+
return this._addListener(name, "once", cb);
|
|
741
|
+
};
|
|
742
|
+
this.instance.removeAllListeners = (name = null) => {
|
|
743
|
+
if (name != null) {
|
|
744
|
+
return delete this._events[name];
|
|
745
|
+
} else {
|
|
746
|
+
return this._events = {};
|
|
747
|
+
}
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
_addListener(name, status, cb) {
|
|
751
|
+
var base;
|
|
752
|
+
if ((base = this._events)[name] == null) {
|
|
753
|
+
base[name] = [];
|
|
754
|
+
}
|
|
755
|
+
this._events[name].push({
|
|
756
|
+
cb,
|
|
757
|
+
status
|
|
758
|
+
});
|
|
759
|
+
return this.instance;
|
|
760
|
+
}
|
|
761
|
+
listenerCount(name) {
|
|
762
|
+
if (this._events[name] != null) {
|
|
763
|
+
return this._events[name].length;
|
|
764
|
+
} else {
|
|
765
|
+
return 0;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
trigger(name, ...args) {
|
|
769
|
+
var _this = this;
|
|
770
|
+
return _asyncToGenerator2(function* () {
|
|
771
|
+
var e, promises;
|
|
772
|
+
try {
|
|
773
|
+
if (name !== "debug") {
|
|
774
|
+
_this.trigger("debug", `Event triggered: ${name}`, args);
|
|
775
|
+
}
|
|
776
|
+
if (_this._events[name] == null) {
|
|
777
|
+
return;
|
|
778
|
+
}
|
|
779
|
+
_this._events[name] = _this._events[name].filter(function(listener) {
|
|
780
|
+
return listener.status !== "none";
|
|
781
|
+
});
|
|
782
|
+
promises = _this._events[name].map(
|
|
783
|
+
/* @__PURE__ */ function() {
|
|
784
|
+
var _ref = _asyncToGenerator2(function* (listener) {
|
|
785
|
+
var e2, returned;
|
|
786
|
+
if (listener.status === "none") {
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
if (listener.status === "once") {
|
|
790
|
+
listener.status = "none";
|
|
791
|
+
}
|
|
792
|
+
try {
|
|
793
|
+
returned = typeof listener.cb === "function" ? listener.cb(...args) : void 0;
|
|
794
|
+
if (typeof (returned != null ? returned.then : void 0) === "function") {
|
|
795
|
+
return yield returned;
|
|
796
|
+
} else {
|
|
797
|
+
return returned;
|
|
798
|
+
}
|
|
799
|
+
} catch (error) {
|
|
800
|
+
e2 = error;
|
|
801
|
+
if (true) {
|
|
802
|
+
_this.trigger("error", e2);
|
|
803
|
+
}
|
|
804
|
+
return null;
|
|
805
|
+
}
|
|
806
|
+
});
|
|
807
|
+
return function(_x) {
|
|
808
|
+
return _ref.apply(this, arguments);
|
|
809
|
+
};
|
|
810
|
+
}()
|
|
811
|
+
);
|
|
812
|
+
return (yield Promise.all(promises)).find(function(x) {
|
|
813
|
+
return x != null;
|
|
814
|
+
});
|
|
815
|
+
} catch (error) {
|
|
816
|
+
e = error;
|
|
817
|
+
if (true) {
|
|
818
|
+
_this.trigger("error", e);
|
|
819
|
+
}
|
|
820
|
+
return null;
|
|
821
|
+
}
|
|
822
|
+
})();
|
|
823
|
+
}
|
|
824
|
+
};
|
|
825
|
+
module2.exports = Events2;
|
|
826
|
+
}
|
|
827
|
+
});
|
|
828
|
+
|
|
829
|
+
// ../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/Queues.js
|
|
830
|
+
var require_Queues = __commonJS({
|
|
831
|
+
"../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/Queues.js"(exports2, module2) {
|
|
832
|
+
"use strict";
|
|
833
|
+
init_cjs_shims();
|
|
834
|
+
var DLList;
|
|
835
|
+
var Events2;
|
|
836
|
+
var Queues;
|
|
837
|
+
DLList = require_DLList();
|
|
838
|
+
Events2 = require_Events();
|
|
839
|
+
Queues = class Queues {
|
|
840
|
+
constructor(num_priorities) {
|
|
841
|
+
var i;
|
|
842
|
+
this.Events = new Events2(this);
|
|
843
|
+
this._length = 0;
|
|
844
|
+
this._lists = function() {
|
|
845
|
+
var j, ref, results;
|
|
846
|
+
results = [];
|
|
847
|
+
for (i = j = 1, ref = num_priorities; 1 <= ref ? j <= ref : j >= ref; i = 1 <= ref ? ++j : --j) {
|
|
848
|
+
results.push(new DLList(() => {
|
|
849
|
+
return this.incr();
|
|
850
|
+
}, () => {
|
|
851
|
+
return this.decr();
|
|
852
|
+
}));
|
|
853
|
+
}
|
|
854
|
+
return results;
|
|
855
|
+
}.call(this);
|
|
856
|
+
}
|
|
857
|
+
incr() {
|
|
858
|
+
if (this._length++ === 0) {
|
|
859
|
+
return this.Events.trigger("leftzero");
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
decr() {
|
|
863
|
+
if (--this._length === 0) {
|
|
864
|
+
return this.Events.trigger("zero");
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
push(job) {
|
|
868
|
+
return this._lists[job.options.priority].push(job);
|
|
869
|
+
}
|
|
870
|
+
queued(priority) {
|
|
871
|
+
if (priority != null) {
|
|
872
|
+
return this._lists[priority].length;
|
|
873
|
+
} else {
|
|
874
|
+
return this._length;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
shiftAll(fn) {
|
|
878
|
+
return this._lists.forEach(function(list) {
|
|
879
|
+
return list.forEachShift(fn);
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
getFirst(arr = this._lists) {
|
|
883
|
+
var j, len, list;
|
|
884
|
+
for (j = 0, len = arr.length; j < len; j++) {
|
|
885
|
+
list = arr[j];
|
|
886
|
+
if (list.length > 0) {
|
|
887
|
+
return list;
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
return [];
|
|
891
|
+
}
|
|
892
|
+
shiftLastFrom(priority) {
|
|
893
|
+
return this.getFirst(this._lists.slice(priority).reverse()).shift();
|
|
894
|
+
}
|
|
895
|
+
};
|
|
896
|
+
module2.exports = Queues;
|
|
897
|
+
}
|
|
898
|
+
});
|
|
899
|
+
|
|
900
|
+
// ../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/BottleneckError.js
|
|
901
|
+
var require_BottleneckError = __commonJS({
|
|
902
|
+
"../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/BottleneckError.js"(exports2, module2) {
|
|
903
|
+
"use strict";
|
|
904
|
+
init_cjs_shims();
|
|
905
|
+
var BottleneckError;
|
|
906
|
+
BottleneckError = class BottleneckError extends Error {
|
|
907
|
+
};
|
|
908
|
+
module2.exports = BottleneckError;
|
|
909
|
+
}
|
|
910
|
+
});
|
|
911
|
+
|
|
912
|
+
// ../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/Job.js
|
|
913
|
+
var require_Job = __commonJS({
|
|
914
|
+
"../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/Job.js"(exports2, module2) {
|
|
915
|
+
"use strict";
|
|
916
|
+
init_cjs_shims();
|
|
917
|
+
function asyncGeneratorStep2(gen, resolve, reject, _next, _throw, key, arg) {
|
|
918
|
+
try {
|
|
919
|
+
var info = gen[key](arg);
|
|
920
|
+
var value = info.value;
|
|
921
|
+
} catch (error) {
|
|
922
|
+
reject(error);
|
|
923
|
+
return;
|
|
924
|
+
}
|
|
925
|
+
if (info.done) {
|
|
926
|
+
resolve(value);
|
|
927
|
+
} else {
|
|
928
|
+
Promise.resolve(value).then(_next, _throw);
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
function _asyncToGenerator2(fn) {
|
|
932
|
+
return function() {
|
|
933
|
+
var self = this, args = arguments;
|
|
934
|
+
return new Promise(function(resolve, reject) {
|
|
935
|
+
var gen = fn.apply(self, args);
|
|
936
|
+
function _next(value) {
|
|
937
|
+
asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "next", value);
|
|
938
|
+
}
|
|
939
|
+
function _throw(err) {
|
|
940
|
+
asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "throw", err);
|
|
941
|
+
}
|
|
942
|
+
_next(void 0);
|
|
943
|
+
});
|
|
944
|
+
};
|
|
945
|
+
}
|
|
946
|
+
var BottleneckError;
|
|
947
|
+
var DEFAULT_PRIORITY;
|
|
948
|
+
var Job;
|
|
949
|
+
var NUM_PRIORITIES;
|
|
950
|
+
var parser2;
|
|
951
|
+
NUM_PRIORITIES = 10;
|
|
952
|
+
DEFAULT_PRIORITY = 5;
|
|
953
|
+
parser2 = require_parser();
|
|
954
|
+
BottleneckError = require_BottleneckError();
|
|
955
|
+
Job = class Job {
|
|
956
|
+
constructor(task, args, options2, jobDefaults, rejectOnDrop, Events2, _states, Promise2) {
|
|
957
|
+
this.task = task;
|
|
958
|
+
this.args = args;
|
|
959
|
+
this.rejectOnDrop = rejectOnDrop;
|
|
960
|
+
this.Events = Events2;
|
|
961
|
+
this._states = _states;
|
|
962
|
+
this.Promise = Promise2;
|
|
963
|
+
this.options = parser2.load(options2, jobDefaults);
|
|
964
|
+
this.options.priority = this._sanitizePriority(this.options.priority);
|
|
965
|
+
if (this.options.id === jobDefaults.id) {
|
|
966
|
+
this.options.id = `${this.options.id}-${this._randomIndex()}`;
|
|
967
|
+
}
|
|
968
|
+
this.promise = new this.Promise((_resolve, _reject) => {
|
|
969
|
+
this._resolve = _resolve;
|
|
970
|
+
this._reject = _reject;
|
|
971
|
+
});
|
|
972
|
+
this.retryCount = 0;
|
|
973
|
+
}
|
|
974
|
+
_sanitizePriority(priority) {
|
|
975
|
+
var sProperty;
|
|
976
|
+
sProperty = ~~priority !== priority ? DEFAULT_PRIORITY : priority;
|
|
977
|
+
if (sProperty < 0) {
|
|
978
|
+
return 0;
|
|
979
|
+
} else if (sProperty > NUM_PRIORITIES - 1) {
|
|
980
|
+
return NUM_PRIORITIES - 1;
|
|
981
|
+
} else {
|
|
982
|
+
return sProperty;
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
_randomIndex() {
|
|
986
|
+
return Math.random().toString(36).slice(2);
|
|
987
|
+
}
|
|
988
|
+
doDrop({
|
|
989
|
+
error,
|
|
990
|
+
message = "This job has been dropped by Bottleneck"
|
|
991
|
+
} = {}) {
|
|
992
|
+
if (this._states.remove(this.options.id)) {
|
|
993
|
+
if (this.rejectOnDrop) {
|
|
994
|
+
this._reject(error != null ? error : new BottleneckError(message));
|
|
995
|
+
}
|
|
996
|
+
this.Events.trigger("dropped", {
|
|
997
|
+
args: this.args,
|
|
998
|
+
options: this.options,
|
|
999
|
+
task: this.task,
|
|
1000
|
+
promise: this.promise
|
|
1001
|
+
});
|
|
1002
|
+
return true;
|
|
1003
|
+
} else {
|
|
1004
|
+
return false;
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
_assertStatus(expected) {
|
|
1008
|
+
var status;
|
|
1009
|
+
status = this._states.jobStatus(this.options.id);
|
|
1010
|
+
if (!(status === expected || expected === "DONE" && status === null)) {
|
|
1011
|
+
throw new BottleneckError(`Invalid job status ${status}, expected ${expected}. Please open an issue at https://github.com/SGrondin/bottleneck/issues`);
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
doReceive() {
|
|
1015
|
+
this._states.start(this.options.id);
|
|
1016
|
+
return this.Events.trigger("received", {
|
|
1017
|
+
args: this.args,
|
|
1018
|
+
options: this.options
|
|
1019
|
+
});
|
|
1020
|
+
}
|
|
1021
|
+
doQueue(reachedHWM, blocked) {
|
|
1022
|
+
this._assertStatus("RECEIVED");
|
|
1023
|
+
this._states.next(this.options.id);
|
|
1024
|
+
return this.Events.trigger("queued", {
|
|
1025
|
+
args: this.args,
|
|
1026
|
+
options: this.options,
|
|
1027
|
+
reachedHWM,
|
|
1028
|
+
blocked
|
|
1029
|
+
});
|
|
1030
|
+
}
|
|
1031
|
+
doRun() {
|
|
1032
|
+
if (this.retryCount === 0) {
|
|
1033
|
+
this._assertStatus("QUEUED");
|
|
1034
|
+
this._states.next(this.options.id);
|
|
1035
|
+
} else {
|
|
1036
|
+
this._assertStatus("EXECUTING");
|
|
1037
|
+
}
|
|
1038
|
+
return this.Events.trigger("scheduled", {
|
|
1039
|
+
args: this.args,
|
|
1040
|
+
options: this.options
|
|
1041
|
+
});
|
|
1042
|
+
}
|
|
1043
|
+
doExecute(chained, clearGlobalState, run, free) {
|
|
1044
|
+
var _this = this;
|
|
1045
|
+
return _asyncToGenerator2(function* () {
|
|
1046
|
+
var error, eventInfo, passed;
|
|
1047
|
+
if (_this.retryCount === 0) {
|
|
1048
|
+
_this._assertStatus("RUNNING");
|
|
1049
|
+
_this._states.next(_this.options.id);
|
|
1050
|
+
} else {
|
|
1051
|
+
_this._assertStatus("EXECUTING");
|
|
1052
|
+
}
|
|
1053
|
+
eventInfo = {
|
|
1054
|
+
args: _this.args,
|
|
1055
|
+
options: _this.options,
|
|
1056
|
+
retryCount: _this.retryCount
|
|
1057
|
+
};
|
|
1058
|
+
_this.Events.trigger("executing", eventInfo);
|
|
1059
|
+
try {
|
|
1060
|
+
passed = yield chained != null ? chained.schedule(_this.options, _this.task, ..._this.args) : _this.task(..._this.args);
|
|
1061
|
+
if (clearGlobalState()) {
|
|
1062
|
+
_this.doDone(eventInfo);
|
|
1063
|
+
yield free(_this.options, eventInfo);
|
|
1064
|
+
_this._assertStatus("DONE");
|
|
1065
|
+
return _this._resolve(passed);
|
|
1066
|
+
}
|
|
1067
|
+
} catch (error1) {
|
|
1068
|
+
error = error1;
|
|
1069
|
+
return _this._onFailure(error, eventInfo, clearGlobalState, run, free);
|
|
1070
|
+
}
|
|
1071
|
+
})();
|
|
1072
|
+
}
|
|
1073
|
+
doExpire(clearGlobalState, run, free) {
|
|
1074
|
+
var error, eventInfo;
|
|
1075
|
+
if (this._states.jobStatus(this.options.id === "RUNNING")) {
|
|
1076
|
+
this._states.next(this.options.id);
|
|
1077
|
+
}
|
|
1078
|
+
this._assertStatus("EXECUTING");
|
|
1079
|
+
eventInfo = {
|
|
1080
|
+
args: this.args,
|
|
1081
|
+
options: this.options,
|
|
1082
|
+
retryCount: this.retryCount
|
|
1083
|
+
};
|
|
1084
|
+
error = new BottleneckError(`This job timed out after ${this.options.expiration} ms.`);
|
|
1085
|
+
return this._onFailure(error, eventInfo, clearGlobalState, run, free);
|
|
1086
|
+
}
|
|
1087
|
+
_onFailure(error, eventInfo, clearGlobalState, run, free) {
|
|
1088
|
+
var _this2 = this;
|
|
1089
|
+
return _asyncToGenerator2(function* () {
|
|
1090
|
+
var retry, retryAfter;
|
|
1091
|
+
if (clearGlobalState()) {
|
|
1092
|
+
retry = yield _this2.Events.trigger("failed", error, eventInfo);
|
|
1093
|
+
if (retry != null) {
|
|
1094
|
+
retryAfter = ~~retry;
|
|
1095
|
+
_this2.Events.trigger("retry", `Retrying ${_this2.options.id} after ${retryAfter} ms`, eventInfo);
|
|
1096
|
+
_this2.retryCount++;
|
|
1097
|
+
return run(retryAfter);
|
|
1098
|
+
} else {
|
|
1099
|
+
_this2.doDone(eventInfo);
|
|
1100
|
+
yield free(_this2.options, eventInfo);
|
|
1101
|
+
_this2._assertStatus("DONE");
|
|
1102
|
+
return _this2._reject(error);
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
})();
|
|
1106
|
+
}
|
|
1107
|
+
doDone(eventInfo) {
|
|
1108
|
+
this._assertStatus("EXECUTING");
|
|
1109
|
+
this._states.next(this.options.id);
|
|
1110
|
+
return this.Events.trigger("done", eventInfo);
|
|
1111
|
+
}
|
|
1112
|
+
};
|
|
1113
|
+
module2.exports = Job;
|
|
1114
|
+
}
|
|
1115
|
+
});
|
|
1116
|
+
|
|
1117
|
+
// ../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/LocalDatastore.js
|
|
1118
|
+
var require_LocalDatastore = __commonJS({
|
|
1119
|
+
"../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/LocalDatastore.js"(exports2, module2) {
|
|
1120
|
+
"use strict";
|
|
1121
|
+
init_cjs_shims();
|
|
1122
|
+
function asyncGeneratorStep2(gen, resolve, reject, _next, _throw, key, arg) {
|
|
1123
|
+
try {
|
|
1124
|
+
var info = gen[key](arg);
|
|
1125
|
+
var value = info.value;
|
|
1126
|
+
} catch (error) {
|
|
1127
|
+
reject(error);
|
|
1128
|
+
return;
|
|
1129
|
+
}
|
|
1130
|
+
if (info.done) {
|
|
1131
|
+
resolve(value);
|
|
1132
|
+
} else {
|
|
1133
|
+
Promise.resolve(value).then(_next, _throw);
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
function _asyncToGenerator2(fn) {
|
|
1137
|
+
return function() {
|
|
1138
|
+
var self = this, args = arguments;
|
|
1139
|
+
return new Promise(function(resolve, reject) {
|
|
1140
|
+
var gen = fn.apply(self, args);
|
|
1141
|
+
function _next(value) {
|
|
1142
|
+
asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "next", value);
|
|
1143
|
+
}
|
|
1144
|
+
function _throw(err) {
|
|
1145
|
+
asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "throw", err);
|
|
1146
|
+
}
|
|
1147
|
+
_next(void 0);
|
|
1148
|
+
});
|
|
1149
|
+
};
|
|
1150
|
+
}
|
|
1151
|
+
var BottleneckError;
|
|
1152
|
+
var LocalDatastore;
|
|
1153
|
+
var parser2;
|
|
1154
|
+
parser2 = require_parser();
|
|
1155
|
+
BottleneckError = require_BottleneckError();
|
|
1156
|
+
LocalDatastore = class LocalDatastore {
|
|
1157
|
+
constructor(instance, storeOptions, storeInstanceOptions) {
|
|
1158
|
+
this.instance = instance;
|
|
1159
|
+
this.storeOptions = storeOptions;
|
|
1160
|
+
this.clientId = this.instance._randomIndex();
|
|
1161
|
+
parser2.load(storeInstanceOptions, storeInstanceOptions, this);
|
|
1162
|
+
this._nextRequest = this._lastReservoirRefresh = this._lastReservoirIncrease = Date.now();
|
|
1163
|
+
this._running = 0;
|
|
1164
|
+
this._done = 0;
|
|
1165
|
+
this._unblockTime = 0;
|
|
1166
|
+
this.ready = this.Promise.resolve();
|
|
1167
|
+
this.clients = {};
|
|
1168
|
+
this._startHeartbeat();
|
|
1169
|
+
}
|
|
1170
|
+
_startHeartbeat() {
|
|
1171
|
+
var base;
|
|
1172
|
+
if (this.heartbeat == null && (this.storeOptions.reservoirRefreshInterval != null && this.storeOptions.reservoirRefreshAmount != null || this.storeOptions.reservoirIncreaseInterval != null && this.storeOptions.reservoirIncreaseAmount != null)) {
|
|
1173
|
+
return typeof (base = this.heartbeat = setInterval(() => {
|
|
1174
|
+
var amount, incr, maximum, now, reservoir;
|
|
1175
|
+
now = Date.now();
|
|
1176
|
+
if (this.storeOptions.reservoirRefreshInterval != null && now >= this._lastReservoirRefresh + this.storeOptions.reservoirRefreshInterval) {
|
|
1177
|
+
this._lastReservoirRefresh = now;
|
|
1178
|
+
this.storeOptions.reservoir = this.storeOptions.reservoirRefreshAmount;
|
|
1179
|
+
this.instance._drainAll(this.computeCapacity());
|
|
1180
|
+
}
|
|
1181
|
+
if (this.storeOptions.reservoirIncreaseInterval != null && now >= this._lastReservoirIncrease + this.storeOptions.reservoirIncreaseInterval) {
|
|
1182
|
+
var _this$storeOptions = this.storeOptions;
|
|
1183
|
+
amount = _this$storeOptions.reservoirIncreaseAmount;
|
|
1184
|
+
maximum = _this$storeOptions.reservoirIncreaseMaximum;
|
|
1185
|
+
reservoir = _this$storeOptions.reservoir;
|
|
1186
|
+
this._lastReservoirIncrease = now;
|
|
1187
|
+
incr = maximum != null ? Math.min(amount, maximum - reservoir) : amount;
|
|
1188
|
+
if (incr > 0) {
|
|
1189
|
+
this.storeOptions.reservoir += incr;
|
|
1190
|
+
return this.instance._drainAll(this.computeCapacity());
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
}, this.heartbeatInterval)).unref === "function" ? base.unref() : void 0;
|
|
1194
|
+
} else {
|
|
1195
|
+
return clearInterval(this.heartbeat);
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
__publish__(message) {
|
|
1199
|
+
var _this = this;
|
|
1200
|
+
return _asyncToGenerator2(function* () {
|
|
1201
|
+
yield _this.yieldLoop();
|
|
1202
|
+
return _this.instance.Events.trigger("message", message.toString());
|
|
1203
|
+
})();
|
|
1204
|
+
}
|
|
1205
|
+
__disconnect__(flush) {
|
|
1206
|
+
var _this2 = this;
|
|
1207
|
+
return _asyncToGenerator2(function* () {
|
|
1208
|
+
yield _this2.yieldLoop();
|
|
1209
|
+
clearInterval(_this2.heartbeat);
|
|
1210
|
+
return _this2.Promise.resolve();
|
|
1211
|
+
})();
|
|
1212
|
+
}
|
|
1213
|
+
yieldLoop(t = 0) {
|
|
1214
|
+
return new this.Promise(function(resolve, reject) {
|
|
1215
|
+
return setTimeout(resolve, t);
|
|
1216
|
+
});
|
|
1217
|
+
}
|
|
1218
|
+
computePenalty() {
|
|
1219
|
+
var ref;
|
|
1220
|
+
return (ref = this.storeOptions.penalty) != null ? ref : 15 * this.storeOptions.minTime || 5e3;
|
|
1221
|
+
}
|
|
1222
|
+
__updateSettings__(options2) {
|
|
1223
|
+
var _this3 = this;
|
|
1224
|
+
return _asyncToGenerator2(function* () {
|
|
1225
|
+
yield _this3.yieldLoop();
|
|
1226
|
+
parser2.overwrite(options2, options2, _this3.storeOptions);
|
|
1227
|
+
_this3._startHeartbeat();
|
|
1228
|
+
_this3.instance._drainAll(_this3.computeCapacity());
|
|
1229
|
+
return true;
|
|
1230
|
+
})();
|
|
1231
|
+
}
|
|
1232
|
+
__running__() {
|
|
1233
|
+
var _this4 = this;
|
|
1234
|
+
return _asyncToGenerator2(function* () {
|
|
1235
|
+
yield _this4.yieldLoop();
|
|
1236
|
+
return _this4._running;
|
|
1237
|
+
})();
|
|
1238
|
+
}
|
|
1239
|
+
__queued__() {
|
|
1240
|
+
var _this5 = this;
|
|
1241
|
+
return _asyncToGenerator2(function* () {
|
|
1242
|
+
yield _this5.yieldLoop();
|
|
1243
|
+
return _this5.instance.queued();
|
|
1244
|
+
})();
|
|
1245
|
+
}
|
|
1246
|
+
__done__() {
|
|
1247
|
+
var _this6 = this;
|
|
1248
|
+
return _asyncToGenerator2(function* () {
|
|
1249
|
+
yield _this6.yieldLoop();
|
|
1250
|
+
return _this6._done;
|
|
1251
|
+
})();
|
|
1252
|
+
}
|
|
1253
|
+
__groupCheck__(time) {
|
|
1254
|
+
var _this7 = this;
|
|
1255
|
+
return _asyncToGenerator2(function* () {
|
|
1256
|
+
yield _this7.yieldLoop();
|
|
1257
|
+
return _this7._nextRequest + _this7.timeout < time;
|
|
1258
|
+
})();
|
|
1259
|
+
}
|
|
1260
|
+
computeCapacity() {
|
|
1261
|
+
var maxConcurrent, reservoir;
|
|
1262
|
+
var _this$storeOptions2 = this.storeOptions;
|
|
1263
|
+
maxConcurrent = _this$storeOptions2.maxConcurrent;
|
|
1264
|
+
reservoir = _this$storeOptions2.reservoir;
|
|
1265
|
+
if (maxConcurrent != null && reservoir != null) {
|
|
1266
|
+
return Math.min(maxConcurrent - this._running, reservoir);
|
|
1267
|
+
} else if (maxConcurrent != null) {
|
|
1268
|
+
return maxConcurrent - this._running;
|
|
1269
|
+
} else if (reservoir != null) {
|
|
1270
|
+
return reservoir;
|
|
1271
|
+
} else {
|
|
1272
|
+
return null;
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
conditionsCheck(weight) {
|
|
1276
|
+
var capacity;
|
|
1277
|
+
capacity = this.computeCapacity();
|
|
1278
|
+
return capacity == null || weight <= capacity;
|
|
1279
|
+
}
|
|
1280
|
+
__incrementReservoir__(incr) {
|
|
1281
|
+
var _this8 = this;
|
|
1282
|
+
return _asyncToGenerator2(function* () {
|
|
1283
|
+
var reservoir;
|
|
1284
|
+
yield _this8.yieldLoop();
|
|
1285
|
+
reservoir = _this8.storeOptions.reservoir += incr;
|
|
1286
|
+
_this8.instance._drainAll(_this8.computeCapacity());
|
|
1287
|
+
return reservoir;
|
|
1288
|
+
})();
|
|
1289
|
+
}
|
|
1290
|
+
__currentReservoir__() {
|
|
1291
|
+
var _this9 = this;
|
|
1292
|
+
return _asyncToGenerator2(function* () {
|
|
1293
|
+
yield _this9.yieldLoop();
|
|
1294
|
+
return _this9.storeOptions.reservoir;
|
|
1295
|
+
})();
|
|
1296
|
+
}
|
|
1297
|
+
isBlocked(now) {
|
|
1298
|
+
return this._unblockTime >= now;
|
|
1299
|
+
}
|
|
1300
|
+
check(weight, now) {
|
|
1301
|
+
return this.conditionsCheck(weight) && this._nextRequest - now <= 0;
|
|
1302
|
+
}
|
|
1303
|
+
__check__(weight) {
|
|
1304
|
+
var _this10 = this;
|
|
1305
|
+
return _asyncToGenerator2(function* () {
|
|
1306
|
+
var now;
|
|
1307
|
+
yield _this10.yieldLoop();
|
|
1308
|
+
now = Date.now();
|
|
1309
|
+
return _this10.check(weight, now);
|
|
1310
|
+
})();
|
|
1311
|
+
}
|
|
1312
|
+
__register__(index, weight, expiration) {
|
|
1313
|
+
var _this11 = this;
|
|
1314
|
+
return _asyncToGenerator2(function* () {
|
|
1315
|
+
var now, wait;
|
|
1316
|
+
yield _this11.yieldLoop();
|
|
1317
|
+
now = Date.now();
|
|
1318
|
+
if (_this11.conditionsCheck(weight)) {
|
|
1319
|
+
_this11._running += weight;
|
|
1320
|
+
if (_this11.storeOptions.reservoir != null) {
|
|
1321
|
+
_this11.storeOptions.reservoir -= weight;
|
|
1322
|
+
}
|
|
1323
|
+
wait = Math.max(_this11._nextRequest - now, 0);
|
|
1324
|
+
_this11._nextRequest = now + wait + _this11.storeOptions.minTime;
|
|
1325
|
+
return {
|
|
1326
|
+
success: true,
|
|
1327
|
+
wait,
|
|
1328
|
+
reservoir: _this11.storeOptions.reservoir
|
|
1329
|
+
};
|
|
1330
|
+
} else {
|
|
1331
|
+
return {
|
|
1332
|
+
success: false
|
|
1333
|
+
};
|
|
1334
|
+
}
|
|
1335
|
+
})();
|
|
1336
|
+
}
|
|
1337
|
+
strategyIsBlock() {
|
|
1338
|
+
return this.storeOptions.strategy === 3;
|
|
1339
|
+
}
|
|
1340
|
+
__submit__(queueLength, weight) {
|
|
1341
|
+
var _this12 = this;
|
|
1342
|
+
return _asyncToGenerator2(function* () {
|
|
1343
|
+
var blocked, now, reachedHWM;
|
|
1344
|
+
yield _this12.yieldLoop();
|
|
1345
|
+
if (_this12.storeOptions.maxConcurrent != null && weight > _this12.storeOptions.maxConcurrent) {
|
|
1346
|
+
throw new BottleneckError(`Impossible to add a job having a weight of ${weight} to a limiter having a maxConcurrent setting of ${_this12.storeOptions.maxConcurrent}`);
|
|
1347
|
+
}
|
|
1348
|
+
now = Date.now();
|
|
1349
|
+
reachedHWM = _this12.storeOptions.highWater != null && queueLength === _this12.storeOptions.highWater && !_this12.check(weight, now);
|
|
1350
|
+
blocked = _this12.strategyIsBlock() && (reachedHWM || _this12.isBlocked(now));
|
|
1351
|
+
if (blocked) {
|
|
1352
|
+
_this12._unblockTime = now + _this12.computePenalty();
|
|
1353
|
+
_this12._nextRequest = _this12._unblockTime + _this12.storeOptions.minTime;
|
|
1354
|
+
_this12.instance._dropAllQueued();
|
|
1355
|
+
}
|
|
1356
|
+
return {
|
|
1357
|
+
reachedHWM,
|
|
1358
|
+
blocked,
|
|
1359
|
+
strategy: _this12.storeOptions.strategy
|
|
1360
|
+
};
|
|
1361
|
+
})();
|
|
1362
|
+
}
|
|
1363
|
+
__free__(index, weight) {
|
|
1364
|
+
var _this13 = this;
|
|
1365
|
+
return _asyncToGenerator2(function* () {
|
|
1366
|
+
yield _this13.yieldLoop();
|
|
1367
|
+
_this13._running -= weight;
|
|
1368
|
+
_this13._done += weight;
|
|
1369
|
+
_this13.instance._drainAll(_this13.computeCapacity());
|
|
1370
|
+
return {
|
|
1371
|
+
running: _this13._running
|
|
1372
|
+
};
|
|
1373
|
+
})();
|
|
1374
|
+
}
|
|
1375
|
+
};
|
|
1376
|
+
module2.exports = LocalDatastore;
|
|
1377
|
+
}
|
|
1378
|
+
});
|
|
1379
|
+
|
|
1380
|
+
// ../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/lua.json
|
|
1381
|
+
var require_lua = __commonJS({
|
|
1382
|
+
"../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/lua.json"(exports2, module2) {
|
|
1383
|
+
module2.exports = {
|
|
1384
|
+
"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",
|
|
1385
|
+
"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",
|
|
1386
|
+
"conditions_check.lua": "local conditions_check = function (capacity, weight)\n return capacity == nil or weight <= capacity\nend\n",
|
|
1387
|
+
"current_reservoir.lua": "return process_tick(now, false)['reservoir']\n",
|
|
1388
|
+
"done.lua": "process_tick(now, false)\n\nreturn tonumber(redis.call('hget', settings_key, 'done'))\n",
|
|
1389
|
+
"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",
|
|
1390
|
+
"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",
|
|
1391
|
+
"group_check.lua": "return not (redis.call('exists', settings_key) == 1)\n",
|
|
1392
|
+
"heartbeat.lua": "process_tick(now, true)\n",
|
|
1393
|
+
"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",
|
|
1394
|
+
"init.lua": `local clear = tonumber(ARGV[num_static_argv + 1])
|
|
1395
|
+
local limiter_version = ARGV[num_static_argv + 2]
|
|
1396
|
+
local num_local_argv = num_static_argv + 2
|
|
1397
|
+
|
|
1398
|
+
if clear == 1 then
|
|
1399
|
+
redis.call('del', unpack(KEYS))
|
|
1400
|
+
end
|
|
1401
|
+
|
|
1402
|
+
if redis.call('exists', settings_key) == 0 then
|
|
1403
|
+
-- Create
|
|
1404
|
+
local args = {'hmset', settings_key}
|
|
1405
|
+
|
|
1406
|
+
for i = num_local_argv + 1, #ARGV do
|
|
1407
|
+
table.insert(args, ARGV[i])
|
|
1408
|
+
end
|
|
1409
|
+
|
|
1410
|
+
redis.call(unpack(args))
|
|
1411
|
+
redis.call('hmset', settings_key,
|
|
1412
|
+
'nextRequest', now,
|
|
1413
|
+
'lastReservoirRefresh', now,
|
|
1414
|
+
'lastReservoirIncrease', now,
|
|
1415
|
+
'running', 0,
|
|
1416
|
+
'done', 0,
|
|
1417
|
+
'unblockTime', 0,
|
|
1418
|
+
'capacityPriorityCounter', 0
|
|
1419
|
+
)
|
|
1420
|
+
|
|
1421
|
+
else
|
|
1422
|
+
-- Apply migrations
|
|
1423
|
+
local settings = redis.call('hmget', settings_key,
|
|
1424
|
+
'id',
|
|
1425
|
+
'version'
|
|
1426
|
+
)
|
|
1427
|
+
local id = settings[1]
|
|
1428
|
+
local current_version = settings[2]
|
|
1429
|
+
|
|
1430
|
+
if current_version ~= limiter_version then
|
|
1431
|
+
local version_digits = {}
|
|
1432
|
+
for k, v in string.gmatch(current_version, "([^.]+)") do
|
|
1433
|
+
table.insert(version_digits, tonumber(k))
|
|
1434
|
+
end
|
|
1435
|
+
|
|
1436
|
+
-- 2.10.0
|
|
1437
|
+
if version_digits[2] < 10 then
|
|
1438
|
+
redis.call('hsetnx', settings_key, 'reservoirRefreshInterval', '')
|
|
1439
|
+
redis.call('hsetnx', settings_key, 'reservoirRefreshAmount', '')
|
|
1440
|
+
redis.call('hsetnx', settings_key, 'lastReservoirRefresh', '')
|
|
1441
|
+
redis.call('hsetnx', settings_key, 'done', 0)
|
|
1442
|
+
redis.call('hset', settings_key, 'version', '2.10.0')
|
|
1443
|
+
end
|
|
1444
|
+
|
|
1445
|
+
-- 2.11.1
|
|
1446
|
+
if version_digits[2] < 11 or (version_digits[2] == 11 and version_digits[3] < 1) then
|
|
1447
|
+
if redis.call('hstrlen', settings_key, 'lastReservoirRefresh') == 0 then
|
|
1448
|
+
redis.call('hmset', settings_key,
|
|
1449
|
+
'lastReservoirRefresh', now,
|
|
1450
|
+
'version', '2.11.1'
|
|
1451
|
+
)
|
|
1452
|
+
end
|
|
1453
|
+
end
|
|
1454
|
+
|
|
1455
|
+
-- 2.14.0
|
|
1456
|
+
if version_digits[2] < 14 then
|
|
1457
|
+
local old_running_key = 'b_'..id..'_running'
|
|
1458
|
+
local old_executing_key = 'b_'..id..'_executing'
|
|
1459
|
+
|
|
1460
|
+
if redis.call('exists', old_running_key) == 1 then
|
|
1461
|
+
redis.call('rename', old_running_key, job_weights_key)
|
|
1462
|
+
end
|
|
1463
|
+
if redis.call('exists', old_executing_key) == 1 then
|
|
1464
|
+
redis.call('rename', old_executing_key, job_expirations_key)
|
|
1465
|
+
end
|
|
1466
|
+
redis.call('hset', settings_key, 'version', '2.14.0')
|
|
1467
|
+
end
|
|
1468
|
+
|
|
1469
|
+
-- 2.15.2
|
|
1470
|
+
if version_digits[2] < 15 or (version_digits[2] == 15 and version_digits[3] < 2) then
|
|
1471
|
+
redis.call('hsetnx', settings_key, 'capacityPriorityCounter', 0)
|
|
1472
|
+
redis.call('hset', settings_key, 'version', '2.15.2')
|
|
1473
|
+
end
|
|
1474
|
+
|
|
1475
|
+
-- 2.17.0
|
|
1476
|
+
if version_digits[2] < 17 then
|
|
1477
|
+
redis.call('hsetnx', settings_key, 'clientTimeout', 10000)
|
|
1478
|
+
redis.call('hset', settings_key, 'version', '2.17.0')
|
|
1479
|
+
end
|
|
1480
|
+
|
|
1481
|
+
-- 2.18.0
|
|
1482
|
+
if version_digits[2] < 18 then
|
|
1483
|
+
redis.call('hsetnx', settings_key, 'reservoirIncreaseInterval', '')
|
|
1484
|
+
redis.call('hsetnx', settings_key, 'reservoirIncreaseAmount', '')
|
|
1485
|
+
redis.call('hsetnx', settings_key, 'reservoirIncreaseMaximum', '')
|
|
1486
|
+
redis.call('hsetnx', settings_key, 'lastReservoirIncrease', now)
|
|
1487
|
+
redis.call('hset', settings_key, 'version', '2.18.0')
|
|
1488
|
+
end
|
|
1489
|
+
|
|
1490
|
+
end
|
|
1491
|
+
|
|
1492
|
+
process_tick(now, false)
|
|
1493
|
+
end
|
|
1494
|
+
|
|
1495
|
+
local groupTimeout = tonumber(redis.call('hget', settings_key, 'groupTimeout'))
|
|
1496
|
+
refresh_expiration(0, 0, groupTimeout)
|
|
1497
|
+
|
|
1498
|
+
return {}
|
|
1499
|
+
`,
|
|
1500
|
+
"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",
|
|
1501
|
+
"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",
|
|
1502
|
+
"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",
|
|
1503
|
+
"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",
|
|
1504
|
+
"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",
|
|
1505
|
+
"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",
|
|
1506
|
+
"running.lua": "return process_tick(now, false)['running']\n",
|
|
1507
|
+
"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",
|
|
1508
|
+
"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",
|
|
1509
|
+
"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",
|
|
1510
|
+
"validate_keys.lua": "if not (redis.call('exists', settings_key) == 1) then\n return redis.error_reply('SETTINGS_KEY_NOT_FOUND')\nend\n"
|
|
1511
|
+
};
|
|
1512
|
+
}
|
|
1513
|
+
});
|
|
1514
|
+
|
|
1515
|
+
// ../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/Scripts.js
|
|
1516
|
+
var require_Scripts = __commonJS({
|
|
1517
|
+
"../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/Scripts.js"(exports2) {
|
|
1518
|
+
"use strict";
|
|
1519
|
+
init_cjs_shims();
|
|
1520
|
+
var headers;
|
|
1521
|
+
var lua;
|
|
1522
|
+
var templates;
|
|
1523
|
+
lua = require_lua();
|
|
1524
|
+
headers = {
|
|
1525
|
+
refs: lua["refs.lua"],
|
|
1526
|
+
validate_keys: lua["validate_keys.lua"],
|
|
1527
|
+
validate_client: lua["validate_client.lua"],
|
|
1528
|
+
refresh_expiration: lua["refresh_expiration.lua"],
|
|
1529
|
+
process_tick: lua["process_tick.lua"],
|
|
1530
|
+
conditions_check: lua["conditions_check.lua"],
|
|
1531
|
+
get_time: lua["get_time.lua"]
|
|
1532
|
+
};
|
|
1533
|
+
exports2.allKeys = function(id) {
|
|
1534
|
+
return [
|
|
1535
|
+
/*
|
|
1536
|
+
HASH
|
|
1537
|
+
*/
|
|
1538
|
+
`b_${id}_settings`,
|
|
1539
|
+
/*
|
|
1540
|
+
HASH
|
|
1541
|
+
job index -> weight
|
|
1542
|
+
*/
|
|
1543
|
+
`b_${id}_job_weights`,
|
|
1544
|
+
/*
|
|
1545
|
+
ZSET
|
|
1546
|
+
job index -> expiration
|
|
1547
|
+
*/
|
|
1548
|
+
`b_${id}_job_expirations`,
|
|
1549
|
+
/*
|
|
1550
|
+
HASH
|
|
1551
|
+
job index -> client
|
|
1552
|
+
*/
|
|
1553
|
+
`b_${id}_job_clients`,
|
|
1554
|
+
/*
|
|
1555
|
+
ZSET
|
|
1556
|
+
client -> sum running
|
|
1557
|
+
*/
|
|
1558
|
+
`b_${id}_client_running`,
|
|
1559
|
+
/*
|
|
1560
|
+
HASH
|
|
1561
|
+
client -> num queued
|
|
1562
|
+
*/
|
|
1563
|
+
`b_${id}_client_num_queued`,
|
|
1564
|
+
/*
|
|
1565
|
+
ZSET
|
|
1566
|
+
client -> last job registered
|
|
1567
|
+
*/
|
|
1568
|
+
`b_${id}_client_last_registered`,
|
|
1569
|
+
/*
|
|
1570
|
+
ZSET
|
|
1571
|
+
client -> last seen
|
|
1572
|
+
*/
|
|
1573
|
+
`b_${id}_client_last_seen`
|
|
1574
|
+
];
|
|
1575
|
+
};
|
|
1576
|
+
templates = {
|
|
1577
|
+
init: {
|
|
1578
|
+
keys: exports2.allKeys,
|
|
1579
|
+
headers: ["process_tick"],
|
|
1580
|
+
refresh_expiration: true,
|
|
1581
|
+
code: lua["init.lua"]
|
|
1582
|
+
},
|
|
1583
|
+
group_check: {
|
|
1584
|
+
keys: exports2.allKeys,
|
|
1585
|
+
headers: [],
|
|
1586
|
+
refresh_expiration: false,
|
|
1587
|
+
code: lua["group_check.lua"]
|
|
1588
|
+
},
|
|
1589
|
+
register_client: {
|
|
1590
|
+
keys: exports2.allKeys,
|
|
1591
|
+
headers: ["validate_keys"],
|
|
1592
|
+
refresh_expiration: false,
|
|
1593
|
+
code: lua["register_client.lua"]
|
|
1594
|
+
},
|
|
1595
|
+
blacklist_client: {
|
|
1596
|
+
keys: exports2.allKeys,
|
|
1597
|
+
headers: ["validate_keys", "validate_client"],
|
|
1598
|
+
refresh_expiration: false,
|
|
1599
|
+
code: lua["blacklist_client.lua"]
|
|
1600
|
+
},
|
|
1601
|
+
heartbeat: {
|
|
1602
|
+
keys: exports2.allKeys,
|
|
1603
|
+
headers: ["validate_keys", "validate_client", "process_tick"],
|
|
1604
|
+
refresh_expiration: false,
|
|
1605
|
+
code: lua["heartbeat.lua"]
|
|
1606
|
+
},
|
|
1607
|
+
update_settings: {
|
|
1608
|
+
keys: exports2.allKeys,
|
|
1609
|
+
headers: ["validate_keys", "validate_client", "process_tick"],
|
|
1610
|
+
refresh_expiration: true,
|
|
1611
|
+
code: lua["update_settings.lua"]
|
|
1612
|
+
},
|
|
1613
|
+
running: {
|
|
1614
|
+
keys: exports2.allKeys,
|
|
1615
|
+
headers: ["validate_keys", "validate_client", "process_tick"],
|
|
1616
|
+
refresh_expiration: false,
|
|
1617
|
+
code: lua["running.lua"]
|
|
1618
|
+
},
|
|
1619
|
+
queued: {
|
|
1620
|
+
keys: exports2.allKeys,
|
|
1621
|
+
headers: ["validate_keys", "validate_client"],
|
|
1622
|
+
refresh_expiration: false,
|
|
1623
|
+
code: lua["queued.lua"]
|
|
1624
|
+
},
|
|
1625
|
+
done: {
|
|
1626
|
+
keys: exports2.allKeys,
|
|
1627
|
+
headers: ["validate_keys", "validate_client", "process_tick"],
|
|
1628
|
+
refresh_expiration: false,
|
|
1629
|
+
code: lua["done.lua"]
|
|
1630
|
+
},
|
|
1631
|
+
check: {
|
|
1632
|
+
keys: exports2.allKeys,
|
|
1633
|
+
headers: ["validate_keys", "validate_client", "process_tick", "conditions_check"],
|
|
1634
|
+
refresh_expiration: false,
|
|
1635
|
+
code: lua["check.lua"]
|
|
1636
|
+
},
|
|
1637
|
+
submit: {
|
|
1638
|
+
keys: exports2.allKeys,
|
|
1639
|
+
headers: ["validate_keys", "validate_client", "process_tick", "conditions_check"],
|
|
1640
|
+
refresh_expiration: true,
|
|
1641
|
+
code: lua["submit.lua"]
|
|
1642
|
+
},
|
|
1643
|
+
register: {
|
|
1644
|
+
keys: exports2.allKeys,
|
|
1645
|
+
headers: ["validate_keys", "validate_client", "process_tick", "conditions_check"],
|
|
1646
|
+
refresh_expiration: true,
|
|
1647
|
+
code: lua["register.lua"]
|
|
1648
|
+
},
|
|
1649
|
+
free: {
|
|
1650
|
+
keys: exports2.allKeys,
|
|
1651
|
+
headers: ["validate_keys", "validate_client", "process_tick"],
|
|
1652
|
+
refresh_expiration: true,
|
|
1653
|
+
code: lua["free.lua"]
|
|
1654
|
+
},
|
|
1655
|
+
current_reservoir: {
|
|
1656
|
+
keys: exports2.allKeys,
|
|
1657
|
+
headers: ["validate_keys", "validate_client", "process_tick"],
|
|
1658
|
+
refresh_expiration: false,
|
|
1659
|
+
code: lua["current_reservoir.lua"]
|
|
1660
|
+
},
|
|
1661
|
+
increment_reservoir: {
|
|
1662
|
+
keys: exports2.allKeys,
|
|
1663
|
+
headers: ["validate_keys", "validate_client", "process_tick"],
|
|
1664
|
+
refresh_expiration: true,
|
|
1665
|
+
code: lua["increment_reservoir.lua"]
|
|
1666
|
+
}
|
|
1667
|
+
};
|
|
1668
|
+
exports2.names = Object.keys(templates);
|
|
1669
|
+
exports2.keys = function(name, id) {
|
|
1670
|
+
return templates[name].keys(id);
|
|
1671
|
+
};
|
|
1672
|
+
exports2.payload = function(name) {
|
|
1673
|
+
var template;
|
|
1674
|
+
template = templates[name];
|
|
1675
|
+
return Array.prototype.concat(headers.refs, template.headers.map(function(h) {
|
|
1676
|
+
return headers[h];
|
|
1677
|
+
}), template.refresh_expiration ? headers.refresh_expiration : "", template.code).join("\n");
|
|
1678
|
+
};
|
|
1679
|
+
}
|
|
1680
|
+
});
|
|
1681
|
+
|
|
1682
|
+
// ../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/RedisConnection.js
|
|
1683
|
+
var require_RedisConnection = __commonJS({
|
|
1684
|
+
"../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/RedisConnection.js"(exports, module) {
|
|
1685
|
+
"use strict";
|
|
1686
|
+
init_cjs_shims();
|
|
1687
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
1688
|
+
try {
|
|
1689
|
+
var info = gen[key](arg);
|
|
1690
|
+
var value = info.value;
|
|
1691
|
+
} catch (error) {
|
|
1692
|
+
reject(error);
|
|
1693
|
+
return;
|
|
1694
|
+
}
|
|
1695
|
+
if (info.done) {
|
|
1696
|
+
resolve(value);
|
|
1697
|
+
} else {
|
|
1698
|
+
Promise.resolve(value).then(_next, _throw);
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
function _asyncToGenerator(fn) {
|
|
1702
|
+
return function() {
|
|
1703
|
+
var self = this, args = arguments;
|
|
1704
|
+
return new Promise(function(resolve, reject) {
|
|
1705
|
+
var gen = fn.apply(self, args);
|
|
1706
|
+
function _next(value) {
|
|
1707
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
1708
|
+
}
|
|
1709
|
+
function _throw(err) {
|
|
1710
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
1711
|
+
}
|
|
1712
|
+
_next(void 0);
|
|
1713
|
+
});
|
|
1714
|
+
};
|
|
1715
|
+
}
|
|
1716
|
+
var Events;
|
|
1717
|
+
var RedisConnection;
|
|
1718
|
+
var Scripts;
|
|
1719
|
+
var parser;
|
|
1720
|
+
parser = require_parser();
|
|
1721
|
+
Events = require_Events();
|
|
1722
|
+
Scripts = require_Scripts();
|
|
1723
|
+
RedisConnection = function() {
|
|
1724
|
+
class RedisConnection {
|
|
1725
|
+
constructor(options = {}) {
|
|
1726
|
+
parser.load(options, this.defaults, this);
|
|
1727
|
+
if (this.Redis == null) {
|
|
1728
|
+
this.Redis = eval("require")("redis");
|
|
1729
|
+
}
|
|
1730
|
+
if (this.Events == null) {
|
|
1731
|
+
this.Events = new Events(this);
|
|
1732
|
+
}
|
|
1733
|
+
this.terminated = false;
|
|
1734
|
+
if (this.client == null) {
|
|
1735
|
+
this.client = this.Redis.createClient(this.clientOptions);
|
|
1736
|
+
}
|
|
1737
|
+
this.subscriber = this.client.duplicate();
|
|
1738
|
+
this.limiters = {};
|
|
1739
|
+
this.shas = {};
|
|
1740
|
+
this.ready = this.Promise.all([this._setup(this.client, false), this._setup(this.subscriber, true)]).then(() => {
|
|
1741
|
+
return this._loadScripts();
|
|
1742
|
+
}).then(() => {
|
|
1743
|
+
return {
|
|
1744
|
+
client: this.client,
|
|
1745
|
+
subscriber: this.subscriber
|
|
1746
|
+
};
|
|
1747
|
+
});
|
|
1748
|
+
}
|
|
1749
|
+
_setup(client, sub) {
|
|
1750
|
+
client.setMaxListeners(0);
|
|
1751
|
+
return new this.Promise((resolve, reject) => {
|
|
1752
|
+
client.on("error", (e) => {
|
|
1753
|
+
return this.Events.trigger("error", e);
|
|
1754
|
+
});
|
|
1755
|
+
if (sub) {
|
|
1756
|
+
client.on("message", (channel, message) => {
|
|
1757
|
+
var ref;
|
|
1758
|
+
return (ref = this.limiters[channel]) != null ? ref._store.onMessage(channel, message) : void 0;
|
|
1759
|
+
});
|
|
1760
|
+
}
|
|
1761
|
+
if (client.ready) {
|
|
1762
|
+
return resolve();
|
|
1763
|
+
} else {
|
|
1764
|
+
return client.once("ready", resolve);
|
|
1765
|
+
}
|
|
1766
|
+
});
|
|
1767
|
+
}
|
|
1768
|
+
_loadScript(name) {
|
|
1769
|
+
return new this.Promise((resolve, reject) => {
|
|
1770
|
+
var payload;
|
|
1771
|
+
payload = Scripts.payload(name);
|
|
1772
|
+
return this.client.multi([["script", "load", payload]]).exec((err, replies) => {
|
|
1773
|
+
if (err != null) {
|
|
1774
|
+
return reject(err);
|
|
1775
|
+
}
|
|
1776
|
+
this.shas[name] = replies[0];
|
|
1777
|
+
return resolve(replies[0]);
|
|
1778
|
+
});
|
|
1779
|
+
});
|
|
1780
|
+
}
|
|
1781
|
+
_loadScripts() {
|
|
1782
|
+
return this.Promise.all(Scripts.names.map((k) => {
|
|
1783
|
+
return this._loadScript(k);
|
|
1784
|
+
}));
|
|
1785
|
+
}
|
|
1786
|
+
__runCommand__(cmd) {
|
|
1787
|
+
var _this = this;
|
|
1788
|
+
return _asyncToGenerator(function* () {
|
|
1789
|
+
yield _this.ready;
|
|
1790
|
+
return new _this.Promise((resolve, reject) => {
|
|
1791
|
+
return _this.client.multi([cmd]).exec_atomic(function(err, replies) {
|
|
1792
|
+
if (err != null) {
|
|
1793
|
+
return reject(err);
|
|
1794
|
+
} else {
|
|
1795
|
+
return resolve(replies[0]);
|
|
1796
|
+
}
|
|
1797
|
+
});
|
|
1798
|
+
});
|
|
1799
|
+
})();
|
|
1800
|
+
}
|
|
1801
|
+
__addLimiter__(instance) {
|
|
1802
|
+
return this.Promise.all([instance.channel(), instance.channel_client()].map((channel) => {
|
|
1803
|
+
return new this.Promise((resolve, reject) => {
|
|
1804
|
+
var handler;
|
|
1805
|
+
handler = (chan) => {
|
|
1806
|
+
if (chan === channel) {
|
|
1807
|
+
this.subscriber.removeListener("subscribe", handler);
|
|
1808
|
+
this.limiters[channel] = instance;
|
|
1809
|
+
return resolve();
|
|
1810
|
+
}
|
|
1811
|
+
};
|
|
1812
|
+
this.subscriber.on("subscribe", handler);
|
|
1813
|
+
return this.subscriber.subscribe(channel);
|
|
1814
|
+
});
|
|
1815
|
+
}));
|
|
1816
|
+
}
|
|
1817
|
+
__removeLimiter__(instance) {
|
|
1818
|
+
var _this2 = this;
|
|
1819
|
+
return this.Promise.all([instance.channel(), instance.channel_client()].map(
|
|
1820
|
+
/* @__PURE__ */ function() {
|
|
1821
|
+
var _ref = _asyncToGenerator(function* (channel) {
|
|
1822
|
+
if (!_this2.terminated) {
|
|
1823
|
+
yield new _this2.Promise((resolve, reject) => {
|
|
1824
|
+
return _this2.subscriber.unsubscribe(channel, function(err, chan) {
|
|
1825
|
+
if (err != null) {
|
|
1826
|
+
return reject(err);
|
|
1827
|
+
}
|
|
1828
|
+
if (chan === channel) {
|
|
1829
|
+
return resolve();
|
|
1830
|
+
}
|
|
1831
|
+
});
|
|
1832
|
+
});
|
|
1833
|
+
}
|
|
1834
|
+
return delete _this2.limiters[channel];
|
|
1835
|
+
});
|
|
1836
|
+
return function(_x) {
|
|
1837
|
+
return _ref.apply(this, arguments);
|
|
1838
|
+
};
|
|
1839
|
+
}()
|
|
1840
|
+
));
|
|
1841
|
+
}
|
|
1842
|
+
__scriptArgs__(name, id, args, cb) {
|
|
1843
|
+
var keys;
|
|
1844
|
+
keys = Scripts.keys(name, id);
|
|
1845
|
+
return [this.shas[name], keys.length].concat(keys, args, cb);
|
|
1846
|
+
}
|
|
1847
|
+
__scriptFn__(name) {
|
|
1848
|
+
return this.client.evalsha.bind(this.client);
|
|
1849
|
+
}
|
|
1850
|
+
disconnect(flush = true) {
|
|
1851
|
+
var i, k, len, ref;
|
|
1852
|
+
ref = Object.keys(this.limiters);
|
|
1853
|
+
for (i = 0, len = ref.length; i < len; i++) {
|
|
1854
|
+
k = ref[i];
|
|
1855
|
+
clearInterval(this.limiters[k]._store.heartbeat);
|
|
1856
|
+
}
|
|
1857
|
+
this.limiters = {};
|
|
1858
|
+
this.terminated = true;
|
|
1859
|
+
this.client.end(flush);
|
|
1860
|
+
this.subscriber.end(flush);
|
|
1861
|
+
return this.Promise.resolve();
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
;
|
|
1865
|
+
RedisConnection.prototype.datastore = "redis";
|
|
1866
|
+
RedisConnection.prototype.defaults = {
|
|
1867
|
+
Redis: null,
|
|
1868
|
+
clientOptions: {},
|
|
1869
|
+
client: null,
|
|
1870
|
+
Promise,
|
|
1871
|
+
Events: null
|
|
1872
|
+
};
|
|
1873
|
+
return RedisConnection;
|
|
1874
|
+
}.call(void 0);
|
|
1875
|
+
module.exports = RedisConnection;
|
|
1876
|
+
}
|
|
1877
|
+
});
|
|
1878
|
+
|
|
1879
|
+
// ../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/IORedisConnection.js
|
|
1880
|
+
var require_IORedisConnection = __commonJS({
|
|
1881
|
+
"../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/IORedisConnection.js"(exports, module) {
|
|
1882
|
+
"use strict";
|
|
1883
|
+
init_cjs_shims();
|
|
1884
|
+
function _slicedToArray(arr, i) {
|
|
1885
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
|
|
1886
|
+
}
|
|
1887
|
+
function _nonIterableRest() {
|
|
1888
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
|
1889
|
+
}
|
|
1890
|
+
function _iterableToArrayLimit(arr, i) {
|
|
1891
|
+
var _arr = [];
|
|
1892
|
+
var _n = true;
|
|
1893
|
+
var _d = false;
|
|
1894
|
+
var _e = void 0;
|
|
1895
|
+
try {
|
|
1896
|
+
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
1897
|
+
_arr.push(_s.value);
|
|
1898
|
+
if (i && _arr.length === i)
|
|
1899
|
+
break;
|
|
1900
|
+
}
|
|
1901
|
+
} catch (err) {
|
|
1902
|
+
_d = true;
|
|
1903
|
+
_e = err;
|
|
1904
|
+
} finally {
|
|
1905
|
+
try {
|
|
1906
|
+
if (!_n && _i["return"] != null)
|
|
1907
|
+
_i["return"]();
|
|
1908
|
+
} finally {
|
|
1909
|
+
if (_d)
|
|
1910
|
+
throw _e;
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
return _arr;
|
|
1914
|
+
}
|
|
1915
|
+
function _arrayWithHoles(arr) {
|
|
1916
|
+
if (Array.isArray(arr))
|
|
1917
|
+
return arr;
|
|
1918
|
+
}
|
|
1919
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
1920
|
+
try {
|
|
1921
|
+
var info = gen[key](arg);
|
|
1922
|
+
var value = info.value;
|
|
1923
|
+
} catch (error) {
|
|
1924
|
+
reject(error);
|
|
1925
|
+
return;
|
|
1926
|
+
}
|
|
1927
|
+
if (info.done) {
|
|
1928
|
+
resolve(value);
|
|
1929
|
+
} else {
|
|
1930
|
+
Promise.resolve(value).then(_next, _throw);
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1933
|
+
function _asyncToGenerator(fn) {
|
|
1934
|
+
return function() {
|
|
1935
|
+
var self = this, args = arguments;
|
|
1936
|
+
return new Promise(function(resolve, reject) {
|
|
1937
|
+
var gen = fn.apply(self, args);
|
|
1938
|
+
function _next(value) {
|
|
1939
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
1940
|
+
}
|
|
1941
|
+
function _throw(err) {
|
|
1942
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
1943
|
+
}
|
|
1944
|
+
_next(void 0);
|
|
1945
|
+
});
|
|
1946
|
+
};
|
|
1947
|
+
}
|
|
1948
|
+
var Events;
|
|
1949
|
+
var IORedisConnection;
|
|
1950
|
+
var Scripts;
|
|
1951
|
+
var parser;
|
|
1952
|
+
parser = require_parser();
|
|
1953
|
+
Events = require_Events();
|
|
1954
|
+
Scripts = require_Scripts();
|
|
1955
|
+
IORedisConnection = function() {
|
|
1956
|
+
class IORedisConnection {
|
|
1957
|
+
constructor(options = {}) {
|
|
1958
|
+
parser.load(options, this.defaults, this);
|
|
1959
|
+
if (this.Redis == null) {
|
|
1960
|
+
this.Redis = eval("require")("ioredis");
|
|
1961
|
+
}
|
|
1962
|
+
if (this.Events == null) {
|
|
1963
|
+
this.Events = new Events(this);
|
|
1964
|
+
}
|
|
1965
|
+
this.terminated = false;
|
|
1966
|
+
if (this.clusterNodes != null) {
|
|
1967
|
+
this.client = new this.Redis.Cluster(this.clusterNodes, this.clientOptions);
|
|
1968
|
+
this.subscriber = new this.Redis.Cluster(this.clusterNodes, this.clientOptions);
|
|
1969
|
+
} else if (this.client != null && this.client.duplicate == null) {
|
|
1970
|
+
this.subscriber = new this.Redis.Cluster(this.client.startupNodes, this.client.options);
|
|
1971
|
+
} else {
|
|
1972
|
+
if (this.client == null) {
|
|
1973
|
+
this.client = new this.Redis(this.clientOptions);
|
|
1974
|
+
}
|
|
1975
|
+
this.subscriber = this.client.duplicate();
|
|
1976
|
+
}
|
|
1977
|
+
this.limiters = {};
|
|
1978
|
+
this.ready = this.Promise.all([this._setup(this.client, false), this._setup(this.subscriber, true)]).then(() => {
|
|
1979
|
+
this._loadScripts();
|
|
1980
|
+
return {
|
|
1981
|
+
client: this.client,
|
|
1982
|
+
subscriber: this.subscriber
|
|
1983
|
+
};
|
|
1984
|
+
});
|
|
1985
|
+
}
|
|
1986
|
+
_setup(client, sub) {
|
|
1987
|
+
client.setMaxListeners(0);
|
|
1988
|
+
return new this.Promise((resolve, reject) => {
|
|
1989
|
+
client.on("error", (e) => {
|
|
1990
|
+
return this.Events.trigger("error", e);
|
|
1991
|
+
});
|
|
1992
|
+
if (sub) {
|
|
1993
|
+
client.on("message", (channel, message) => {
|
|
1994
|
+
var ref;
|
|
1995
|
+
return (ref = this.limiters[channel]) != null ? ref._store.onMessage(channel, message) : void 0;
|
|
1996
|
+
});
|
|
1997
|
+
}
|
|
1998
|
+
if (client.status === "ready") {
|
|
1999
|
+
return resolve();
|
|
2000
|
+
} else {
|
|
2001
|
+
return client.once("ready", resolve);
|
|
2002
|
+
}
|
|
2003
|
+
});
|
|
2004
|
+
}
|
|
2005
|
+
_loadScripts() {
|
|
2006
|
+
return Scripts.names.forEach((name) => {
|
|
2007
|
+
return this.client.defineCommand(name, {
|
|
2008
|
+
lua: Scripts.payload(name)
|
|
2009
|
+
});
|
|
2010
|
+
});
|
|
2011
|
+
}
|
|
2012
|
+
__runCommand__(cmd) {
|
|
2013
|
+
var _this = this;
|
|
2014
|
+
return _asyncToGenerator(function* () {
|
|
2015
|
+
var _, deleted;
|
|
2016
|
+
yield _this.ready;
|
|
2017
|
+
var _ref = yield _this.client.pipeline([cmd]).exec();
|
|
2018
|
+
var _ref2 = _slicedToArray(_ref, 1);
|
|
2019
|
+
var _ref2$ = _slicedToArray(_ref2[0], 2);
|
|
2020
|
+
_ = _ref2$[0];
|
|
2021
|
+
deleted = _ref2$[1];
|
|
2022
|
+
return deleted;
|
|
2023
|
+
})();
|
|
2024
|
+
}
|
|
2025
|
+
__addLimiter__(instance) {
|
|
2026
|
+
return this.Promise.all([instance.channel(), instance.channel_client()].map((channel) => {
|
|
2027
|
+
return new this.Promise((resolve, reject) => {
|
|
2028
|
+
return this.subscriber.subscribe(channel, () => {
|
|
2029
|
+
this.limiters[channel] = instance;
|
|
2030
|
+
return resolve();
|
|
2031
|
+
});
|
|
2032
|
+
});
|
|
2033
|
+
}));
|
|
2034
|
+
}
|
|
2035
|
+
__removeLimiter__(instance) {
|
|
2036
|
+
var _this2 = this;
|
|
2037
|
+
return [instance.channel(), instance.channel_client()].forEach(
|
|
2038
|
+
/* @__PURE__ */ function() {
|
|
2039
|
+
var _ref3 = _asyncToGenerator(function* (channel) {
|
|
2040
|
+
if (!_this2.terminated) {
|
|
2041
|
+
yield _this2.subscriber.unsubscribe(channel);
|
|
2042
|
+
}
|
|
2043
|
+
return delete _this2.limiters[channel];
|
|
2044
|
+
});
|
|
2045
|
+
return function(_x) {
|
|
2046
|
+
return _ref3.apply(this, arguments);
|
|
2047
|
+
};
|
|
2048
|
+
}()
|
|
2049
|
+
);
|
|
2050
|
+
}
|
|
2051
|
+
__scriptArgs__(name, id, args, cb) {
|
|
2052
|
+
var keys;
|
|
2053
|
+
keys = Scripts.keys(name, id);
|
|
2054
|
+
return [keys.length].concat(keys, args, cb);
|
|
2055
|
+
}
|
|
2056
|
+
__scriptFn__(name) {
|
|
2057
|
+
return this.client[name].bind(this.client);
|
|
2058
|
+
}
|
|
2059
|
+
disconnect(flush = true) {
|
|
2060
|
+
var i, k, len, ref;
|
|
2061
|
+
ref = Object.keys(this.limiters);
|
|
2062
|
+
for (i = 0, len = ref.length; i < len; i++) {
|
|
2063
|
+
k = ref[i];
|
|
2064
|
+
clearInterval(this.limiters[k]._store.heartbeat);
|
|
2065
|
+
}
|
|
2066
|
+
this.limiters = {};
|
|
2067
|
+
this.terminated = true;
|
|
2068
|
+
if (flush) {
|
|
2069
|
+
return this.Promise.all([this.client.quit(), this.subscriber.quit()]);
|
|
2070
|
+
} else {
|
|
2071
|
+
this.client.disconnect();
|
|
2072
|
+
this.subscriber.disconnect();
|
|
2073
|
+
return this.Promise.resolve();
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
}
|
|
2077
|
+
;
|
|
2078
|
+
IORedisConnection.prototype.datastore = "ioredis";
|
|
2079
|
+
IORedisConnection.prototype.defaults = {
|
|
2080
|
+
Redis: null,
|
|
2081
|
+
clientOptions: {},
|
|
2082
|
+
clusterNodes: null,
|
|
2083
|
+
client: null,
|
|
2084
|
+
Promise,
|
|
2085
|
+
Events: null
|
|
2086
|
+
};
|
|
2087
|
+
return IORedisConnection;
|
|
2088
|
+
}.call(void 0);
|
|
2089
|
+
module.exports = IORedisConnection;
|
|
2090
|
+
}
|
|
2091
|
+
});
|
|
2092
|
+
|
|
2093
|
+
// ../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/RedisDatastore.js
|
|
2094
|
+
var require_RedisDatastore = __commonJS({
|
|
2095
|
+
"../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/RedisDatastore.js"(exports2, module2) {
|
|
2096
|
+
"use strict";
|
|
2097
|
+
init_cjs_shims();
|
|
2098
|
+
function _slicedToArray2(arr, i) {
|
|
2099
|
+
return _arrayWithHoles2(arr) || _iterableToArrayLimit2(arr, i) || _nonIterableRest2();
|
|
2100
|
+
}
|
|
2101
|
+
function _nonIterableRest2() {
|
|
2102
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
|
2103
|
+
}
|
|
2104
|
+
function _iterableToArrayLimit2(arr, i) {
|
|
2105
|
+
var _arr = [];
|
|
2106
|
+
var _n = true;
|
|
2107
|
+
var _d = false;
|
|
2108
|
+
var _e = void 0;
|
|
2109
|
+
try {
|
|
2110
|
+
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
2111
|
+
_arr.push(_s.value);
|
|
2112
|
+
if (i && _arr.length === i)
|
|
2113
|
+
break;
|
|
2114
|
+
}
|
|
2115
|
+
} catch (err) {
|
|
2116
|
+
_d = true;
|
|
2117
|
+
_e = err;
|
|
2118
|
+
} finally {
|
|
2119
|
+
try {
|
|
2120
|
+
if (!_n && _i["return"] != null)
|
|
2121
|
+
_i["return"]();
|
|
2122
|
+
} finally {
|
|
2123
|
+
if (_d)
|
|
2124
|
+
throw _e;
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
return _arr;
|
|
2128
|
+
}
|
|
2129
|
+
function _arrayWithHoles2(arr) {
|
|
2130
|
+
if (Array.isArray(arr))
|
|
2131
|
+
return arr;
|
|
2132
|
+
}
|
|
2133
|
+
function asyncGeneratorStep2(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2134
|
+
try {
|
|
2135
|
+
var info = gen[key](arg);
|
|
2136
|
+
var value = info.value;
|
|
2137
|
+
} catch (error) {
|
|
2138
|
+
reject(error);
|
|
2139
|
+
return;
|
|
2140
|
+
}
|
|
2141
|
+
if (info.done) {
|
|
2142
|
+
resolve(value);
|
|
2143
|
+
} else {
|
|
2144
|
+
Promise.resolve(value).then(_next, _throw);
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
function _asyncToGenerator2(fn) {
|
|
2148
|
+
return function() {
|
|
2149
|
+
var self = this, args = arguments;
|
|
2150
|
+
return new Promise(function(resolve, reject) {
|
|
2151
|
+
var gen = fn.apply(self, args);
|
|
2152
|
+
function _next(value) {
|
|
2153
|
+
asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "next", value);
|
|
2154
|
+
}
|
|
2155
|
+
function _throw(err) {
|
|
2156
|
+
asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "throw", err);
|
|
2157
|
+
}
|
|
2158
|
+
_next(void 0);
|
|
2159
|
+
});
|
|
2160
|
+
};
|
|
2161
|
+
}
|
|
2162
|
+
var BottleneckError;
|
|
2163
|
+
var IORedisConnection2;
|
|
2164
|
+
var RedisConnection2;
|
|
2165
|
+
var RedisDatastore;
|
|
2166
|
+
var parser2;
|
|
2167
|
+
parser2 = require_parser();
|
|
2168
|
+
BottleneckError = require_BottleneckError();
|
|
2169
|
+
RedisConnection2 = require_RedisConnection();
|
|
2170
|
+
IORedisConnection2 = require_IORedisConnection();
|
|
2171
|
+
RedisDatastore = class RedisDatastore {
|
|
2172
|
+
constructor(instance, storeOptions, storeInstanceOptions) {
|
|
2173
|
+
this.instance = instance;
|
|
2174
|
+
this.storeOptions = storeOptions;
|
|
2175
|
+
this.originalId = this.instance.id;
|
|
2176
|
+
this.clientId = this.instance._randomIndex();
|
|
2177
|
+
parser2.load(storeInstanceOptions, storeInstanceOptions, this);
|
|
2178
|
+
this.clients = {};
|
|
2179
|
+
this.capacityPriorityCounters = {};
|
|
2180
|
+
this.sharedConnection = this.connection != null;
|
|
2181
|
+
if (this.connection == null) {
|
|
2182
|
+
this.connection = this.instance.datastore === "redis" ? new RedisConnection2({
|
|
2183
|
+
Redis: this.Redis,
|
|
2184
|
+
clientOptions: this.clientOptions,
|
|
2185
|
+
Promise: this.Promise,
|
|
2186
|
+
Events: this.instance.Events
|
|
2187
|
+
}) : this.instance.datastore === "ioredis" ? new IORedisConnection2({
|
|
2188
|
+
Redis: this.Redis,
|
|
2189
|
+
clientOptions: this.clientOptions,
|
|
2190
|
+
clusterNodes: this.clusterNodes,
|
|
2191
|
+
Promise: this.Promise,
|
|
2192
|
+
Events: this.instance.Events
|
|
2193
|
+
}) : void 0;
|
|
2194
|
+
}
|
|
2195
|
+
this.instance.connection = this.connection;
|
|
2196
|
+
this.instance.datastore = this.connection.datastore;
|
|
2197
|
+
this.ready = this.connection.ready.then((clients) => {
|
|
2198
|
+
this.clients = clients;
|
|
2199
|
+
return this.runScript("init", this.prepareInitSettings(this.clearDatastore));
|
|
2200
|
+
}).then(() => {
|
|
2201
|
+
return this.connection.__addLimiter__(this.instance);
|
|
2202
|
+
}).then(() => {
|
|
2203
|
+
return this.runScript("register_client", [this.instance.queued()]);
|
|
2204
|
+
}).then(() => {
|
|
2205
|
+
var base;
|
|
2206
|
+
if (typeof (base = this.heartbeat = setInterval(() => {
|
|
2207
|
+
return this.runScript("heartbeat", []).catch((e) => {
|
|
2208
|
+
return this.instance.Events.trigger("error", e);
|
|
2209
|
+
});
|
|
2210
|
+
}, this.heartbeatInterval)).unref === "function") {
|
|
2211
|
+
base.unref();
|
|
2212
|
+
}
|
|
2213
|
+
return this.clients;
|
|
2214
|
+
});
|
|
2215
|
+
}
|
|
2216
|
+
__publish__(message) {
|
|
2217
|
+
var _this = this;
|
|
2218
|
+
return _asyncToGenerator2(function* () {
|
|
2219
|
+
var client;
|
|
2220
|
+
var _ref = yield _this.ready;
|
|
2221
|
+
client = _ref.client;
|
|
2222
|
+
return client.publish(_this.instance.channel(), `message:${message.toString()}`);
|
|
2223
|
+
})();
|
|
2224
|
+
}
|
|
2225
|
+
onMessage(channel, message) {
|
|
2226
|
+
var _this2 = this;
|
|
2227
|
+
return _asyncToGenerator2(function* () {
|
|
2228
|
+
var capacity, counter, data, drained, e, newCapacity, pos, priorityClient, rawCapacity, type;
|
|
2229
|
+
try {
|
|
2230
|
+
pos = message.indexOf(":");
|
|
2231
|
+
var _ref2 = [message.slice(0, pos), message.slice(pos + 1)];
|
|
2232
|
+
type = _ref2[0];
|
|
2233
|
+
data = _ref2[1];
|
|
2234
|
+
if (type === "capacity") {
|
|
2235
|
+
return yield _this2.instance._drainAll(data.length > 0 ? ~~data : void 0);
|
|
2236
|
+
} else if (type === "capacity-priority") {
|
|
2237
|
+
var _data$split = data.split(":");
|
|
2238
|
+
var _data$split2 = _slicedToArray2(_data$split, 3);
|
|
2239
|
+
rawCapacity = _data$split2[0];
|
|
2240
|
+
priorityClient = _data$split2[1];
|
|
2241
|
+
counter = _data$split2[2];
|
|
2242
|
+
capacity = rawCapacity.length > 0 ? ~~rawCapacity : void 0;
|
|
2243
|
+
if (priorityClient === _this2.clientId) {
|
|
2244
|
+
drained = yield _this2.instance._drainAll(capacity);
|
|
2245
|
+
newCapacity = capacity != null ? capacity - (drained || 0) : "";
|
|
2246
|
+
return yield _this2.clients.client.publish(_this2.instance.channel(), `capacity-priority:${newCapacity}::${counter}`);
|
|
2247
|
+
} else if (priorityClient === "") {
|
|
2248
|
+
clearTimeout(_this2.capacityPriorityCounters[counter]);
|
|
2249
|
+
delete _this2.capacityPriorityCounters[counter];
|
|
2250
|
+
return _this2.instance._drainAll(capacity);
|
|
2251
|
+
} else {
|
|
2252
|
+
return _this2.capacityPriorityCounters[counter] = setTimeout(
|
|
2253
|
+
/* @__PURE__ */ _asyncToGenerator2(function* () {
|
|
2254
|
+
var e2;
|
|
2255
|
+
try {
|
|
2256
|
+
delete _this2.capacityPriorityCounters[counter];
|
|
2257
|
+
yield _this2.runScript("blacklist_client", [priorityClient]);
|
|
2258
|
+
return yield _this2.instance._drainAll(capacity);
|
|
2259
|
+
} catch (error) {
|
|
2260
|
+
e2 = error;
|
|
2261
|
+
return _this2.instance.Events.trigger("error", e2);
|
|
2262
|
+
}
|
|
2263
|
+
}),
|
|
2264
|
+
1e3
|
|
2265
|
+
);
|
|
2266
|
+
}
|
|
2267
|
+
} else if (type === "message") {
|
|
2268
|
+
return _this2.instance.Events.trigger("message", data);
|
|
2269
|
+
} else if (type === "blocked") {
|
|
2270
|
+
return yield _this2.instance._dropAllQueued();
|
|
2271
|
+
}
|
|
2272
|
+
} catch (error) {
|
|
2273
|
+
e = error;
|
|
2274
|
+
return _this2.instance.Events.trigger("error", e);
|
|
2275
|
+
}
|
|
2276
|
+
})();
|
|
2277
|
+
}
|
|
2278
|
+
__disconnect__(flush) {
|
|
2279
|
+
clearInterval(this.heartbeat);
|
|
2280
|
+
if (this.sharedConnection) {
|
|
2281
|
+
return this.connection.__removeLimiter__(this.instance);
|
|
2282
|
+
} else {
|
|
2283
|
+
return this.connection.disconnect(flush);
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2286
|
+
runScript(name, args) {
|
|
2287
|
+
var _this3 = this;
|
|
2288
|
+
return _asyncToGenerator2(function* () {
|
|
2289
|
+
if (!(name === "init" || name === "register_client")) {
|
|
2290
|
+
yield _this3.ready;
|
|
2291
|
+
}
|
|
2292
|
+
return new _this3.Promise((resolve, reject) => {
|
|
2293
|
+
var all_args, arr;
|
|
2294
|
+
all_args = [Date.now(), _this3.clientId].concat(args);
|
|
2295
|
+
_this3.instance.Events.trigger("debug", `Calling Redis script: ${name}.lua`, all_args);
|
|
2296
|
+
arr = _this3.connection.__scriptArgs__(name, _this3.originalId, all_args, function(err, replies) {
|
|
2297
|
+
if (err != null) {
|
|
2298
|
+
return reject(err);
|
|
2299
|
+
}
|
|
2300
|
+
return resolve(replies);
|
|
2301
|
+
});
|
|
2302
|
+
return _this3.connection.__scriptFn__(name)(...arr);
|
|
2303
|
+
}).catch((e) => {
|
|
2304
|
+
if (e.message === "SETTINGS_KEY_NOT_FOUND") {
|
|
2305
|
+
if (name === "heartbeat") {
|
|
2306
|
+
return _this3.Promise.resolve();
|
|
2307
|
+
} else {
|
|
2308
|
+
return _this3.runScript("init", _this3.prepareInitSettings(false)).then(() => {
|
|
2309
|
+
return _this3.runScript(name, args);
|
|
2310
|
+
});
|
|
2311
|
+
}
|
|
2312
|
+
} else if (e.message === "UNKNOWN_CLIENT") {
|
|
2313
|
+
return _this3.runScript("register_client", [_this3.instance.queued()]).then(() => {
|
|
2314
|
+
return _this3.runScript(name, args);
|
|
2315
|
+
});
|
|
2316
|
+
} else {
|
|
2317
|
+
return _this3.Promise.reject(e);
|
|
2318
|
+
}
|
|
2319
|
+
});
|
|
2320
|
+
})();
|
|
2321
|
+
}
|
|
2322
|
+
prepareArray(arr) {
|
|
2323
|
+
var i, len, results, x;
|
|
2324
|
+
results = [];
|
|
2325
|
+
for (i = 0, len = arr.length; i < len; i++) {
|
|
2326
|
+
x = arr[i];
|
|
2327
|
+
results.push(x != null ? x.toString() : "");
|
|
2328
|
+
}
|
|
2329
|
+
return results;
|
|
2330
|
+
}
|
|
2331
|
+
prepareObject(obj) {
|
|
2332
|
+
var arr, k, v;
|
|
2333
|
+
arr = [];
|
|
2334
|
+
for (k in obj) {
|
|
2335
|
+
v = obj[k];
|
|
2336
|
+
arr.push(k, v != null ? v.toString() : "");
|
|
2337
|
+
}
|
|
2338
|
+
return arr;
|
|
2339
|
+
}
|
|
2340
|
+
prepareInitSettings(clear) {
|
|
2341
|
+
var args;
|
|
2342
|
+
args = this.prepareObject(Object.assign({}, this.storeOptions, {
|
|
2343
|
+
id: this.originalId,
|
|
2344
|
+
version: this.instance.version,
|
|
2345
|
+
groupTimeout: this.timeout,
|
|
2346
|
+
clientTimeout: this.clientTimeout
|
|
2347
|
+
}));
|
|
2348
|
+
args.unshift(clear ? 1 : 0, this.instance.version);
|
|
2349
|
+
return args;
|
|
2350
|
+
}
|
|
2351
|
+
convertBool(b) {
|
|
2352
|
+
return !!b;
|
|
2353
|
+
}
|
|
2354
|
+
__updateSettings__(options2) {
|
|
2355
|
+
var _this4 = this;
|
|
2356
|
+
return _asyncToGenerator2(function* () {
|
|
2357
|
+
yield _this4.runScript("update_settings", _this4.prepareObject(options2));
|
|
2358
|
+
return parser2.overwrite(options2, options2, _this4.storeOptions);
|
|
2359
|
+
})();
|
|
2360
|
+
}
|
|
2361
|
+
__running__() {
|
|
2362
|
+
return this.runScript("running", []);
|
|
2363
|
+
}
|
|
2364
|
+
__queued__() {
|
|
2365
|
+
return this.runScript("queued", []);
|
|
2366
|
+
}
|
|
2367
|
+
__done__() {
|
|
2368
|
+
return this.runScript("done", []);
|
|
2369
|
+
}
|
|
2370
|
+
__groupCheck__() {
|
|
2371
|
+
var _this5 = this;
|
|
2372
|
+
return _asyncToGenerator2(function* () {
|
|
2373
|
+
return _this5.convertBool(yield _this5.runScript("group_check", []));
|
|
2374
|
+
})();
|
|
2375
|
+
}
|
|
2376
|
+
__incrementReservoir__(incr) {
|
|
2377
|
+
return this.runScript("increment_reservoir", [incr]);
|
|
2378
|
+
}
|
|
2379
|
+
__currentReservoir__() {
|
|
2380
|
+
return this.runScript("current_reservoir", []);
|
|
2381
|
+
}
|
|
2382
|
+
__check__(weight) {
|
|
2383
|
+
var _this6 = this;
|
|
2384
|
+
return _asyncToGenerator2(function* () {
|
|
2385
|
+
return _this6.convertBool(yield _this6.runScript("check", _this6.prepareArray([weight])));
|
|
2386
|
+
})();
|
|
2387
|
+
}
|
|
2388
|
+
__register__(index, weight, expiration) {
|
|
2389
|
+
var _this7 = this;
|
|
2390
|
+
return _asyncToGenerator2(function* () {
|
|
2391
|
+
var reservoir, success, wait;
|
|
2392
|
+
var _ref4 = yield _this7.runScript("register", _this7.prepareArray([index, weight, expiration]));
|
|
2393
|
+
var _ref5 = _slicedToArray2(_ref4, 3);
|
|
2394
|
+
success = _ref5[0];
|
|
2395
|
+
wait = _ref5[1];
|
|
2396
|
+
reservoir = _ref5[2];
|
|
2397
|
+
return {
|
|
2398
|
+
success: _this7.convertBool(success),
|
|
2399
|
+
wait,
|
|
2400
|
+
reservoir
|
|
2401
|
+
};
|
|
2402
|
+
})();
|
|
2403
|
+
}
|
|
2404
|
+
__submit__(queueLength, weight) {
|
|
2405
|
+
var _this8 = this;
|
|
2406
|
+
return _asyncToGenerator2(function* () {
|
|
2407
|
+
var blocked, e, maxConcurrent, overweight, reachedHWM, strategy;
|
|
2408
|
+
try {
|
|
2409
|
+
var _ref6 = yield _this8.runScript("submit", _this8.prepareArray([queueLength, weight]));
|
|
2410
|
+
var _ref7 = _slicedToArray2(_ref6, 3);
|
|
2411
|
+
reachedHWM = _ref7[0];
|
|
2412
|
+
blocked = _ref7[1];
|
|
2413
|
+
strategy = _ref7[2];
|
|
2414
|
+
return {
|
|
2415
|
+
reachedHWM: _this8.convertBool(reachedHWM),
|
|
2416
|
+
blocked: _this8.convertBool(blocked),
|
|
2417
|
+
strategy
|
|
2418
|
+
};
|
|
2419
|
+
} catch (error) {
|
|
2420
|
+
e = error;
|
|
2421
|
+
if (e.message.indexOf("OVERWEIGHT") === 0) {
|
|
2422
|
+
var _e$message$split = e.message.split(":");
|
|
2423
|
+
var _e$message$split2 = _slicedToArray2(_e$message$split, 3);
|
|
2424
|
+
overweight = _e$message$split2[0];
|
|
2425
|
+
weight = _e$message$split2[1];
|
|
2426
|
+
maxConcurrent = _e$message$split2[2];
|
|
2427
|
+
throw new BottleneckError(`Impossible to add a job having a weight of ${weight} to a limiter having a maxConcurrent setting of ${maxConcurrent}`);
|
|
2428
|
+
} else {
|
|
2429
|
+
throw e;
|
|
2430
|
+
}
|
|
2431
|
+
}
|
|
2432
|
+
})();
|
|
2433
|
+
}
|
|
2434
|
+
__free__(index, weight) {
|
|
2435
|
+
var _this9 = this;
|
|
2436
|
+
return _asyncToGenerator2(function* () {
|
|
2437
|
+
var running;
|
|
2438
|
+
running = yield _this9.runScript("free", _this9.prepareArray([index]));
|
|
2439
|
+
return {
|
|
2440
|
+
running
|
|
2441
|
+
};
|
|
2442
|
+
})();
|
|
2443
|
+
}
|
|
2444
|
+
};
|
|
2445
|
+
module2.exports = RedisDatastore;
|
|
2446
|
+
}
|
|
2447
|
+
});
|
|
2448
|
+
|
|
2449
|
+
// ../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/States.js
|
|
2450
|
+
var require_States = __commonJS({
|
|
2451
|
+
"../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/States.js"(exports2, module2) {
|
|
2452
|
+
"use strict";
|
|
2453
|
+
init_cjs_shims();
|
|
2454
|
+
var BottleneckError;
|
|
2455
|
+
var States;
|
|
2456
|
+
BottleneckError = require_BottleneckError();
|
|
2457
|
+
States = class States {
|
|
2458
|
+
constructor(status1) {
|
|
2459
|
+
this.status = status1;
|
|
2460
|
+
this._jobs = {};
|
|
2461
|
+
this.counts = this.status.map(function() {
|
|
2462
|
+
return 0;
|
|
2463
|
+
});
|
|
2464
|
+
}
|
|
2465
|
+
next(id) {
|
|
2466
|
+
var current, next;
|
|
2467
|
+
current = this._jobs[id];
|
|
2468
|
+
next = current + 1;
|
|
2469
|
+
if (current != null && next < this.status.length) {
|
|
2470
|
+
this.counts[current]--;
|
|
2471
|
+
this.counts[next]++;
|
|
2472
|
+
return this._jobs[id]++;
|
|
2473
|
+
} else if (current != null) {
|
|
2474
|
+
this.counts[current]--;
|
|
2475
|
+
return delete this._jobs[id];
|
|
2476
|
+
}
|
|
2477
|
+
}
|
|
2478
|
+
start(id) {
|
|
2479
|
+
var initial;
|
|
2480
|
+
initial = 0;
|
|
2481
|
+
this._jobs[id] = initial;
|
|
2482
|
+
return this.counts[initial]++;
|
|
2483
|
+
}
|
|
2484
|
+
remove(id) {
|
|
2485
|
+
var current;
|
|
2486
|
+
current = this._jobs[id];
|
|
2487
|
+
if (current != null) {
|
|
2488
|
+
this.counts[current]--;
|
|
2489
|
+
delete this._jobs[id];
|
|
2490
|
+
}
|
|
2491
|
+
return current != null;
|
|
2492
|
+
}
|
|
2493
|
+
jobStatus(id) {
|
|
2494
|
+
var ref;
|
|
2495
|
+
return (ref = this.status[this._jobs[id]]) != null ? ref : null;
|
|
2496
|
+
}
|
|
2497
|
+
statusJobs(status) {
|
|
2498
|
+
var k, pos, ref, results, v;
|
|
2499
|
+
if (status != null) {
|
|
2500
|
+
pos = this.status.indexOf(status);
|
|
2501
|
+
if (pos < 0) {
|
|
2502
|
+
throw new BottleneckError(`status must be one of ${this.status.join(", ")}`);
|
|
2503
|
+
}
|
|
2504
|
+
ref = this._jobs;
|
|
2505
|
+
results = [];
|
|
2506
|
+
for (k in ref) {
|
|
2507
|
+
v = ref[k];
|
|
2508
|
+
if (v === pos) {
|
|
2509
|
+
results.push(k);
|
|
2510
|
+
}
|
|
2511
|
+
}
|
|
2512
|
+
return results;
|
|
2513
|
+
} else {
|
|
2514
|
+
return Object.keys(this._jobs);
|
|
2515
|
+
}
|
|
2516
|
+
}
|
|
2517
|
+
statusCounts() {
|
|
2518
|
+
return this.counts.reduce((acc, v, i) => {
|
|
2519
|
+
acc[this.status[i]] = v;
|
|
2520
|
+
return acc;
|
|
2521
|
+
}, {});
|
|
2522
|
+
}
|
|
2523
|
+
};
|
|
2524
|
+
module2.exports = States;
|
|
2525
|
+
}
|
|
2526
|
+
});
|
|
2527
|
+
|
|
2528
|
+
// ../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/Sync.js
|
|
2529
|
+
var require_Sync = __commonJS({
|
|
2530
|
+
"../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/Sync.js"(exports2, module2) {
|
|
2531
|
+
"use strict";
|
|
2532
|
+
init_cjs_shims();
|
|
2533
|
+
function asyncGeneratorStep2(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2534
|
+
try {
|
|
2535
|
+
var info = gen[key](arg);
|
|
2536
|
+
var value = info.value;
|
|
2537
|
+
} catch (error) {
|
|
2538
|
+
reject(error);
|
|
2539
|
+
return;
|
|
2540
|
+
}
|
|
2541
|
+
if (info.done) {
|
|
2542
|
+
resolve(value);
|
|
2543
|
+
} else {
|
|
2544
|
+
Promise.resolve(value).then(_next, _throw);
|
|
2545
|
+
}
|
|
2546
|
+
}
|
|
2547
|
+
function _asyncToGenerator2(fn) {
|
|
2548
|
+
return function() {
|
|
2549
|
+
var self = this, args = arguments;
|
|
2550
|
+
return new Promise(function(resolve, reject) {
|
|
2551
|
+
var gen = fn.apply(self, args);
|
|
2552
|
+
function _next(value) {
|
|
2553
|
+
asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "next", value);
|
|
2554
|
+
}
|
|
2555
|
+
function _throw(err) {
|
|
2556
|
+
asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "throw", err);
|
|
2557
|
+
}
|
|
2558
|
+
_next(void 0);
|
|
2559
|
+
});
|
|
2560
|
+
};
|
|
2561
|
+
}
|
|
2562
|
+
var DLList;
|
|
2563
|
+
var Sync;
|
|
2564
|
+
DLList = require_DLList();
|
|
2565
|
+
Sync = class Sync {
|
|
2566
|
+
constructor(name, Promise2) {
|
|
2567
|
+
this.schedule = this.schedule.bind(this);
|
|
2568
|
+
this.name = name;
|
|
2569
|
+
this.Promise = Promise2;
|
|
2570
|
+
this._running = 0;
|
|
2571
|
+
this._queue = new DLList();
|
|
2572
|
+
}
|
|
2573
|
+
isEmpty() {
|
|
2574
|
+
return this._queue.length === 0;
|
|
2575
|
+
}
|
|
2576
|
+
_tryToRun() {
|
|
2577
|
+
var _this = this;
|
|
2578
|
+
return _asyncToGenerator2(function* () {
|
|
2579
|
+
var args, cb, error, reject, resolve, returned, task;
|
|
2580
|
+
if (_this._running < 1 && _this._queue.length > 0) {
|
|
2581
|
+
_this._running++;
|
|
2582
|
+
var _this$_queue$shift = _this._queue.shift();
|
|
2583
|
+
task = _this$_queue$shift.task;
|
|
2584
|
+
args = _this$_queue$shift.args;
|
|
2585
|
+
resolve = _this$_queue$shift.resolve;
|
|
2586
|
+
reject = _this$_queue$shift.reject;
|
|
2587
|
+
cb = yield _asyncToGenerator2(function* () {
|
|
2588
|
+
try {
|
|
2589
|
+
returned = yield task(...args);
|
|
2590
|
+
return function() {
|
|
2591
|
+
return resolve(returned);
|
|
2592
|
+
};
|
|
2593
|
+
} catch (error1) {
|
|
2594
|
+
error = error1;
|
|
2595
|
+
return function() {
|
|
2596
|
+
return reject(error);
|
|
2597
|
+
};
|
|
2598
|
+
}
|
|
2599
|
+
})();
|
|
2600
|
+
_this._running--;
|
|
2601
|
+
_this._tryToRun();
|
|
2602
|
+
return cb();
|
|
2603
|
+
}
|
|
2604
|
+
})();
|
|
2605
|
+
}
|
|
2606
|
+
schedule(task, ...args) {
|
|
2607
|
+
var promise, reject, resolve;
|
|
2608
|
+
resolve = reject = null;
|
|
2609
|
+
promise = new this.Promise(function(_resolve, _reject) {
|
|
2610
|
+
resolve = _resolve;
|
|
2611
|
+
return reject = _reject;
|
|
2612
|
+
});
|
|
2613
|
+
this._queue.push({
|
|
2614
|
+
task,
|
|
2615
|
+
args,
|
|
2616
|
+
resolve,
|
|
2617
|
+
reject
|
|
2618
|
+
});
|
|
2619
|
+
this._tryToRun();
|
|
2620
|
+
return promise;
|
|
2621
|
+
}
|
|
2622
|
+
};
|
|
2623
|
+
module2.exports = Sync;
|
|
2624
|
+
}
|
|
2625
|
+
});
|
|
2626
|
+
|
|
2627
|
+
// ../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/version.json
|
|
2628
|
+
var require_version = __commonJS({
|
|
2629
|
+
"../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/version.json"(exports2, module2) {
|
|
2630
|
+
module2.exports = { version: "2.19.5" };
|
|
2631
|
+
}
|
|
2632
|
+
});
|
|
2633
|
+
|
|
2634
|
+
// ../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/Group.js
|
|
2635
|
+
var require_Group = __commonJS({
|
|
2636
|
+
"../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/Group.js"(exports2, module2) {
|
|
2637
|
+
"use strict";
|
|
2638
|
+
init_cjs_shims();
|
|
2639
|
+
function _slicedToArray2(arr, i) {
|
|
2640
|
+
return _arrayWithHoles2(arr) || _iterableToArrayLimit2(arr, i) || _nonIterableRest2();
|
|
2641
|
+
}
|
|
2642
|
+
function _nonIterableRest2() {
|
|
2643
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
|
2644
|
+
}
|
|
2645
|
+
function _iterableToArrayLimit2(arr, i) {
|
|
2646
|
+
var _arr = [];
|
|
2647
|
+
var _n = true;
|
|
2648
|
+
var _d = false;
|
|
2649
|
+
var _e = void 0;
|
|
2650
|
+
try {
|
|
2651
|
+
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
2652
|
+
_arr.push(_s.value);
|
|
2653
|
+
if (i && _arr.length === i)
|
|
2654
|
+
break;
|
|
2655
|
+
}
|
|
2656
|
+
} catch (err) {
|
|
2657
|
+
_d = true;
|
|
2658
|
+
_e = err;
|
|
2659
|
+
} finally {
|
|
2660
|
+
try {
|
|
2661
|
+
if (!_n && _i["return"] != null)
|
|
2662
|
+
_i["return"]();
|
|
2663
|
+
} finally {
|
|
2664
|
+
if (_d)
|
|
2665
|
+
throw _e;
|
|
2666
|
+
}
|
|
2667
|
+
}
|
|
2668
|
+
return _arr;
|
|
2669
|
+
}
|
|
2670
|
+
function _arrayWithHoles2(arr) {
|
|
2671
|
+
if (Array.isArray(arr))
|
|
2672
|
+
return arr;
|
|
2673
|
+
}
|
|
2674
|
+
function asyncGeneratorStep2(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2675
|
+
try {
|
|
2676
|
+
var info = gen[key](arg);
|
|
2677
|
+
var value = info.value;
|
|
2678
|
+
} catch (error) {
|
|
2679
|
+
reject(error);
|
|
2680
|
+
return;
|
|
2681
|
+
}
|
|
2682
|
+
if (info.done) {
|
|
2683
|
+
resolve(value);
|
|
2684
|
+
} else {
|
|
2685
|
+
Promise.resolve(value).then(_next, _throw);
|
|
2686
|
+
}
|
|
2687
|
+
}
|
|
2688
|
+
function _asyncToGenerator2(fn) {
|
|
2689
|
+
return function() {
|
|
2690
|
+
var self = this, args = arguments;
|
|
2691
|
+
return new Promise(function(resolve, reject) {
|
|
2692
|
+
var gen = fn.apply(self, args);
|
|
2693
|
+
function _next(value) {
|
|
2694
|
+
asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "next", value);
|
|
2695
|
+
}
|
|
2696
|
+
function _throw(err) {
|
|
2697
|
+
asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "throw", err);
|
|
2698
|
+
}
|
|
2699
|
+
_next(void 0);
|
|
2700
|
+
});
|
|
2701
|
+
};
|
|
2702
|
+
}
|
|
2703
|
+
var Events2;
|
|
2704
|
+
var Group;
|
|
2705
|
+
var IORedisConnection2;
|
|
2706
|
+
var RedisConnection2;
|
|
2707
|
+
var Scripts2;
|
|
2708
|
+
var parser2;
|
|
2709
|
+
parser2 = require_parser();
|
|
2710
|
+
Events2 = require_Events();
|
|
2711
|
+
RedisConnection2 = require_RedisConnection();
|
|
2712
|
+
IORedisConnection2 = require_IORedisConnection();
|
|
2713
|
+
Scripts2 = require_Scripts();
|
|
2714
|
+
Group = function() {
|
|
2715
|
+
class Group2 {
|
|
2716
|
+
constructor(limiterOptions = {}) {
|
|
2717
|
+
this.deleteKey = this.deleteKey.bind(this);
|
|
2718
|
+
this.limiterOptions = limiterOptions;
|
|
2719
|
+
parser2.load(this.limiterOptions, this.defaults, this);
|
|
2720
|
+
this.Events = new Events2(this);
|
|
2721
|
+
this.instances = {};
|
|
2722
|
+
this.Bottleneck = require_Bottleneck();
|
|
2723
|
+
this._startAutoCleanup();
|
|
2724
|
+
this.sharedConnection = this.connection != null;
|
|
2725
|
+
if (this.connection == null) {
|
|
2726
|
+
if (this.limiterOptions.datastore === "redis") {
|
|
2727
|
+
this.connection = new RedisConnection2(Object.assign({}, this.limiterOptions, {
|
|
2728
|
+
Events: this.Events
|
|
2729
|
+
}));
|
|
2730
|
+
} else if (this.limiterOptions.datastore === "ioredis") {
|
|
2731
|
+
this.connection = new IORedisConnection2(Object.assign({}, this.limiterOptions, {
|
|
2732
|
+
Events: this.Events
|
|
2733
|
+
}));
|
|
2734
|
+
}
|
|
2735
|
+
}
|
|
2736
|
+
}
|
|
2737
|
+
key(key = "") {
|
|
2738
|
+
var ref;
|
|
2739
|
+
return (ref = this.instances[key]) != null ? ref : (() => {
|
|
2740
|
+
var limiter;
|
|
2741
|
+
limiter = this.instances[key] = new this.Bottleneck(Object.assign(this.limiterOptions, {
|
|
2742
|
+
id: `${this.id}-${key}`,
|
|
2743
|
+
timeout: this.timeout,
|
|
2744
|
+
connection: this.connection
|
|
2745
|
+
}));
|
|
2746
|
+
this.Events.trigger("created", limiter, key);
|
|
2747
|
+
return limiter;
|
|
2748
|
+
})();
|
|
2749
|
+
}
|
|
2750
|
+
deleteKey(key = "") {
|
|
2751
|
+
var _this = this;
|
|
2752
|
+
return _asyncToGenerator2(function* () {
|
|
2753
|
+
var deleted, instance;
|
|
2754
|
+
instance = _this.instances[key];
|
|
2755
|
+
if (_this.connection) {
|
|
2756
|
+
deleted = yield _this.connection.__runCommand__(["del", ...Scripts2.allKeys(`${_this.id}-${key}`)]);
|
|
2757
|
+
}
|
|
2758
|
+
if (instance != null) {
|
|
2759
|
+
delete _this.instances[key];
|
|
2760
|
+
yield instance.disconnect();
|
|
2761
|
+
}
|
|
2762
|
+
return instance != null || deleted > 0;
|
|
2763
|
+
})();
|
|
2764
|
+
}
|
|
2765
|
+
limiters() {
|
|
2766
|
+
var k, ref, results, v;
|
|
2767
|
+
ref = this.instances;
|
|
2768
|
+
results = [];
|
|
2769
|
+
for (k in ref) {
|
|
2770
|
+
v = ref[k];
|
|
2771
|
+
results.push({
|
|
2772
|
+
key: k,
|
|
2773
|
+
limiter: v
|
|
2774
|
+
});
|
|
2775
|
+
}
|
|
2776
|
+
return results;
|
|
2777
|
+
}
|
|
2778
|
+
keys() {
|
|
2779
|
+
return Object.keys(this.instances);
|
|
2780
|
+
}
|
|
2781
|
+
clusterKeys() {
|
|
2782
|
+
var _this2 = this;
|
|
2783
|
+
return _asyncToGenerator2(function* () {
|
|
2784
|
+
var cursor, end, found, i, k, keys, len, next, start;
|
|
2785
|
+
if (_this2.connection == null) {
|
|
2786
|
+
return _this2.Promise.resolve(_this2.keys());
|
|
2787
|
+
}
|
|
2788
|
+
keys = [];
|
|
2789
|
+
cursor = null;
|
|
2790
|
+
start = `b_${_this2.id}-`.length;
|
|
2791
|
+
end = "_settings".length;
|
|
2792
|
+
while (cursor !== 0) {
|
|
2793
|
+
var _ref = yield _this2.connection.__runCommand__(["scan", cursor != null ? cursor : 0, "match", `b_${_this2.id}-*_settings`, "count", 1e4]);
|
|
2794
|
+
var _ref2 = _slicedToArray2(_ref, 2);
|
|
2795
|
+
next = _ref2[0];
|
|
2796
|
+
found = _ref2[1];
|
|
2797
|
+
cursor = ~~next;
|
|
2798
|
+
for (i = 0, len = found.length; i < len; i++) {
|
|
2799
|
+
k = found[i];
|
|
2800
|
+
keys.push(k.slice(start, -end));
|
|
2801
|
+
}
|
|
2802
|
+
}
|
|
2803
|
+
return keys;
|
|
2804
|
+
})();
|
|
2805
|
+
}
|
|
2806
|
+
_startAutoCleanup() {
|
|
2807
|
+
var _this3 = this;
|
|
2808
|
+
var base;
|
|
2809
|
+
clearInterval(this.interval);
|
|
2810
|
+
return typeof (base = this.interval = setInterval(
|
|
2811
|
+
/* @__PURE__ */ _asyncToGenerator2(function* () {
|
|
2812
|
+
var e, k, ref, results, time, v;
|
|
2813
|
+
time = Date.now();
|
|
2814
|
+
ref = _this3.instances;
|
|
2815
|
+
results = [];
|
|
2816
|
+
for (k in ref) {
|
|
2817
|
+
v = ref[k];
|
|
2818
|
+
try {
|
|
2819
|
+
if (yield v._store.__groupCheck__(time)) {
|
|
2820
|
+
results.push(_this3.deleteKey(k));
|
|
2821
|
+
} else {
|
|
2822
|
+
results.push(void 0);
|
|
2823
|
+
}
|
|
2824
|
+
} catch (error) {
|
|
2825
|
+
e = error;
|
|
2826
|
+
results.push(v.Events.trigger("error", e));
|
|
2827
|
+
}
|
|
2828
|
+
}
|
|
2829
|
+
return results;
|
|
2830
|
+
}),
|
|
2831
|
+
this.timeout / 2
|
|
2832
|
+
)).unref === "function" ? base.unref() : void 0;
|
|
2833
|
+
}
|
|
2834
|
+
updateSettings(options2 = {}) {
|
|
2835
|
+
parser2.overwrite(options2, this.defaults, this);
|
|
2836
|
+
parser2.overwrite(options2, options2, this.limiterOptions);
|
|
2837
|
+
if (options2.timeout != null) {
|
|
2838
|
+
return this._startAutoCleanup();
|
|
2839
|
+
}
|
|
2840
|
+
}
|
|
2841
|
+
disconnect(flush = true) {
|
|
2842
|
+
var ref;
|
|
2843
|
+
if (!this.sharedConnection) {
|
|
2844
|
+
return (ref = this.connection) != null ? ref.disconnect(flush) : void 0;
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2847
|
+
}
|
|
2848
|
+
;
|
|
2849
|
+
Group2.prototype.defaults = {
|
|
2850
|
+
timeout: 1e3 * 60 * 5,
|
|
2851
|
+
connection: null,
|
|
2852
|
+
Promise,
|
|
2853
|
+
id: "group-key"
|
|
2854
|
+
};
|
|
2855
|
+
return Group2;
|
|
2856
|
+
}.call(void 0);
|
|
2857
|
+
module2.exports = Group;
|
|
2858
|
+
}
|
|
2859
|
+
});
|
|
2860
|
+
|
|
2861
|
+
// ../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/Batcher.js
|
|
2862
|
+
var require_Batcher = __commonJS({
|
|
2863
|
+
"../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/Batcher.js"(exports2, module2) {
|
|
2864
|
+
"use strict";
|
|
2865
|
+
init_cjs_shims();
|
|
2866
|
+
var Batcher;
|
|
2867
|
+
var Events2;
|
|
2868
|
+
var parser2;
|
|
2869
|
+
parser2 = require_parser();
|
|
2870
|
+
Events2 = require_Events();
|
|
2871
|
+
Batcher = function() {
|
|
2872
|
+
class Batcher2 {
|
|
2873
|
+
constructor(options2 = {}) {
|
|
2874
|
+
this.options = options2;
|
|
2875
|
+
parser2.load(this.options, this.defaults, this);
|
|
2876
|
+
this.Events = new Events2(this);
|
|
2877
|
+
this._arr = [];
|
|
2878
|
+
this._resetPromise();
|
|
2879
|
+
this._lastFlush = Date.now();
|
|
2880
|
+
}
|
|
2881
|
+
_resetPromise() {
|
|
2882
|
+
return this._promise = new this.Promise((res, rej) => {
|
|
2883
|
+
return this._resolve = res;
|
|
2884
|
+
});
|
|
2885
|
+
}
|
|
2886
|
+
_flush() {
|
|
2887
|
+
clearTimeout(this._timeout);
|
|
2888
|
+
this._lastFlush = Date.now();
|
|
2889
|
+
this._resolve();
|
|
2890
|
+
this.Events.trigger("batch", this._arr);
|
|
2891
|
+
this._arr = [];
|
|
2892
|
+
return this._resetPromise();
|
|
2893
|
+
}
|
|
2894
|
+
add(data) {
|
|
2895
|
+
var ret;
|
|
2896
|
+
this._arr.push(data);
|
|
2897
|
+
ret = this._promise;
|
|
2898
|
+
if (this._arr.length === this.maxSize) {
|
|
2899
|
+
this._flush();
|
|
2900
|
+
} else if (this.maxTime != null && this._arr.length === 1) {
|
|
2901
|
+
this._timeout = setTimeout(() => {
|
|
2902
|
+
return this._flush();
|
|
2903
|
+
}, this.maxTime);
|
|
2904
|
+
}
|
|
2905
|
+
return ret;
|
|
2906
|
+
}
|
|
2907
|
+
}
|
|
2908
|
+
;
|
|
2909
|
+
Batcher2.prototype.defaults = {
|
|
2910
|
+
maxTime: null,
|
|
2911
|
+
maxSize: null,
|
|
2912
|
+
Promise
|
|
2913
|
+
};
|
|
2914
|
+
return Batcher2;
|
|
2915
|
+
}.call(void 0);
|
|
2916
|
+
module2.exports = Batcher;
|
|
2917
|
+
}
|
|
2918
|
+
});
|
|
2919
|
+
|
|
2920
|
+
// ../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/Bottleneck.js
|
|
2921
|
+
var require_Bottleneck = __commonJS({
|
|
2922
|
+
"../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/Bottleneck.js"(exports2, module2) {
|
|
2923
|
+
"use strict";
|
|
2924
|
+
init_cjs_shims();
|
|
2925
|
+
function _slicedToArray2(arr, i) {
|
|
2926
|
+
return _arrayWithHoles2(arr) || _iterableToArrayLimit2(arr, i) || _nonIterableRest2();
|
|
2927
|
+
}
|
|
2928
|
+
function _iterableToArrayLimit2(arr, i) {
|
|
2929
|
+
var _arr = [];
|
|
2930
|
+
var _n = true;
|
|
2931
|
+
var _d = false;
|
|
2932
|
+
var _e = void 0;
|
|
2933
|
+
try {
|
|
2934
|
+
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
2935
|
+
_arr.push(_s.value);
|
|
2936
|
+
if (i && _arr.length === i)
|
|
2937
|
+
break;
|
|
2938
|
+
}
|
|
2939
|
+
} catch (err) {
|
|
2940
|
+
_d = true;
|
|
2941
|
+
_e = err;
|
|
2942
|
+
} finally {
|
|
2943
|
+
try {
|
|
2944
|
+
if (!_n && _i["return"] != null)
|
|
2945
|
+
_i["return"]();
|
|
2946
|
+
} finally {
|
|
2947
|
+
if (_d)
|
|
2948
|
+
throw _e;
|
|
2949
|
+
}
|
|
2950
|
+
}
|
|
2951
|
+
return _arr;
|
|
2952
|
+
}
|
|
2953
|
+
function _toArray(arr) {
|
|
2954
|
+
return _arrayWithHoles2(arr) || _iterableToArray(arr) || _nonIterableRest2();
|
|
2955
|
+
}
|
|
2956
|
+
function _nonIterableRest2() {
|
|
2957
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
|
2958
|
+
}
|
|
2959
|
+
function _iterableToArray(iter) {
|
|
2960
|
+
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]")
|
|
2961
|
+
return Array.from(iter);
|
|
2962
|
+
}
|
|
2963
|
+
function _arrayWithHoles2(arr) {
|
|
2964
|
+
if (Array.isArray(arr))
|
|
2965
|
+
return arr;
|
|
2966
|
+
}
|
|
2967
|
+
function asyncGeneratorStep2(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2968
|
+
try {
|
|
2969
|
+
var info = gen[key](arg);
|
|
2970
|
+
var value = info.value;
|
|
2971
|
+
} catch (error) {
|
|
2972
|
+
reject(error);
|
|
2973
|
+
return;
|
|
2974
|
+
}
|
|
2975
|
+
if (info.done) {
|
|
2976
|
+
resolve(value);
|
|
2977
|
+
} else {
|
|
2978
|
+
Promise.resolve(value).then(_next, _throw);
|
|
2979
|
+
}
|
|
2980
|
+
}
|
|
2981
|
+
function _asyncToGenerator2(fn) {
|
|
2982
|
+
return function() {
|
|
2983
|
+
var self = this, args = arguments;
|
|
2984
|
+
return new Promise(function(resolve, reject) {
|
|
2985
|
+
var gen = fn.apply(self, args);
|
|
2986
|
+
function _next(value) {
|
|
2987
|
+
asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "next", value);
|
|
2988
|
+
}
|
|
2989
|
+
function _throw(err) {
|
|
2990
|
+
asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "throw", err);
|
|
2991
|
+
}
|
|
2992
|
+
_next(void 0);
|
|
2993
|
+
});
|
|
2994
|
+
};
|
|
2995
|
+
}
|
|
2996
|
+
var Bottleneck;
|
|
2997
|
+
var DEFAULT_PRIORITY;
|
|
2998
|
+
var Events2;
|
|
2999
|
+
var Job;
|
|
3000
|
+
var LocalDatastore;
|
|
3001
|
+
var NUM_PRIORITIES;
|
|
3002
|
+
var Queues;
|
|
3003
|
+
var RedisDatastore;
|
|
3004
|
+
var States;
|
|
3005
|
+
var Sync;
|
|
3006
|
+
var parser2;
|
|
3007
|
+
var splice = [].splice;
|
|
3008
|
+
NUM_PRIORITIES = 10;
|
|
3009
|
+
DEFAULT_PRIORITY = 5;
|
|
3010
|
+
parser2 = require_parser();
|
|
3011
|
+
Queues = require_Queues();
|
|
3012
|
+
Job = require_Job();
|
|
3013
|
+
LocalDatastore = require_LocalDatastore();
|
|
3014
|
+
RedisDatastore = require_RedisDatastore();
|
|
3015
|
+
Events2 = require_Events();
|
|
3016
|
+
States = require_States();
|
|
3017
|
+
Sync = require_Sync();
|
|
3018
|
+
Bottleneck = function() {
|
|
3019
|
+
class Bottleneck2 {
|
|
3020
|
+
constructor(options2 = {}, ...invalid) {
|
|
3021
|
+
var storeInstanceOptions, storeOptions;
|
|
3022
|
+
this._addToQueue = this._addToQueue.bind(this);
|
|
3023
|
+
this._validateOptions(options2, invalid);
|
|
3024
|
+
parser2.load(options2, this.instanceDefaults, this);
|
|
3025
|
+
this._queues = new Queues(NUM_PRIORITIES);
|
|
3026
|
+
this._scheduled = {};
|
|
3027
|
+
this._states = new States(["RECEIVED", "QUEUED", "RUNNING", "EXECUTING"].concat(this.trackDoneStatus ? ["DONE"] : []));
|
|
3028
|
+
this._limiter = null;
|
|
3029
|
+
this.Events = new Events2(this);
|
|
3030
|
+
this._submitLock = new Sync("submit", this.Promise);
|
|
3031
|
+
this._registerLock = new Sync("register", this.Promise);
|
|
3032
|
+
storeOptions = parser2.load(options2, this.storeDefaults, {});
|
|
3033
|
+
this._store = function() {
|
|
3034
|
+
if (this.datastore === "redis" || this.datastore === "ioredis" || this.connection != null) {
|
|
3035
|
+
storeInstanceOptions = parser2.load(options2, this.redisStoreDefaults, {});
|
|
3036
|
+
return new RedisDatastore(this, storeOptions, storeInstanceOptions);
|
|
3037
|
+
} else if (this.datastore === "local") {
|
|
3038
|
+
storeInstanceOptions = parser2.load(options2, this.localStoreDefaults, {});
|
|
3039
|
+
return new LocalDatastore(this, storeOptions, storeInstanceOptions);
|
|
3040
|
+
} else {
|
|
3041
|
+
throw new Bottleneck2.prototype.BottleneckError(`Invalid datastore type: ${this.datastore}`);
|
|
3042
|
+
}
|
|
3043
|
+
}.call(this);
|
|
3044
|
+
this._queues.on("leftzero", () => {
|
|
3045
|
+
var ref;
|
|
3046
|
+
return (ref = this._store.heartbeat) != null ? typeof ref.ref === "function" ? ref.ref() : void 0 : void 0;
|
|
3047
|
+
});
|
|
3048
|
+
this._queues.on("zero", () => {
|
|
3049
|
+
var ref;
|
|
3050
|
+
return (ref = this._store.heartbeat) != null ? typeof ref.unref === "function" ? ref.unref() : void 0 : void 0;
|
|
3051
|
+
});
|
|
3052
|
+
}
|
|
3053
|
+
_validateOptions(options2, invalid) {
|
|
3054
|
+
if (!(options2 != null && typeof options2 === "object" && invalid.length === 0)) {
|
|
3055
|
+
throw new Bottleneck2.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.");
|
|
3056
|
+
}
|
|
3057
|
+
}
|
|
3058
|
+
ready() {
|
|
3059
|
+
return this._store.ready;
|
|
3060
|
+
}
|
|
3061
|
+
clients() {
|
|
3062
|
+
return this._store.clients;
|
|
3063
|
+
}
|
|
3064
|
+
channel() {
|
|
3065
|
+
return `b_${this.id}`;
|
|
3066
|
+
}
|
|
3067
|
+
channel_client() {
|
|
3068
|
+
return `b_${this.id}_${this._store.clientId}`;
|
|
3069
|
+
}
|
|
3070
|
+
publish(message) {
|
|
3071
|
+
return this._store.__publish__(message);
|
|
3072
|
+
}
|
|
3073
|
+
disconnect(flush = true) {
|
|
3074
|
+
return this._store.__disconnect__(flush);
|
|
3075
|
+
}
|
|
3076
|
+
chain(_limiter) {
|
|
3077
|
+
this._limiter = _limiter;
|
|
3078
|
+
return this;
|
|
3079
|
+
}
|
|
3080
|
+
queued(priority) {
|
|
3081
|
+
return this._queues.queued(priority);
|
|
3082
|
+
}
|
|
3083
|
+
clusterQueued() {
|
|
3084
|
+
return this._store.__queued__();
|
|
3085
|
+
}
|
|
3086
|
+
empty() {
|
|
3087
|
+
return this.queued() === 0 && this._submitLock.isEmpty();
|
|
3088
|
+
}
|
|
3089
|
+
running() {
|
|
3090
|
+
return this._store.__running__();
|
|
3091
|
+
}
|
|
3092
|
+
done() {
|
|
3093
|
+
return this._store.__done__();
|
|
3094
|
+
}
|
|
3095
|
+
jobStatus(id) {
|
|
3096
|
+
return this._states.jobStatus(id);
|
|
3097
|
+
}
|
|
3098
|
+
jobs(status) {
|
|
3099
|
+
return this._states.statusJobs(status);
|
|
3100
|
+
}
|
|
3101
|
+
counts() {
|
|
3102
|
+
return this._states.statusCounts();
|
|
3103
|
+
}
|
|
3104
|
+
_randomIndex() {
|
|
3105
|
+
return Math.random().toString(36).slice(2);
|
|
3106
|
+
}
|
|
3107
|
+
check(weight = 1) {
|
|
3108
|
+
return this._store.__check__(weight);
|
|
3109
|
+
}
|
|
3110
|
+
_clearGlobalState(index) {
|
|
3111
|
+
if (this._scheduled[index] != null) {
|
|
3112
|
+
clearTimeout(this._scheduled[index].expiration);
|
|
3113
|
+
delete this._scheduled[index];
|
|
3114
|
+
return true;
|
|
3115
|
+
} else {
|
|
3116
|
+
return false;
|
|
3117
|
+
}
|
|
3118
|
+
}
|
|
3119
|
+
_free(index, job, options2, eventInfo) {
|
|
3120
|
+
var _this = this;
|
|
3121
|
+
return _asyncToGenerator2(function* () {
|
|
3122
|
+
var e, running;
|
|
3123
|
+
try {
|
|
3124
|
+
var _ref = yield _this._store.__free__(index, options2.weight);
|
|
3125
|
+
running = _ref.running;
|
|
3126
|
+
_this.Events.trigger("debug", `Freed ${options2.id}`, eventInfo);
|
|
3127
|
+
if (running === 0 && _this.empty()) {
|
|
3128
|
+
return _this.Events.trigger("idle");
|
|
3129
|
+
}
|
|
3130
|
+
} catch (error1) {
|
|
3131
|
+
e = error1;
|
|
3132
|
+
return _this.Events.trigger("error", e);
|
|
3133
|
+
}
|
|
3134
|
+
})();
|
|
3135
|
+
}
|
|
3136
|
+
_run(index, job, wait) {
|
|
3137
|
+
var clearGlobalState, free, run;
|
|
3138
|
+
job.doRun();
|
|
3139
|
+
clearGlobalState = this._clearGlobalState.bind(this, index);
|
|
3140
|
+
run = this._run.bind(this, index, job);
|
|
3141
|
+
free = this._free.bind(this, index, job);
|
|
3142
|
+
return this._scheduled[index] = {
|
|
3143
|
+
timeout: setTimeout(() => {
|
|
3144
|
+
return job.doExecute(this._limiter, clearGlobalState, run, free);
|
|
3145
|
+
}, wait),
|
|
3146
|
+
expiration: job.options.expiration != null ? setTimeout(function() {
|
|
3147
|
+
return job.doExpire(clearGlobalState, run, free);
|
|
3148
|
+
}, wait + job.options.expiration) : void 0,
|
|
3149
|
+
job
|
|
3150
|
+
};
|
|
3151
|
+
}
|
|
3152
|
+
_drainOne(capacity) {
|
|
3153
|
+
return this._registerLock.schedule(() => {
|
|
3154
|
+
var args, index, next, options2, queue;
|
|
3155
|
+
if (this.queued() === 0) {
|
|
3156
|
+
return this.Promise.resolve(null);
|
|
3157
|
+
}
|
|
3158
|
+
queue = this._queues.getFirst();
|
|
3159
|
+
var _next2 = next = queue.first();
|
|
3160
|
+
options2 = _next2.options;
|
|
3161
|
+
args = _next2.args;
|
|
3162
|
+
if (capacity != null && options2.weight > capacity) {
|
|
3163
|
+
return this.Promise.resolve(null);
|
|
3164
|
+
}
|
|
3165
|
+
this.Events.trigger("debug", `Draining ${options2.id}`, {
|
|
3166
|
+
args,
|
|
3167
|
+
options: options2
|
|
3168
|
+
});
|
|
3169
|
+
index = this._randomIndex();
|
|
3170
|
+
return this._store.__register__(index, options2.weight, options2.expiration).then(({
|
|
3171
|
+
success,
|
|
3172
|
+
wait,
|
|
3173
|
+
reservoir
|
|
3174
|
+
}) => {
|
|
3175
|
+
var empty;
|
|
3176
|
+
this.Events.trigger("debug", `Drained ${options2.id}`, {
|
|
3177
|
+
success,
|
|
3178
|
+
args,
|
|
3179
|
+
options: options2
|
|
3180
|
+
});
|
|
3181
|
+
if (success) {
|
|
3182
|
+
queue.shift();
|
|
3183
|
+
empty = this.empty();
|
|
3184
|
+
if (empty) {
|
|
3185
|
+
this.Events.trigger("empty");
|
|
3186
|
+
}
|
|
3187
|
+
if (reservoir === 0) {
|
|
3188
|
+
this.Events.trigger("depleted", empty);
|
|
3189
|
+
}
|
|
3190
|
+
this._run(index, next, wait);
|
|
3191
|
+
return this.Promise.resolve(options2.weight);
|
|
3192
|
+
} else {
|
|
3193
|
+
return this.Promise.resolve(null);
|
|
3194
|
+
}
|
|
3195
|
+
});
|
|
3196
|
+
});
|
|
3197
|
+
}
|
|
3198
|
+
_drainAll(capacity, total = 0) {
|
|
3199
|
+
return this._drainOne(capacity).then((drained) => {
|
|
3200
|
+
var newCapacity;
|
|
3201
|
+
if (drained != null) {
|
|
3202
|
+
newCapacity = capacity != null ? capacity - drained : capacity;
|
|
3203
|
+
return this._drainAll(newCapacity, total + drained);
|
|
3204
|
+
} else {
|
|
3205
|
+
return this.Promise.resolve(total);
|
|
3206
|
+
}
|
|
3207
|
+
}).catch((e) => {
|
|
3208
|
+
return this.Events.trigger("error", e);
|
|
3209
|
+
});
|
|
3210
|
+
}
|
|
3211
|
+
_dropAllQueued(message) {
|
|
3212
|
+
return this._queues.shiftAll(function(job) {
|
|
3213
|
+
return job.doDrop({
|
|
3214
|
+
message
|
|
3215
|
+
});
|
|
3216
|
+
});
|
|
3217
|
+
}
|
|
3218
|
+
stop(options2 = {}) {
|
|
3219
|
+
var done, waitForExecuting;
|
|
3220
|
+
options2 = parser2.load(options2, this.stopDefaults);
|
|
3221
|
+
waitForExecuting = (at) => {
|
|
3222
|
+
var finished;
|
|
3223
|
+
finished = () => {
|
|
3224
|
+
var counts;
|
|
3225
|
+
counts = this._states.counts;
|
|
3226
|
+
return counts[0] + counts[1] + counts[2] + counts[3] === at;
|
|
3227
|
+
};
|
|
3228
|
+
return new this.Promise((resolve, reject) => {
|
|
3229
|
+
if (finished()) {
|
|
3230
|
+
return resolve();
|
|
3231
|
+
} else {
|
|
3232
|
+
return this.on("done", () => {
|
|
3233
|
+
if (finished()) {
|
|
3234
|
+
this.removeAllListeners("done");
|
|
3235
|
+
return resolve();
|
|
3236
|
+
}
|
|
3237
|
+
});
|
|
3238
|
+
}
|
|
3239
|
+
});
|
|
3240
|
+
};
|
|
3241
|
+
done = options2.dropWaitingJobs ? (this._run = function(index, next) {
|
|
3242
|
+
return next.doDrop({
|
|
3243
|
+
message: options2.dropErrorMessage
|
|
3244
|
+
});
|
|
3245
|
+
}, this._drainOne = () => {
|
|
3246
|
+
return this.Promise.resolve(null);
|
|
3247
|
+
}, this._registerLock.schedule(() => {
|
|
3248
|
+
return this._submitLock.schedule(() => {
|
|
3249
|
+
var k, ref, v;
|
|
3250
|
+
ref = this._scheduled;
|
|
3251
|
+
for (k in ref) {
|
|
3252
|
+
v = ref[k];
|
|
3253
|
+
if (this.jobStatus(v.job.options.id) === "RUNNING") {
|
|
3254
|
+
clearTimeout(v.timeout);
|
|
3255
|
+
clearTimeout(v.expiration);
|
|
3256
|
+
v.job.doDrop({
|
|
3257
|
+
message: options2.dropErrorMessage
|
|
3258
|
+
});
|
|
3259
|
+
}
|
|
3260
|
+
}
|
|
3261
|
+
this._dropAllQueued(options2.dropErrorMessage);
|
|
3262
|
+
return waitForExecuting(0);
|
|
3263
|
+
});
|
|
3264
|
+
})) : this.schedule({
|
|
3265
|
+
priority: NUM_PRIORITIES - 1,
|
|
3266
|
+
weight: 0
|
|
3267
|
+
}, () => {
|
|
3268
|
+
return waitForExecuting(1);
|
|
3269
|
+
});
|
|
3270
|
+
this._receive = function(job) {
|
|
3271
|
+
return job._reject(new Bottleneck2.prototype.BottleneckError(options2.enqueueErrorMessage));
|
|
3272
|
+
};
|
|
3273
|
+
this.stop = () => {
|
|
3274
|
+
return this.Promise.reject(new Bottleneck2.prototype.BottleneckError("stop() has already been called"));
|
|
3275
|
+
};
|
|
3276
|
+
return done;
|
|
3277
|
+
}
|
|
3278
|
+
_addToQueue(job) {
|
|
3279
|
+
var _this2 = this;
|
|
3280
|
+
return _asyncToGenerator2(function* () {
|
|
3281
|
+
var args, blocked, error, options2, reachedHWM, shifted, strategy;
|
|
3282
|
+
args = job.args;
|
|
3283
|
+
options2 = job.options;
|
|
3284
|
+
try {
|
|
3285
|
+
var _ref2 = yield _this2._store.__submit__(_this2.queued(), options2.weight);
|
|
3286
|
+
reachedHWM = _ref2.reachedHWM;
|
|
3287
|
+
blocked = _ref2.blocked;
|
|
3288
|
+
strategy = _ref2.strategy;
|
|
3289
|
+
} catch (error1) {
|
|
3290
|
+
error = error1;
|
|
3291
|
+
_this2.Events.trigger("debug", `Could not queue ${options2.id}`, {
|
|
3292
|
+
args,
|
|
3293
|
+
options: options2,
|
|
3294
|
+
error
|
|
3295
|
+
});
|
|
3296
|
+
job.doDrop({
|
|
3297
|
+
error
|
|
3298
|
+
});
|
|
3299
|
+
return false;
|
|
3300
|
+
}
|
|
3301
|
+
if (blocked) {
|
|
3302
|
+
job.doDrop();
|
|
3303
|
+
return true;
|
|
3304
|
+
} else if (reachedHWM) {
|
|
3305
|
+
shifted = strategy === Bottleneck2.prototype.strategy.LEAK ? _this2._queues.shiftLastFrom(options2.priority) : strategy === Bottleneck2.prototype.strategy.OVERFLOW_PRIORITY ? _this2._queues.shiftLastFrom(options2.priority + 1) : strategy === Bottleneck2.prototype.strategy.OVERFLOW ? job : void 0;
|
|
3306
|
+
if (shifted != null) {
|
|
3307
|
+
shifted.doDrop();
|
|
3308
|
+
}
|
|
3309
|
+
if (shifted == null || strategy === Bottleneck2.prototype.strategy.OVERFLOW) {
|
|
3310
|
+
if (shifted == null) {
|
|
3311
|
+
job.doDrop();
|
|
3312
|
+
}
|
|
3313
|
+
return reachedHWM;
|
|
3314
|
+
}
|
|
3315
|
+
}
|
|
3316
|
+
job.doQueue(reachedHWM, blocked);
|
|
3317
|
+
_this2._queues.push(job);
|
|
3318
|
+
yield _this2._drainAll();
|
|
3319
|
+
return reachedHWM;
|
|
3320
|
+
})();
|
|
3321
|
+
}
|
|
3322
|
+
_receive(job) {
|
|
3323
|
+
if (this._states.jobStatus(job.options.id) != null) {
|
|
3324
|
+
job._reject(new Bottleneck2.prototype.BottleneckError(`A job with the same id already exists (id=${job.options.id})`));
|
|
3325
|
+
return false;
|
|
3326
|
+
} else {
|
|
3327
|
+
job.doReceive();
|
|
3328
|
+
return this._submitLock.schedule(this._addToQueue, job);
|
|
3329
|
+
}
|
|
3330
|
+
}
|
|
3331
|
+
submit(...args) {
|
|
3332
|
+
var cb, fn, job, options2, ref, ref1, task;
|
|
3333
|
+
if (typeof args[0] === "function") {
|
|
3334
|
+
var _ref3, _ref4, _splice$call, _splice$call2;
|
|
3335
|
+
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;
|
|
3336
|
+
options2 = parser2.load({}, this.jobDefaults);
|
|
3337
|
+
} else {
|
|
3338
|
+
var _ref5, _ref6, _splice$call3, _splice$call4;
|
|
3339
|
+
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;
|
|
3340
|
+
options2 = parser2.load(options2, this.jobDefaults);
|
|
3341
|
+
}
|
|
3342
|
+
task = (...args2) => {
|
|
3343
|
+
return new this.Promise(function(resolve, reject) {
|
|
3344
|
+
return fn(...args2, function(...args3) {
|
|
3345
|
+
return (args3[0] != null ? reject : resolve)(args3);
|
|
3346
|
+
});
|
|
3347
|
+
});
|
|
3348
|
+
};
|
|
3349
|
+
job = new Job(task, args, options2, this.jobDefaults, this.rejectOnDrop, this.Events, this._states, this.Promise);
|
|
3350
|
+
job.promise.then(function(args2) {
|
|
3351
|
+
return typeof cb === "function" ? cb(...args2) : void 0;
|
|
3352
|
+
}).catch(function(args2) {
|
|
3353
|
+
if (Array.isArray(args2)) {
|
|
3354
|
+
return typeof cb === "function" ? cb(...args2) : void 0;
|
|
3355
|
+
} else {
|
|
3356
|
+
return typeof cb === "function" ? cb(args2) : void 0;
|
|
3357
|
+
}
|
|
3358
|
+
});
|
|
3359
|
+
return this._receive(job);
|
|
3360
|
+
}
|
|
3361
|
+
schedule(...args) {
|
|
3362
|
+
var job, options2, task;
|
|
3363
|
+
if (typeof args[0] === "function") {
|
|
3364
|
+
var _args = args;
|
|
3365
|
+
var _args2 = _toArray(_args);
|
|
3366
|
+
task = _args2[0];
|
|
3367
|
+
args = _args2.slice(1);
|
|
3368
|
+
options2 = {};
|
|
3369
|
+
} else {
|
|
3370
|
+
var _args3 = args;
|
|
3371
|
+
var _args4 = _toArray(_args3);
|
|
3372
|
+
options2 = _args4[0];
|
|
3373
|
+
task = _args4[1];
|
|
3374
|
+
args = _args4.slice(2);
|
|
3375
|
+
}
|
|
3376
|
+
job = new Job(task, args, options2, this.jobDefaults, this.rejectOnDrop, this.Events, this._states, this.Promise);
|
|
3377
|
+
this._receive(job);
|
|
3378
|
+
return job.promise;
|
|
3379
|
+
}
|
|
3380
|
+
wrap(fn) {
|
|
3381
|
+
var schedule, wrapped;
|
|
3382
|
+
schedule = this.schedule.bind(this);
|
|
3383
|
+
wrapped = function wrapped2(...args) {
|
|
3384
|
+
return schedule(fn.bind(this), ...args);
|
|
3385
|
+
};
|
|
3386
|
+
wrapped.withOptions = function(options2, ...args) {
|
|
3387
|
+
return schedule(options2, fn, ...args);
|
|
3388
|
+
};
|
|
3389
|
+
return wrapped;
|
|
3390
|
+
}
|
|
3391
|
+
updateSettings(options2 = {}) {
|
|
3392
|
+
var _this3 = this;
|
|
3393
|
+
return _asyncToGenerator2(function* () {
|
|
3394
|
+
yield _this3._store.__updateSettings__(parser2.overwrite(options2, _this3.storeDefaults));
|
|
3395
|
+
parser2.overwrite(options2, _this3.instanceDefaults, _this3);
|
|
3396
|
+
return _this3;
|
|
3397
|
+
})();
|
|
3398
|
+
}
|
|
3399
|
+
currentReservoir() {
|
|
3400
|
+
return this._store.__currentReservoir__();
|
|
3401
|
+
}
|
|
3402
|
+
incrementReservoir(incr = 0) {
|
|
3403
|
+
return this._store.__incrementReservoir__(incr);
|
|
3404
|
+
}
|
|
3405
|
+
}
|
|
3406
|
+
;
|
|
3407
|
+
Bottleneck2.default = Bottleneck2;
|
|
3408
|
+
Bottleneck2.Events = Events2;
|
|
3409
|
+
Bottleneck2.version = Bottleneck2.prototype.version = require_version().version;
|
|
3410
|
+
Bottleneck2.strategy = Bottleneck2.prototype.strategy = {
|
|
3411
|
+
LEAK: 1,
|
|
3412
|
+
OVERFLOW: 2,
|
|
3413
|
+
OVERFLOW_PRIORITY: 4,
|
|
3414
|
+
BLOCK: 3
|
|
3415
|
+
};
|
|
3416
|
+
Bottleneck2.BottleneckError = Bottleneck2.prototype.BottleneckError = require_BottleneckError();
|
|
3417
|
+
Bottleneck2.Group = Bottleneck2.prototype.Group = require_Group();
|
|
3418
|
+
Bottleneck2.RedisConnection = Bottleneck2.prototype.RedisConnection = require_RedisConnection();
|
|
3419
|
+
Bottleneck2.IORedisConnection = Bottleneck2.prototype.IORedisConnection = require_IORedisConnection();
|
|
3420
|
+
Bottleneck2.Batcher = Bottleneck2.prototype.Batcher = require_Batcher();
|
|
3421
|
+
Bottleneck2.prototype.jobDefaults = {
|
|
3422
|
+
priority: DEFAULT_PRIORITY,
|
|
3423
|
+
weight: 1,
|
|
3424
|
+
expiration: null,
|
|
3425
|
+
id: "<no-id>"
|
|
3426
|
+
};
|
|
3427
|
+
Bottleneck2.prototype.storeDefaults = {
|
|
3428
|
+
maxConcurrent: null,
|
|
3429
|
+
minTime: 0,
|
|
3430
|
+
highWater: null,
|
|
3431
|
+
strategy: Bottleneck2.prototype.strategy.LEAK,
|
|
3432
|
+
penalty: null,
|
|
3433
|
+
reservoir: null,
|
|
3434
|
+
reservoirRefreshInterval: null,
|
|
3435
|
+
reservoirRefreshAmount: null,
|
|
3436
|
+
reservoirIncreaseInterval: null,
|
|
3437
|
+
reservoirIncreaseAmount: null,
|
|
3438
|
+
reservoirIncreaseMaximum: null
|
|
3439
|
+
};
|
|
3440
|
+
Bottleneck2.prototype.localStoreDefaults = {
|
|
3441
|
+
Promise,
|
|
3442
|
+
timeout: null,
|
|
3443
|
+
heartbeatInterval: 250
|
|
3444
|
+
};
|
|
3445
|
+
Bottleneck2.prototype.redisStoreDefaults = {
|
|
3446
|
+
Promise,
|
|
3447
|
+
timeout: null,
|
|
3448
|
+
heartbeatInterval: 5e3,
|
|
3449
|
+
clientTimeout: 1e4,
|
|
3450
|
+
Redis: null,
|
|
3451
|
+
clientOptions: {},
|
|
3452
|
+
clusterNodes: null,
|
|
3453
|
+
clearDatastore: false,
|
|
3454
|
+
connection: null
|
|
3455
|
+
};
|
|
3456
|
+
Bottleneck2.prototype.instanceDefaults = {
|
|
3457
|
+
datastore: "local",
|
|
3458
|
+
connection: null,
|
|
3459
|
+
id: "<no-id>",
|
|
3460
|
+
rejectOnDrop: true,
|
|
3461
|
+
trackDoneStatus: false,
|
|
3462
|
+
Promise
|
|
3463
|
+
};
|
|
3464
|
+
Bottleneck2.prototype.stopDefaults = {
|
|
3465
|
+
enqueueErrorMessage: "This limiter has been stopped and cannot accept new jobs.",
|
|
3466
|
+
dropWaitingJobs: true,
|
|
3467
|
+
dropErrorMessage: "This limiter has been stopped."
|
|
3468
|
+
};
|
|
3469
|
+
return Bottleneck2;
|
|
3470
|
+
}.call(void 0);
|
|
3471
|
+
module2.exports = Bottleneck;
|
|
3472
|
+
}
|
|
3473
|
+
});
|
|
3474
|
+
|
|
3475
|
+
// ../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/index.js
|
|
3476
|
+
var require_lib = __commonJS({
|
|
3477
|
+
"../../node_modules/.pnpm/bottleneck@2.19.5/node_modules/bottleneck/lib/index.js"(exports2, module2) {
|
|
3478
|
+
"use strict";
|
|
3479
|
+
init_cjs_shims();
|
|
3480
|
+
module2.exports = require_Bottleneck();
|
|
3481
|
+
}
|
|
3482
|
+
});
|
|
3483
|
+
|
|
3484
|
+
// ../../node_modules/.pnpm/get-port-please@3.0.1/node_modules/get-port-please/dist/index.mjs
|
|
3485
|
+
init_cjs_shims();
|
|
3486
|
+
import { createServer } from "node:net";
|
|
3487
|
+
import { networkInterfaces } from "node:os";
|
|
3488
|
+
var unsafePorts = /* @__PURE__ */ new Set([
|
|
3489
|
+
1,
|
|
3490
|
+
7,
|
|
3491
|
+
9,
|
|
3492
|
+
11,
|
|
3493
|
+
13,
|
|
3494
|
+
15,
|
|
3495
|
+
17,
|
|
3496
|
+
19,
|
|
3497
|
+
20,
|
|
3498
|
+
21,
|
|
3499
|
+
22,
|
|
3500
|
+
23,
|
|
3501
|
+
25,
|
|
3502
|
+
37,
|
|
3503
|
+
42,
|
|
3504
|
+
43,
|
|
3505
|
+
53,
|
|
3506
|
+
69,
|
|
3507
|
+
77,
|
|
3508
|
+
79,
|
|
3509
|
+
87,
|
|
3510
|
+
95,
|
|
3511
|
+
101,
|
|
3512
|
+
102,
|
|
3513
|
+
103,
|
|
3514
|
+
104,
|
|
3515
|
+
109,
|
|
3516
|
+
110,
|
|
3517
|
+
111,
|
|
3518
|
+
113,
|
|
3519
|
+
115,
|
|
3520
|
+
117,
|
|
3521
|
+
119,
|
|
3522
|
+
123,
|
|
3523
|
+
135,
|
|
3524
|
+
137,
|
|
3525
|
+
139,
|
|
3526
|
+
143,
|
|
3527
|
+
161,
|
|
3528
|
+
179,
|
|
3529
|
+
389,
|
|
3530
|
+
427,
|
|
3531
|
+
465,
|
|
3532
|
+
512,
|
|
3533
|
+
513,
|
|
3534
|
+
514,
|
|
3535
|
+
515,
|
|
3536
|
+
526,
|
|
3537
|
+
530,
|
|
3538
|
+
531,
|
|
3539
|
+
532,
|
|
3540
|
+
540,
|
|
3541
|
+
548,
|
|
3542
|
+
554,
|
|
3543
|
+
556,
|
|
3544
|
+
563,
|
|
3545
|
+
587,
|
|
3546
|
+
601,
|
|
3547
|
+
636,
|
|
3548
|
+
989,
|
|
3549
|
+
990,
|
|
3550
|
+
993,
|
|
3551
|
+
995,
|
|
3552
|
+
1719,
|
|
3553
|
+
1720,
|
|
3554
|
+
1723,
|
|
3555
|
+
2049,
|
|
3556
|
+
3659,
|
|
3557
|
+
4045,
|
|
3558
|
+
5060,
|
|
3559
|
+
5061,
|
|
3560
|
+
6e3,
|
|
3561
|
+
6566,
|
|
3562
|
+
6665,
|
|
3563
|
+
6666,
|
|
3564
|
+
6667,
|
|
3565
|
+
6668,
|
|
3566
|
+
6669,
|
|
3567
|
+
6697,
|
|
3568
|
+
10080
|
|
3569
|
+
]);
|
|
3570
|
+
function isUnsafePort(port) {
|
|
3571
|
+
return unsafePorts.has(port);
|
|
3572
|
+
}
|
|
3573
|
+
function isSafePort(port) {
|
|
3574
|
+
return !isUnsafePort(port);
|
|
3575
|
+
}
|
|
3576
|
+
function log(...arguments_) {
|
|
3577
|
+
console.log("[get-port]", ...arguments_);
|
|
3578
|
+
}
|
|
3579
|
+
async function getRandomPort(host) {
|
|
3580
|
+
const port = await checkPort(0, host);
|
|
3581
|
+
if (port === false) {
|
|
3582
|
+
throw new Error("Unable to obtain an available random port number!");
|
|
3583
|
+
}
|
|
3584
|
+
return port;
|
|
3585
|
+
}
|
|
3586
|
+
async function checkPort(port, host = process.env.HOST, _verbose) {
|
|
3587
|
+
if (!host) {
|
|
3588
|
+
host = getLocalHosts([void 0, "0.0.0.0"]);
|
|
3589
|
+
}
|
|
3590
|
+
if (!Array.isArray(host)) {
|
|
3591
|
+
return _checkPort(port, host);
|
|
3592
|
+
}
|
|
3593
|
+
for (const _host of host) {
|
|
3594
|
+
const _port = await _checkPort(port, _host);
|
|
3595
|
+
if (_port === false) {
|
|
3596
|
+
if (port < 1024 && _verbose) {
|
|
3597
|
+
log("Unable to listen to priviliged port:", `${_host}:${port}`);
|
|
3598
|
+
}
|
|
3599
|
+
return false;
|
|
3600
|
+
}
|
|
3601
|
+
if (port === 0 && _port !== 0) {
|
|
3602
|
+
port = _port;
|
|
3603
|
+
}
|
|
3604
|
+
}
|
|
3605
|
+
return port;
|
|
3606
|
+
}
|
|
3607
|
+
function _checkPort(port, host) {
|
|
3608
|
+
return new Promise((resolve) => {
|
|
3609
|
+
const server = createServer();
|
|
3610
|
+
server.unref();
|
|
3611
|
+
server.on("error", (error) => {
|
|
3612
|
+
if (error.code === "EINVAL" || error.code === "EADDRNOTAVAIL") {
|
|
3613
|
+
resolve(port !== 0 && isSafePort(port) && port);
|
|
3614
|
+
} else {
|
|
3615
|
+
resolve(false);
|
|
3616
|
+
}
|
|
3617
|
+
});
|
|
3618
|
+
server.listen({ port, host }, () => {
|
|
3619
|
+
const { port: port2 } = server.address();
|
|
3620
|
+
server.close(() => {
|
|
3621
|
+
resolve(isSafePort(port2) && port2);
|
|
3622
|
+
});
|
|
3623
|
+
});
|
|
3624
|
+
});
|
|
3625
|
+
}
|
|
3626
|
+
function getLocalHosts(additional) {
|
|
3627
|
+
const hosts = new Set(additional);
|
|
3628
|
+
for (const _interface of Object.values(networkInterfaces())) {
|
|
3629
|
+
for (const config of _interface || []) {
|
|
3630
|
+
hosts.add(config.address);
|
|
3631
|
+
}
|
|
3632
|
+
}
|
|
3633
|
+
return [...hosts];
|
|
3634
|
+
}
|
|
3635
|
+
|
|
3636
|
+
export {
|
|
3637
|
+
getRandomPort,
|
|
3638
|
+
checkPort,
|
|
3639
|
+
require_find_process2 as require_find_process,
|
|
3640
|
+
require_lib
|
|
3641
|
+
};
|
|
3642
|
+
//# sourceMappingURL=chunk-EQPYUHNM.js.map
|