sqlite-executor 4.0.5 → 4.0.7
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/cjs/core/inflightTracker.d.cts +33 -0
- package/dist/cjs/core/lruCache.d.cts +8 -1
- package/dist/cjs/core/metrics.d.cts +4 -4
- package/dist/cjs/core/pipelineUtils.d.cts +196 -0
- package/dist/cjs/core/readerPool.d.cts +2 -2
- package/dist/cjs/index.cjs +1366 -979
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/utils/interpolate.d.cts +11 -0
- package/dist/cjs/utils/normalize.d.cts +24 -0
- package/dist/cjs/utils/timeout.d.cts +2 -1
- package/dist/esm/core/inflightTracker.d.mts +33 -0
- package/dist/esm/core/lruCache.d.mts +8 -1
- package/dist/esm/core/metrics.d.mts +4 -4
- package/dist/esm/core/pipelineUtils.d.mts +196 -0
- package/dist/esm/core/readerPool.d.mts +2 -2
- package/dist/esm/index.mjs +1368 -981
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/utils/interpolate.d.mts +11 -0
- package/dist/esm/utils/normalize.d.mts +24 -0
- package/dist/esm/utils/timeout.d.mts +2 -1
- package/package.json +31 -1
package/dist/esm/index.mjs
CHANGED
|
@@ -1,220 +1,11 @@
|
|
|
1
|
-
import * as __WEBPACK_EXTERNAL_MODULE_node_events_0a6aefe7__ from "node:events";
|
|
2
1
|
import * as __WEBPACK_EXTERNAL_MODULE_node_child_process_27f17141__ from "node:child_process";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_events_0a6aefe7__ from "node:events";
|
|
3
3
|
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
|
|
4
4
|
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
5
5
|
import * as __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__ from "node:os";
|
|
6
|
-
function _check_private_redeclaration(obj, privateCollection) {
|
|
7
|
-
if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
8
|
-
}
|
|
9
|
-
function _class_apply_descriptor_get(receiver, descriptor) {
|
|
10
|
-
if (descriptor.get) return descriptor.get.call(receiver);
|
|
11
|
-
return descriptor.value;
|
|
12
|
-
}
|
|
13
|
-
function _class_apply_descriptor_set(receiver, descriptor, value) {
|
|
14
|
-
if (descriptor.set) descriptor.set.call(receiver, value);
|
|
15
|
-
else {
|
|
16
|
-
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
17
|
-
descriptor.value = value;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
function _class_call_check(instance, Constructor) {
|
|
21
|
-
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
22
|
-
}
|
|
23
|
-
function _class_extract_field_descriptor(receiver, privateMap, action) {
|
|
24
|
-
if (!privateMap.has(receiver)) throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
25
|
-
return privateMap.get(receiver);
|
|
26
|
-
}
|
|
27
|
-
function _class_private_field_get(receiver, privateMap) {
|
|
28
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
|
|
29
|
-
return _class_apply_descriptor_get(receiver, descriptor);
|
|
30
|
-
}
|
|
31
|
-
function _class_private_field_init(obj, privateMap, value) {
|
|
32
|
-
_check_private_redeclaration(obj, privateMap);
|
|
33
|
-
privateMap.set(obj, value);
|
|
34
|
-
}
|
|
35
|
-
function _class_private_field_set(receiver, privateMap, value) {
|
|
36
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
|
|
37
|
-
_class_apply_descriptor_set(receiver, descriptor, value);
|
|
38
|
-
return value;
|
|
39
|
-
}
|
|
40
|
-
function _defineProperties(target, props) {
|
|
41
|
-
for(var i = 0; i < props.length; i++){
|
|
42
|
-
var descriptor = props[i];
|
|
43
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
44
|
-
descriptor.configurable = true;
|
|
45
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
46
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
function _create_class(Constructor, protoProps, staticProps) {
|
|
50
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
51
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
52
|
-
return Constructor;
|
|
53
|
-
}
|
|
54
|
-
var _maxSize = /*#__PURE__*/ new WeakMap(), _maxKeyLength = /*#__PURE__*/ new WeakMap(), _map = /*#__PURE__*/ new WeakMap();
|
|
55
|
-
var lruCache_LRUCache = /*#__PURE__*/ function() {
|
|
56
|
-
"use strict";
|
|
57
|
-
function LRUCache() {
|
|
58
|
-
var _ref = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, _ref_maxSize = _ref.maxSize, maxSize = void 0 === _ref_maxSize ? 256 : _ref_maxSize, _ref_maxKeyLength = _ref.maxKeyLength, maxKeyLength = void 0 === _ref_maxKeyLength ? 4096 : _ref_maxKeyLength;
|
|
59
|
-
_class_call_check(this, LRUCache);
|
|
60
|
-
_class_private_field_init(this, _maxSize, {
|
|
61
|
-
writable: true,
|
|
62
|
-
value: void 0
|
|
63
|
-
});
|
|
64
|
-
_class_private_field_init(this, _maxKeyLength, {
|
|
65
|
-
writable: true,
|
|
66
|
-
value: void 0
|
|
67
|
-
});
|
|
68
|
-
_class_private_field_init(this, _map, {
|
|
69
|
-
writable: true,
|
|
70
|
-
value: new Map()
|
|
71
|
-
});
|
|
72
|
-
_class_private_field_set(this, _maxSize, Math.max(1, maxSize));
|
|
73
|
-
_class_private_field_set(this, _maxKeyLength, maxKeyLength);
|
|
74
|
-
}
|
|
75
|
-
_create_class(LRUCache, [
|
|
76
|
-
{
|
|
77
|
-
key: "get",
|
|
78
|
-
value: function(key) {
|
|
79
|
-
if ("string" != typeof key || key.length > _class_private_field_get(this, _maxKeyLength)) return;
|
|
80
|
-
var value = _class_private_field_get(this, _map).get(key);
|
|
81
|
-
if (void 0 === value) return;
|
|
82
|
-
_class_private_field_get(this, _map)["delete"](key);
|
|
83
|
-
_class_private_field_get(this, _map).set(key, value);
|
|
84
|
-
return value;
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
key: "set",
|
|
89
|
-
value: function(key, value) {
|
|
90
|
-
if ("string" != typeof key || key.length > _class_private_field_get(this, _maxKeyLength)) return;
|
|
91
|
-
if (_class_private_field_get(this, _map).size >= _class_private_field_get(this, _maxSize)) {
|
|
92
|
-
var firstKey = _class_private_field_get(this, _map).keys().next().value;
|
|
93
|
-
_class_private_field_get(this, _map)["delete"](firstKey);
|
|
94
|
-
}
|
|
95
|
-
_class_private_field_get(this, _map).set(key, value);
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
key: "size",
|
|
100
|
-
get: function() {
|
|
101
|
-
return _class_private_field_get(this, _map).size;
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
key: "clear",
|
|
106
|
-
value: function() {
|
|
107
|
-
_class_private_field_get(this, _map).clear();
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
]);
|
|
111
|
-
return LRUCache;
|
|
112
|
-
}();
|
|
113
|
-
var CC_SINGLE_QUOTE = 39;
|
|
114
|
-
var CC_DOUBLE_QUOTE = 34;
|
|
115
|
-
var CC_DASH = 45;
|
|
116
|
-
var CC_SLASH = 47;
|
|
117
|
-
var CC_STAR = 42;
|
|
118
|
-
var CC_NEWLINE = 10;
|
|
119
|
-
var CC_QUESTION = 63;
|
|
120
|
-
var CC_SEMICOLON = 59;
|
|
121
|
-
var CC_SPACE = 32;
|
|
122
|
-
var STATE_NORMAL = 0;
|
|
123
|
-
var STATE_SINGLE_QUOTE = 1;
|
|
124
|
-
var STATE_DOUBLE_QUOTE = 2;
|
|
125
|
-
var STATE_LINE_COMMENT = 3;
|
|
126
|
-
var STATE_BLOCK_COMMENT = 4;
|
|
127
|
-
var _normBuf = new Uint16Array(1024);
|
|
128
|
-
var _normDecoder = new TextDecoder("utf-16le");
|
|
129
|
-
var _normCache = new lruCache_LRUCache({
|
|
130
|
-
maxSize: 256,
|
|
131
|
-
maxKeyLength: 4096
|
|
132
|
-
});
|
|
133
|
-
function normalizeSQL(sql) {
|
|
134
|
-
var cached = _normCache.get(sql);
|
|
135
|
-
if (void 0 !== cached) return cached;
|
|
136
|
-
var len = sql.length;
|
|
137
|
-
var needed = len + 1;
|
|
138
|
-
if (_normBuf.length < needed) _normBuf = new Uint16Array(needed);
|
|
139
|
-
var outCodes = _normBuf;
|
|
140
|
-
var writePos = 0;
|
|
141
|
-
var pendingSpace = false;
|
|
142
|
-
var state = STATE_NORMAL;
|
|
143
|
-
for(var i = 0; i < len; i++){
|
|
144
|
-
var code = sql.charCodeAt(i);
|
|
145
|
-
var nextCode = sql.charCodeAt(i + 1);
|
|
146
|
-
if (state === STATE_BLOCK_COMMENT) {
|
|
147
|
-
if (code === CC_STAR && nextCode === CC_SLASH) {
|
|
148
|
-
state = STATE_NORMAL;
|
|
149
|
-
i++;
|
|
150
|
-
if (writePos > 0) pendingSpace = true;
|
|
151
|
-
}
|
|
152
|
-
continue;
|
|
153
|
-
}
|
|
154
|
-
if (state === STATE_LINE_COMMENT) {
|
|
155
|
-
if (code === CC_NEWLINE) {
|
|
156
|
-
state = STATE_NORMAL;
|
|
157
|
-
if (writePos > 0) pendingSpace = true;
|
|
158
|
-
}
|
|
159
|
-
continue;
|
|
160
|
-
}
|
|
161
|
-
if (state === STATE_NORMAL) {
|
|
162
|
-
if (code === CC_DASH && nextCode === CC_DASH) {
|
|
163
|
-
state = STATE_LINE_COMMENT;
|
|
164
|
-
i++;
|
|
165
|
-
continue;
|
|
166
|
-
}
|
|
167
|
-
if (code === CC_SLASH && nextCode === CC_STAR) {
|
|
168
|
-
state = STATE_BLOCK_COMMENT;
|
|
169
|
-
i++;
|
|
170
|
-
continue;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
if (32 === code || 9 === code || 10 === code || 11 === code || 12 === code || 13 === code) {
|
|
174
|
-
if (writePos > 0) pendingSpace = true;
|
|
175
|
-
continue;
|
|
176
|
-
}
|
|
177
|
-
if (pendingSpace && writePos > 0) {
|
|
178
|
-
outCodes[writePos++] = CC_SPACE;
|
|
179
|
-
pendingSpace = false;
|
|
180
|
-
}
|
|
181
|
-
outCodes[writePos++] = code;
|
|
182
|
-
if (state === STATE_NORMAL) {
|
|
183
|
-
if (code === CC_SINGLE_QUOTE) state = STATE_SINGLE_QUOTE;
|
|
184
|
-
else if (code === CC_DOUBLE_QUOTE) state = STATE_DOUBLE_QUOTE;
|
|
185
|
-
continue;
|
|
186
|
-
}
|
|
187
|
-
if (state === STATE_SINGLE_QUOTE) {
|
|
188
|
-
if (code === CC_SINGLE_QUOTE && nextCode === CC_SINGLE_QUOTE) {
|
|
189
|
-
outCodes[writePos++] = nextCode;
|
|
190
|
-
i++;
|
|
191
|
-
continue;
|
|
192
|
-
}
|
|
193
|
-
if (code === CC_SINGLE_QUOTE) state = STATE_NORMAL;
|
|
194
|
-
continue;
|
|
195
|
-
}
|
|
196
|
-
if (state === STATE_DOUBLE_QUOTE) {
|
|
197
|
-
if (code === CC_DOUBLE_QUOTE && nextCode === CC_DOUBLE_QUOTE) {
|
|
198
|
-
outCodes[writePos++] = nextCode;
|
|
199
|
-
i++;
|
|
200
|
-
continue;
|
|
201
|
-
}
|
|
202
|
-
if (code === CC_DOUBLE_QUOTE) state = STATE_NORMAL;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
var result;
|
|
206
|
-
if (0 === writePos) result = ";";
|
|
207
|
-
else {
|
|
208
|
-
while(writePos > 0 && outCodes[writePos - 1] === CC_SEMICOLON)writePos--;
|
|
209
|
-
outCodes[writePos++] = CC_SEMICOLON;
|
|
210
|
-
result = _normDecoder.decode(outCodes.subarray(0, writePos));
|
|
211
|
-
}
|
|
212
|
-
_normCache.set(sql, result);
|
|
213
|
-
return result;
|
|
214
|
-
}
|
|
215
6
|
var DEFAULT_STATEMENT_TIMEOUT = 30000;
|
|
216
7
|
function createTimeoutError(timeout, sql) {
|
|
217
|
-
return new Error("SQLite statement timed out after ".concat(timeout, "ms: ").concat(
|
|
8
|
+
return new Error("SQLite statement timed out after ".concat(timeout, "ms: ").concat(sql));
|
|
218
9
|
}
|
|
219
10
|
function toError(value) {
|
|
220
11
|
return value instanceof Error ? value : new Error(String(value));
|
|
@@ -245,56 +36,65 @@ function createJsonValueParser(onValue) {
|
|
|
245
36
|
feed: function(chunk) {
|
|
246
37
|
this.buffer += chunk;
|
|
247
38
|
var consumeUntil = 0;
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
39
|
+
var buffer = this.buffer;
|
|
40
|
+
var start = this.start;
|
|
41
|
+
var nesting = this.nesting;
|
|
42
|
+
var inString = this.inString;
|
|
43
|
+
var escaped = this.escaped;
|
|
44
|
+
for(var index = this.readPos; index < buffer.length; index++){
|
|
45
|
+
var code = buffer.charCodeAt(index);
|
|
46
|
+
if (-1 === start) {
|
|
251
47
|
if (isWhitespaceCode(code)) continue;
|
|
252
48
|
if (code !== CHAR_OPEN_BRACKET && code !== CHAR_OPEN_BRACE) continue;
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
49
|
+
start = index;
|
|
50
|
+
nesting = 1;
|
|
51
|
+
inString = false;
|
|
52
|
+
escaped = false;
|
|
257
53
|
continue;
|
|
258
54
|
}
|
|
259
|
-
if (
|
|
260
|
-
if (
|
|
261
|
-
else if (code === CHAR_BACKSLASH)
|
|
262
|
-
else if (code === CHAR_QUOTE)
|
|
55
|
+
if (inString) {
|
|
56
|
+
if (escaped) escaped = false;
|
|
57
|
+
else if (code === CHAR_BACKSLASH) escaped = true;
|
|
58
|
+
else if (code === CHAR_QUOTE) inString = false;
|
|
263
59
|
continue;
|
|
264
60
|
}
|
|
265
61
|
if (code === CHAR_QUOTE) {
|
|
266
|
-
|
|
62
|
+
inString = true;
|
|
267
63
|
continue;
|
|
268
64
|
}
|
|
269
65
|
if (code === CHAR_OPEN_BRACKET || code === CHAR_OPEN_BRACE) {
|
|
270
|
-
|
|
66
|
+
nesting++;
|
|
271
67
|
continue;
|
|
272
68
|
}
|
|
273
69
|
if (code === CHAR_CLOSE_BRACKET || code === CHAR_CLOSE_BRACE) {
|
|
274
|
-
|
|
275
|
-
if (0 ===
|
|
276
|
-
if (index ===
|
|
277
|
-
|
|
70
|
+
nesting--;
|
|
71
|
+
if (0 === nesting) {
|
|
72
|
+
if (index === start + 1) {
|
|
73
|
+
start = -1;
|
|
278
74
|
consumeUntil = index + 1;
|
|
279
75
|
continue;
|
|
280
76
|
}
|
|
281
|
-
var raw =
|
|
282
|
-
|
|
77
|
+
var raw = buffer.slice(start, index + 1);
|
|
78
|
+
start = -1;
|
|
283
79
|
onValue(raw);
|
|
284
80
|
consumeUntil = index + 1;
|
|
285
81
|
}
|
|
286
82
|
}
|
|
287
83
|
}
|
|
84
|
+
this.start = start;
|
|
85
|
+
this.nesting = nesting;
|
|
86
|
+
this.inString = inString;
|
|
87
|
+
this.escaped = escaped;
|
|
288
88
|
if (consumeUntil > 0) {
|
|
289
89
|
this._consumed = consumeUntil;
|
|
290
|
-
this.readPos = -1 !== this.start ?
|
|
90
|
+
this.readPos = -1 !== this.start ? buffer.length : this._consumed;
|
|
291
91
|
if (this._consumed > 65536) {
|
|
292
92
|
if (-1 !== this.start) this.start -= this._consumed;
|
|
293
93
|
this.buffer = this.buffer.slice(this._consumed);
|
|
294
94
|
this.readPos = this.buffer.length;
|
|
295
95
|
this._consumed = 0;
|
|
296
96
|
}
|
|
297
|
-
} else this.readPos =
|
|
97
|
+
} else this.readPos = buffer.length;
|
|
298
98
|
},
|
|
299
99
|
reset: function() {
|
|
300
100
|
this.buffer = "";
|
|
@@ -322,10 +122,18 @@ function createRowStreamParser(onRow) {
|
|
|
322
122
|
feed: function(chunk) {
|
|
323
123
|
if (this.finished) return chunk;
|
|
324
124
|
this.buffer += chunk;
|
|
125
|
+
var buffer = this.buffer;
|
|
126
|
+
var started = this.started;
|
|
127
|
+
var inString = this.inString;
|
|
128
|
+
var escaped = this.escaped;
|
|
129
|
+
var elementStart = this.elementStart;
|
|
130
|
+
var elementEnd = this.elementEnd;
|
|
131
|
+
var nesting = this.nesting;
|
|
132
|
+
var consumed = this._consumed;
|
|
325
133
|
var index = this.readPos;
|
|
326
|
-
while(index <
|
|
327
|
-
var code =
|
|
328
|
-
if (!
|
|
134
|
+
while(index < buffer.length){
|
|
135
|
+
var code = buffer.charCodeAt(index);
|
|
136
|
+
if (!started) {
|
|
329
137
|
if (isWhitespaceCode(code)) {
|
|
330
138
|
index++;
|
|
331
139
|
continue;
|
|
@@ -334,74 +142,82 @@ function createRowStreamParser(onRow) {
|
|
|
334
142
|
index++;
|
|
335
143
|
continue;
|
|
336
144
|
}
|
|
337
|
-
|
|
145
|
+
started = true;
|
|
338
146
|
index++;
|
|
339
147
|
continue;
|
|
340
148
|
}
|
|
341
|
-
if (
|
|
342
|
-
if (
|
|
343
|
-
else if (code === CHAR_BACKSLASH)
|
|
344
|
-
else if (code === CHAR_QUOTE)
|
|
149
|
+
if (inString) {
|
|
150
|
+
if (escaped) escaped = false;
|
|
151
|
+
else if (code === CHAR_BACKSLASH) escaped = true;
|
|
152
|
+
else if (code === CHAR_QUOTE) inString = false;
|
|
345
153
|
index++;
|
|
346
154
|
continue;
|
|
347
155
|
}
|
|
348
|
-
if (-1 ===
|
|
156
|
+
if (-1 === elementStart) {
|
|
349
157
|
if (isWhitespaceCode(code) || code === CHAR_COMMA) {
|
|
350
158
|
index++;
|
|
351
159
|
continue;
|
|
352
160
|
}
|
|
353
161
|
if (code === CHAR_CLOSE_BRACKET) {
|
|
354
162
|
this.finished = true;
|
|
355
|
-
var leftover = this.buffer.slice(index + 1);
|
|
356
|
-
this.buffer = "";
|
|
357
163
|
this.readPos = 0;
|
|
358
|
-
|
|
164
|
+
this.buffer = "";
|
|
165
|
+
this.started = false;
|
|
166
|
+
return buffer.slice(index + 1);
|
|
359
167
|
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
168
|
+
elementStart = index;
|
|
169
|
+
elementEnd = -1;
|
|
170
|
+
nesting = code === CHAR_OPEN_BRACE || code === CHAR_OPEN_BRACKET ? 1 : 0;
|
|
171
|
+
inString = code === CHAR_QUOTE;
|
|
172
|
+
escaped = false;
|
|
364
173
|
index++;
|
|
365
174
|
continue;
|
|
366
175
|
}
|
|
367
176
|
if (code === CHAR_QUOTE) {
|
|
368
|
-
|
|
177
|
+
inString = true;
|
|
369
178
|
index++;
|
|
370
179
|
continue;
|
|
371
180
|
}
|
|
372
181
|
if (code === CHAR_OPEN_BRACE || code === CHAR_OPEN_BRACKET) {
|
|
373
|
-
|
|
182
|
+
nesting++;
|
|
374
183
|
index++;
|
|
375
184
|
continue;
|
|
376
185
|
}
|
|
377
186
|
if (code === CHAR_CLOSE_BRACE || code === CHAR_CLOSE_BRACKET) {
|
|
378
|
-
|
|
379
|
-
if (0 ===
|
|
187
|
+
nesting--;
|
|
188
|
+
if (0 === nesting) elementEnd = index + 1;
|
|
380
189
|
}
|
|
381
|
-
if (-1 !==
|
|
190
|
+
if (-1 !== elementEnd) {
|
|
382
191
|
var lookAhead = index + 1;
|
|
383
|
-
while(lookAhead <
|
|
384
|
-
if (lookAhead <
|
|
385
|
-
var delimiter =
|
|
192
|
+
while(lookAhead < buffer.length && isWhitespaceCode(buffer.charCodeAt(lookAhead)))lookAhead++;
|
|
193
|
+
if (lookAhead < buffer.length) {
|
|
194
|
+
var delimiter = buffer.charCodeAt(lookAhead);
|
|
386
195
|
if (delimiter === CHAR_COMMA || delimiter === CHAR_CLOSE_BRACKET) {
|
|
387
|
-
onRow(
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
196
|
+
onRow(buffer.slice(elementStart, elementEnd));
|
|
197
|
+
consumed = lookAhead + 1;
|
|
198
|
+
elementStart = -1;
|
|
199
|
+
elementEnd = -1;
|
|
200
|
+
nesting = 0;
|
|
392
201
|
if (delimiter === CHAR_CLOSE_BRACKET) {
|
|
393
202
|
this.finished = true;
|
|
394
|
-
var tail = this.buffer.slice(this._consumed);
|
|
395
203
|
this.buffer = "";
|
|
204
|
+
this.started = false;
|
|
205
|
+
this.inString = false;
|
|
206
|
+
this.escaped = false;
|
|
207
|
+
this.elementStart = -1;
|
|
208
|
+
this.elementEnd = -1;
|
|
209
|
+
this.nesting = 0;
|
|
396
210
|
this._consumed = 0;
|
|
397
211
|
this.readPos = 0;
|
|
398
|
-
return
|
|
212
|
+
return buffer.slice(consumed);
|
|
399
213
|
}
|
|
400
|
-
index =
|
|
401
|
-
if (
|
|
402
|
-
|
|
403
|
-
|
|
214
|
+
index = consumed;
|
|
215
|
+
if (consumed > 65536) {
|
|
216
|
+
buffer = buffer.slice(consumed);
|
|
217
|
+
this.buffer = buffer;
|
|
404
218
|
this._consumed = 0;
|
|
219
|
+
index = 0;
|
|
220
|
+
consumed = 0;
|
|
405
221
|
}
|
|
406
222
|
continue;
|
|
407
223
|
}
|
|
@@ -409,12 +225,19 @@ function createRowStreamParser(onRow) {
|
|
|
409
225
|
}
|
|
410
226
|
index++;
|
|
411
227
|
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
228
|
+
this.started = started;
|
|
229
|
+
this.inString = inString;
|
|
230
|
+
this.escaped = escaped;
|
|
231
|
+
this.elementStart = elementStart;
|
|
232
|
+
this.elementEnd = elementEnd;
|
|
233
|
+
this.nesting = nesting;
|
|
234
|
+
this._consumed = consumed;
|
|
235
|
+
if (consumed > 0) {
|
|
236
|
+
if (-1 !== elementStart) {
|
|
237
|
+
this.elementStart -= consumed;
|
|
238
|
+
if (-1 !== elementEnd) this.elementEnd -= consumed;
|
|
416
239
|
}
|
|
417
|
-
this.buffer =
|
|
240
|
+
this.buffer = buffer.slice(consumed);
|
|
418
241
|
this._consumed = 0;
|
|
419
242
|
}
|
|
420
243
|
if (this.elementStart > 0) {
|
|
@@ -442,14 +265,15 @@ function createRowStreamParser(onRow) {
|
|
|
442
265
|
var TOKEN_COLUMN = "__sqlite_executor_token__";
|
|
443
266
|
var DEFAULT_BATCH_SIZE = 10;
|
|
444
267
|
var DEFAULT_MAX_INFLIGHT = 50;
|
|
445
|
-
|
|
268
|
+
var INFLIGHT_COMPACT_THRESHOLD = 128;
|
|
269
|
+
function _check_private_redeclaration(obj, privateCollection) {
|
|
446
270
|
if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
447
271
|
}
|
|
448
|
-
function
|
|
272
|
+
function _class_apply_descriptor_get(receiver, descriptor) {
|
|
449
273
|
if (descriptor.get) return descriptor.get.call(receiver);
|
|
450
274
|
return descriptor.value;
|
|
451
275
|
}
|
|
452
|
-
function
|
|
276
|
+
function _class_apply_descriptor_set(receiver, descriptor, value) {
|
|
453
277
|
if (descriptor.set) descriptor.set.call(receiver, value);
|
|
454
278
|
else {
|
|
455
279
|
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
@@ -472,31 +296,31 @@ function _class_apply_descriptor_update(receiver, descriptor) {
|
|
|
472
296
|
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
473
297
|
return descriptor;
|
|
474
298
|
}
|
|
475
|
-
function
|
|
299
|
+
function _class_call_check(instance, Constructor) {
|
|
476
300
|
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
477
301
|
}
|
|
478
|
-
function
|
|
302
|
+
function _class_extract_field_descriptor(receiver, privateMap, action) {
|
|
479
303
|
if (!privateMap.has(receiver)) throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
480
304
|
return privateMap.get(receiver);
|
|
481
305
|
}
|
|
482
|
-
function
|
|
483
|
-
var descriptor =
|
|
484
|
-
return
|
|
306
|
+
function _class_private_field_get(receiver, privateMap) {
|
|
307
|
+
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
|
|
308
|
+
return _class_apply_descriptor_get(receiver, descriptor);
|
|
485
309
|
}
|
|
486
|
-
function
|
|
487
|
-
|
|
310
|
+
function _class_private_field_init(obj, privateMap, value) {
|
|
311
|
+
_check_private_redeclaration(obj, privateMap);
|
|
488
312
|
privateMap.set(obj, value);
|
|
489
313
|
}
|
|
490
|
-
function
|
|
491
|
-
var descriptor =
|
|
492
|
-
|
|
314
|
+
function _class_private_field_set(receiver, privateMap, value) {
|
|
315
|
+
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
|
|
316
|
+
_class_apply_descriptor_set(receiver, descriptor, value);
|
|
493
317
|
return value;
|
|
494
318
|
}
|
|
495
319
|
function _class_private_field_update(receiver, privateMap) {
|
|
496
|
-
var descriptor =
|
|
320
|
+
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "update");
|
|
497
321
|
return _class_apply_descriptor_update(receiver, descriptor);
|
|
498
322
|
}
|
|
499
|
-
function
|
|
323
|
+
function _defineProperties(target, props) {
|
|
500
324
|
for(var i = 0; i < props.length; i++){
|
|
501
325
|
var descriptor = props[i];
|
|
502
326
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
@@ -505,9 +329,9 @@ function stream_defineProperties(target, props) {
|
|
|
505
329
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
506
330
|
}
|
|
507
331
|
}
|
|
508
|
-
function
|
|
509
|
-
if (protoProps)
|
|
510
|
-
if (staticProps)
|
|
332
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
333
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
334
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
511
335
|
return Constructor;
|
|
512
336
|
}
|
|
513
337
|
function _type_of(obj) {
|
|
@@ -515,7 +339,7 @@ function _type_of(obj) {
|
|
|
515
339
|
}
|
|
516
340
|
var _computedKey;
|
|
517
341
|
function setupStreamParser(task) {
|
|
518
|
-
var
|
|
342
|
+
var pipelineOrFeed = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {
|
|
519
343
|
feed: function() {}
|
|
520
344
|
};
|
|
521
345
|
if ("stream" !== task.kind) return null;
|
|
@@ -523,7 +347,7 @@ function setupStreamParser(task) {
|
|
|
523
347
|
if (task.consumerError) return;
|
|
524
348
|
try {
|
|
525
349
|
var row = JSON.parse(rawRow);
|
|
526
|
-
if ((void 0 === row ? "undefined" : _type_of(row)) === "object" && null !== row && TOKEN_COLUMN in row) return void
|
|
350
|
+
if ((void 0 === row ? "undefined" : _type_of(row)) === "object" && null !== row && TOKEN_COLUMN in row) return void pipelineOrFeed.feed("[".concat(rawRow, "]"));
|
|
527
351
|
task.onRow(row);
|
|
528
352
|
} catch (error) {
|
|
529
353
|
task.consumerError = toError(error);
|
|
@@ -537,50 +361,50 @@ var _computedKey1 = _computedKey;
|
|
|
537
361
|
var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
538
362
|
"use strict";
|
|
539
363
|
function AsyncRowBuffer() {
|
|
540
|
-
|
|
541
|
-
|
|
364
|
+
_class_call_check(this, AsyncRowBuffer);
|
|
365
|
+
_class_private_field_init(this, _buffer, {
|
|
542
366
|
writable: true,
|
|
543
367
|
value: []
|
|
544
368
|
});
|
|
545
|
-
|
|
369
|
+
_class_private_field_init(this, _index, {
|
|
546
370
|
writable: true,
|
|
547
371
|
value: 0
|
|
548
372
|
});
|
|
549
|
-
|
|
373
|
+
_class_private_field_init(this, _done, {
|
|
550
374
|
writable: true,
|
|
551
375
|
value: false
|
|
552
376
|
});
|
|
553
|
-
|
|
377
|
+
_class_private_field_init(this, _error, {
|
|
554
378
|
writable: true,
|
|
555
379
|
value: null
|
|
556
380
|
});
|
|
557
|
-
|
|
381
|
+
_class_private_field_init(this, _pending, {
|
|
558
382
|
writable: true,
|
|
559
383
|
value: null
|
|
560
384
|
});
|
|
561
385
|
}
|
|
562
|
-
|
|
386
|
+
_create_class(AsyncRowBuffer, [
|
|
563
387
|
{
|
|
564
388
|
key: "push",
|
|
565
389
|
value: function(row) {
|
|
566
|
-
if (
|
|
567
|
-
if (
|
|
568
|
-
var resolve =
|
|
569
|
-
|
|
390
|
+
if (_class_private_field_get(this, _done) || _class_private_field_get(this, _error)) return;
|
|
391
|
+
if (_class_private_field_get(this, _pending)) {
|
|
392
|
+
var resolve = _class_private_field_get(this, _pending).resolve;
|
|
393
|
+
_class_private_field_set(this, _pending, null);
|
|
570
394
|
resolve({
|
|
571
395
|
value: row,
|
|
572
396
|
done: false
|
|
573
397
|
});
|
|
574
|
-
} else
|
|
398
|
+
} else _class_private_field_get(this, _buffer).push(row);
|
|
575
399
|
}
|
|
576
400
|
},
|
|
577
401
|
{
|
|
578
402
|
key: "end",
|
|
579
403
|
value: function() {
|
|
580
|
-
|
|
581
|
-
if (
|
|
582
|
-
var resolve =
|
|
583
|
-
|
|
404
|
+
_class_private_field_set(this, _done, true);
|
|
405
|
+
if (_class_private_field_get(this, _pending)) {
|
|
406
|
+
var resolve = _class_private_field_get(this, _pending).resolve;
|
|
407
|
+
_class_private_field_set(this, _pending, null);
|
|
584
408
|
resolve({
|
|
585
409
|
value: void 0,
|
|
586
410
|
done: true
|
|
@@ -591,10 +415,10 @@ var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
|
591
415
|
{
|
|
592
416
|
key: "error",
|
|
593
417
|
value: function(err) {
|
|
594
|
-
|
|
595
|
-
if (
|
|
596
|
-
var reject =
|
|
597
|
-
|
|
418
|
+
_class_private_field_set(this, _error, err);
|
|
419
|
+
if (_class_private_field_get(this, _pending)) {
|
|
420
|
+
var reject = _class_private_field_get(this, _pending).reject;
|
|
421
|
+
_class_private_field_set(this, _pending, null);
|
|
598
422
|
reject(err);
|
|
599
423
|
}
|
|
600
424
|
}
|
|
@@ -603,17 +427,17 @@ var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
|
603
427
|
key: "next",
|
|
604
428
|
value: function() {
|
|
605
429
|
var _this = this;
|
|
606
|
-
if (
|
|
607
|
-
value:
|
|
430
|
+
if (_class_private_field_get(this, _index) < _class_private_field_get(this, _buffer).length) return Promise.resolve({
|
|
431
|
+
value: _class_private_field_get(this, _buffer)[_class_private_field_update(this, _index).value++],
|
|
608
432
|
done: false
|
|
609
433
|
});
|
|
610
|
-
if (
|
|
434
|
+
if (_class_private_field_get(this, _done)) return Promise.resolve({
|
|
611
435
|
value: void 0,
|
|
612
436
|
done: true
|
|
613
437
|
});
|
|
614
|
-
if (
|
|
438
|
+
if (_class_private_field_get(this, _error)) return Promise.reject(_class_private_field_get(this, _error));
|
|
615
439
|
return new Promise(function(resolve, reject) {
|
|
616
|
-
|
|
440
|
+
_class_private_field_set(_this, _pending, {
|
|
617
441
|
resolve: resolve,
|
|
618
442
|
reject: reject
|
|
619
443
|
});
|
|
@@ -623,12 +447,12 @@ var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
|
623
447
|
{
|
|
624
448
|
key: "return",
|
|
625
449
|
value: function() {
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
if (
|
|
630
|
-
var resolve =
|
|
631
|
-
|
|
450
|
+
_class_private_field_set(this, _done, true);
|
|
451
|
+
_class_private_field_set(this, _buffer, []);
|
|
452
|
+
_class_private_field_set(this, _index, 0);
|
|
453
|
+
if (_class_private_field_get(this, _pending)) {
|
|
454
|
+
var resolve = _class_private_field_get(this, _pending).resolve;
|
|
455
|
+
_class_private_field_set(this, _pending, null);
|
|
632
456
|
resolve({
|
|
633
457
|
value: void 0,
|
|
634
458
|
done: true
|
|
@@ -724,10 +548,12 @@ function createTransactionHandle(scopeId, executor) {
|
|
|
724
548
|
};
|
|
725
549
|
return handle;
|
|
726
550
|
}
|
|
727
|
-
|
|
551
|
+
function isWindows() {
|
|
552
|
+
return "win32" === __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__["default"].platform();
|
|
553
|
+
}
|
|
728
554
|
function isExecutable(filePath) {
|
|
729
555
|
try {
|
|
730
|
-
if (isWindows) return __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].statSync(filePath).isFile();
|
|
556
|
+
if (isWindows()) return __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].statSync(filePath).isFile();
|
|
731
557
|
__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].accessSync(filePath, __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].constants.X_OK);
|
|
732
558
|
return true;
|
|
733
559
|
} catch (e) {
|
|
@@ -735,7 +561,7 @@ function isExecutable(filePath) {
|
|
|
735
561
|
}
|
|
736
562
|
}
|
|
737
563
|
function getPathExts() {
|
|
738
|
-
if (!isWindows) return [
|
|
564
|
+
if (!isWindows()) return [
|
|
739
565
|
""
|
|
740
566
|
];
|
|
741
567
|
var ext = process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM;.PS1";
|
|
@@ -748,7 +574,7 @@ function which(command) {
|
|
|
748
574
|
var pathExts = getPathExts();
|
|
749
575
|
if (command.includes(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].sep)) {
|
|
750
576
|
var fullPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(command);
|
|
751
|
-
if (!isWindows) return isExecutable(fullPath) ? fullPath : null;
|
|
577
|
+
if (!isWindows()) return isExecutable(fullPath) ? fullPath : null;
|
|
752
578
|
if (__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(fullPath)) return isExecutable(fullPath) ? fullPath : null;
|
|
753
579
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
754
580
|
try {
|
|
@@ -775,7 +601,7 @@ function which(command) {
|
|
|
775
601
|
try {
|
|
776
602
|
for(var _iterator1 = pathDirs[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
777
603
|
var dir = _step1.value;
|
|
778
|
-
if (dir) if (isWindows) {
|
|
604
|
+
if (dir) if (isWindows()) {
|
|
779
605
|
var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
|
|
780
606
|
try {
|
|
781
607
|
for(var _iterator2 = pathExts[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true){
|
|
@@ -870,6 +696,14 @@ function process_class_private_field_set(receiver, privateMap, value) {
|
|
|
870
696
|
process_class_apply_descriptor_set(receiver, descriptor, value);
|
|
871
697
|
return value;
|
|
872
698
|
}
|
|
699
|
+
function _class_private_method_get(receiver, privateSet, fn) {
|
|
700
|
+
if (!privateSet.has(receiver)) throw new TypeError("attempted to get private field on non-instance");
|
|
701
|
+
return fn;
|
|
702
|
+
}
|
|
703
|
+
function _class_private_method_init(obj, privateSet) {
|
|
704
|
+
process_check_private_redeclaration(obj, privateSet);
|
|
705
|
+
privateSet.add(obj);
|
|
706
|
+
}
|
|
873
707
|
function process_defineProperties(target, props) {
|
|
874
708
|
for(var i = 0; i < props.length; i++){
|
|
875
709
|
var descriptor = props[i];
|
|
@@ -976,12 +810,14 @@ function _ts_generator(thisArg, body) {
|
|
|
976
810
|
}
|
|
977
811
|
}
|
|
978
812
|
var GRACEFUL_SHUTDOWN_TIMEOUT = 5000;
|
|
979
|
-
var _binary = /*#__PURE__*/ new WeakMap(), _database = /*#__PURE__*/ new WeakMap(), _proc = /*#__PURE__*/ new WeakMap(), _initMode = /*#__PURE__*/ new WeakMap(), _draining = /*#__PURE__*/ new WeakMap(), _onDrain = /*#__PURE__*/ new WeakMap();
|
|
813
|
+
var _binary = /*#__PURE__*/ new WeakMap(), _database = /*#__PURE__*/ new WeakMap(), _proc = /*#__PURE__*/ new WeakMap(), _initMode = /*#__PURE__*/ new WeakMap(), _draining = /*#__PURE__*/ new WeakMap(), _writeBuffer = /*#__PURE__*/ new WeakMap(), _drainCallbacks = /*#__PURE__*/ new WeakMap(), _onDrain = /*#__PURE__*/ new WeakMap(), _flushBuffer = /*#__PURE__*/ new WeakSet(), _notifyIfDrained = /*#__PURE__*/ new WeakSet();
|
|
980
814
|
var process_ProcessManager = /*#__PURE__*/ function() {
|
|
981
815
|
"use strict";
|
|
982
816
|
function ProcessManager() {
|
|
983
817
|
var _ref = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, binary = _ref.binary, database = _ref.database, _ref_initMode = _ref.initMode, initMode = void 0 === _ref_initMode ? "wal" : _ref_initMode, onDrain = _ref.onDrain;
|
|
984
818
|
process_class_call_check(this, ProcessManager);
|
|
819
|
+
_class_private_method_init(this, _flushBuffer);
|
|
820
|
+
_class_private_method_init(this, _notifyIfDrained);
|
|
985
821
|
process_class_private_field_init(this, _binary, {
|
|
986
822
|
writable: true,
|
|
987
823
|
value: void 0
|
|
@@ -1002,6 +838,14 @@ var process_ProcessManager = /*#__PURE__*/ function() {
|
|
|
1002
838
|
writable: true,
|
|
1003
839
|
value: false
|
|
1004
840
|
});
|
|
841
|
+
process_class_private_field_init(this, _writeBuffer, {
|
|
842
|
+
writable: true,
|
|
843
|
+
value: []
|
|
844
|
+
});
|
|
845
|
+
process_class_private_field_init(this, _drainCallbacks, {
|
|
846
|
+
writable: true,
|
|
847
|
+
value: []
|
|
848
|
+
});
|
|
1005
849
|
process_class_private_field_init(this, _onDrain, {
|
|
1006
850
|
writable: true,
|
|
1007
851
|
value: void 0
|
|
@@ -1025,6 +869,13 @@ var process_ProcessManager = /*#__PURE__*/ function() {
|
|
|
1025
869
|
process_class_private_field_set(this, _onDrain, fn);
|
|
1026
870
|
}
|
|
1027
871
|
},
|
|
872
|
+
{
|
|
873
|
+
key: "onDrained",
|
|
874
|
+
value: function(callback) {
|
|
875
|
+
if (!process_class_private_field_get(this, _draining) && 0 === process_class_private_field_get(this, _writeBuffer).length) return void callback();
|
|
876
|
+
process_class_private_field_get(this, _drainCallbacks).push(callback);
|
|
877
|
+
}
|
|
878
|
+
},
|
|
1028
879
|
{
|
|
1029
880
|
key: "binary",
|
|
1030
881
|
get: function() {
|
|
@@ -1040,9 +891,9 @@ var process_ProcessManager = /*#__PURE__*/ function() {
|
|
|
1040
891
|
{
|
|
1041
892
|
key: "start",
|
|
1042
893
|
value: function() {
|
|
1043
|
-
var _proc_stdin, _proc_stdout, _proc_stderr;
|
|
894
|
+
var _proc_stdin, _proc_stdout, _proc_stderr, _proc_stdin1;
|
|
1044
895
|
if (!process_class_private_field_get(this, _binary)) throw new Error("sqlite3 binary path is empty. Provide a valid --binary / binary option.");
|
|
1045
|
-
if (!__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync(process_class_private_field_get(this, _binary))) throw new Error("sqlite3 binary not found: ".concat(process_class_private_field_get(this, _binary), ". Make sure sqlite3 is installed or provide a valid --binary / binary option."));
|
|
896
|
+
if (__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(process_class_private_field_get(this, _binary)) && !__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync(process_class_private_field_get(this, _binary))) throw new Error("sqlite3 binary not found: ".concat(process_class_private_field_get(this, _binary), ". Make sure sqlite3 is installed or provide a valid --binary / binary option."));
|
|
1046
897
|
var args = [
|
|
1047
898
|
"-json"
|
|
1048
899
|
];
|
|
@@ -1059,6 +910,7 @@ var process_ProcessManager = /*#__PURE__*/ function() {
|
|
|
1059
910
|
null == (_proc_stdin = proc.stdin) || _proc_stdin.setDefaultEncoding("utf-8");
|
|
1060
911
|
null == (_proc_stdout = proc.stdout) || _proc_stdout.setEncoding("utf-8");
|
|
1061
912
|
null == (_proc_stderr = proc.stderr) || _proc_stderr.setEncoding("utf-8");
|
|
913
|
+
null == (_proc_stdin1 = proc.stdin) || _proc_stdin1.on("error", function() {});
|
|
1062
914
|
process_class_private_field_set(this, _proc, proc);
|
|
1063
915
|
return proc;
|
|
1064
916
|
}
|
|
@@ -1070,11 +922,13 @@ var process_ProcessManager = /*#__PURE__*/ function() {
|
|
|
1070
922
|
var _$_class_private_field_get;
|
|
1071
923
|
var stream = null == (_$_class_private_field_get = process_class_private_field_get(this, _proc)) ? void 0 : _$_class_private_field_get.stdin;
|
|
1072
924
|
if (!stream) return;
|
|
1073
|
-
if (process_class_private_field_get(this, _draining)) return;
|
|
925
|
+
if (process_class_private_field_get(this, _draining)) return void process_class_private_field_get(this, _writeBuffer).push(data);
|
|
1074
926
|
if (!stream.write(data)) {
|
|
1075
927
|
process_class_private_field_set(this, _draining, true);
|
|
1076
928
|
stream.once("drain", function() {
|
|
1077
929
|
process_class_private_field_set(_this, _draining, false);
|
|
930
|
+
_class_private_method_get(_this, _flushBuffer, flushBuffer).call(_this);
|
|
931
|
+
_class_private_method_get(_this, _notifyIfDrained, notifyIfDrained).call(_this);
|
|
1078
932
|
process_class_private_field_get(_this, _onDrain).call(_this);
|
|
1079
933
|
});
|
|
1080
934
|
}
|
|
@@ -1093,40 +947,58 @@ var process_ProcessManager = /*#__PURE__*/ function() {
|
|
|
1093
947
|
if (!proc) return [
|
|
1094
948
|
2
|
|
1095
949
|
];
|
|
950
|
+
if (!(process_class_private_field_get(_this, _draining) || process_class_private_field_get(_this, _writeBuffer).length > 0)) return [
|
|
951
|
+
3,
|
|
952
|
+
2
|
|
953
|
+
];
|
|
954
|
+
return [
|
|
955
|
+
4,
|
|
956
|
+
new Promise(function(resolve) {
|
|
957
|
+
var timer = setTimeout(resolve, GRACEFUL_SHUTDOWN_TIMEOUT);
|
|
958
|
+
_this.onDrained(function() {
|
|
959
|
+
clearTimeout(timer);
|
|
960
|
+
resolve();
|
|
961
|
+
});
|
|
962
|
+
})
|
|
963
|
+
];
|
|
964
|
+
case 1:
|
|
965
|
+
_state.sent();
|
|
966
|
+
_state.label = 2;
|
|
967
|
+
case 2:
|
|
1096
968
|
timer = setTimeout(function() {
|
|
1097
969
|
proc.kill();
|
|
1098
|
-
}, GRACEFUL_SHUTDOWN_TIMEOUT);
|
|
1099
|
-
_state.label =
|
|
1100
|
-
case
|
|
970
|
+
}, GRACEFUL_SHUTDOWN_TIMEOUT).unref();
|
|
971
|
+
_state.label = 3;
|
|
972
|
+
case 3:
|
|
1101
973
|
_state.trys.push([
|
|
1102
|
-
1,
|
|
1103
974
|
3,
|
|
1104
|
-
|
|
1105
|
-
|
|
975
|
+
5,
|
|
976
|
+
6,
|
|
977
|
+
7
|
|
1106
978
|
]);
|
|
1107
979
|
null == (_proc_stdin = proc.stdin) || _proc_stdin.write(".quit\n");
|
|
1108
980
|
return [
|
|
1109
981
|
4,
|
|
1110
982
|
(0, __WEBPACK_EXTERNAL_MODULE_node_events_0a6aefe7__.once)(proc, "close")
|
|
1111
983
|
];
|
|
1112
|
-
case
|
|
984
|
+
case 4:
|
|
1113
985
|
_state.sent();
|
|
1114
986
|
return [
|
|
1115
987
|
3,
|
|
1116
|
-
|
|
988
|
+
7
|
|
1117
989
|
];
|
|
1118
|
-
case
|
|
990
|
+
case 5:
|
|
1119
991
|
_state.sent();
|
|
1120
992
|
return [
|
|
1121
993
|
3,
|
|
1122
|
-
|
|
994
|
+
7
|
|
1123
995
|
];
|
|
1124
|
-
case
|
|
996
|
+
case 6:
|
|
1125
997
|
clearTimeout(timer);
|
|
1126
998
|
return [
|
|
1127
999
|
7
|
|
1128
1000
|
];
|
|
1129
|
-
case
|
|
1001
|
+
case 7:
|
|
1130
1002
|
return [
|
|
1131
1003
|
2
|
|
1132
1004
|
];
|
|
@@ -1143,6 +1015,8 @@ var process_ProcessManager = /*#__PURE__*/ function() {
|
|
|
1143
1015
|
if (!proc) return null;
|
|
1144
1016
|
process_class_private_field_set(this, _proc, null);
|
|
1145
1017
|
process_class_private_field_set(this, _draining, false);
|
|
1018
|
+
process_class_private_field_set(this, _writeBuffer, []);
|
|
1019
|
+
process_class_private_field_set(this, _drainCallbacks, []);
|
|
1146
1020
|
null == (_proc_stdout = proc.stdout) || _proc_stdout.removeAllListeners();
|
|
1147
1021
|
null == (_proc_stderr = proc.stderr) || _proc_stderr.removeAllListeners();
|
|
1148
1022
|
proc.removeAllListeners();
|
|
@@ -1154,6 +1028,47 @@ var process_ProcessManager = /*#__PURE__*/ function() {
|
|
|
1154
1028
|
]);
|
|
1155
1029
|
return ProcessManager;
|
|
1156
1030
|
}();
|
|
1031
|
+
function flushBuffer() {
|
|
1032
|
+
var buffer = process_class_private_field_get(this, _writeBuffer);
|
|
1033
|
+
process_class_private_field_set(this, _writeBuffer, []);
|
|
1034
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
1035
|
+
try {
|
|
1036
|
+
for(var _iterator = buffer[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1037
|
+
var data = _step.value;
|
|
1038
|
+
this.write(data);
|
|
1039
|
+
}
|
|
1040
|
+
} catch (err) {
|
|
1041
|
+
_didIteratorError = true;
|
|
1042
|
+
_iteratorError = err;
|
|
1043
|
+
} finally{
|
|
1044
|
+
try {
|
|
1045
|
+
if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
|
|
1046
|
+
} finally{
|
|
1047
|
+
if (_didIteratorError) throw _iteratorError;
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
function notifyIfDrained() {
|
|
1052
|
+
if (process_class_private_field_get(this, _draining)) return;
|
|
1053
|
+
var callbacks = process_class_private_field_get(this, _drainCallbacks);
|
|
1054
|
+
process_class_private_field_set(this, _drainCallbacks, []);
|
|
1055
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
1056
|
+
try {
|
|
1057
|
+
for(var _iterator = callbacks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1058
|
+
var cb = _step.value;
|
|
1059
|
+
cb();
|
|
1060
|
+
}
|
|
1061
|
+
} catch (err) {
|
|
1062
|
+
_didIteratorError = true;
|
|
1063
|
+
_iteratorError = err;
|
|
1064
|
+
} finally{
|
|
1065
|
+
try {
|
|
1066
|
+
if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
|
|
1067
|
+
} finally{
|
|
1068
|
+
if (_didIteratorError) throw _iteratorError;
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1157
1072
|
var _counter = 0;
|
|
1158
1073
|
var _PREFIX = "__executor_end__";
|
|
1159
1074
|
var _PID36 = process.pid.toString(36);
|
|
@@ -1161,121 +1076,305 @@ function generateToken() {
|
|
|
1161
1076
|
_counter = _counter + 1 >>> 0;
|
|
1162
1077
|
return "".concat(_PREFIX).concat(_counter.toString(36), "_").concat(_PID36);
|
|
1163
1078
|
}
|
|
1164
|
-
function
|
|
1165
|
-
|
|
1079
|
+
function lruCache_check_private_redeclaration(obj, privateCollection) {
|
|
1080
|
+
if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
1166
1081
|
}
|
|
1167
|
-
function
|
|
1168
|
-
if (
|
|
1169
|
-
|
|
1170
|
-
if ("number" == typeof value || (void 0 === value ? "undefined" : escape_type_of(value)) === "bigint") return String(value);
|
|
1171
|
-
if ("boolean" == typeof value) return value ? "TRUE" : "FALSE";
|
|
1172
|
-
if (value instanceof Date) return "'".concat(value.toISOString(), "'");
|
|
1173
|
-
throw new TypeError("Unsupported parameter type: ".concat(void 0 === value ? "undefined" : escape_type_of(value)));
|
|
1082
|
+
function lruCache_class_apply_descriptor_get(receiver, descriptor) {
|
|
1083
|
+
if (descriptor.get) return descriptor.get.call(receiver);
|
|
1084
|
+
return descriptor.value;
|
|
1174
1085
|
}
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1086
|
+
function lruCache_class_apply_descriptor_set(receiver, descriptor, value) {
|
|
1087
|
+
if (descriptor.set) descriptor.set.call(receiver, value);
|
|
1088
|
+
else {
|
|
1089
|
+
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
1090
|
+
descriptor.value = value;
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
function lruCache_class_call_check(instance, Constructor) {
|
|
1094
|
+
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
1095
|
+
}
|
|
1096
|
+
function lruCache_class_extract_field_descriptor(receiver, privateMap, action) {
|
|
1097
|
+
if (!privateMap.has(receiver)) throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
1098
|
+
return privateMap.get(receiver);
|
|
1099
|
+
}
|
|
1100
|
+
function lruCache_class_private_field_get(receiver, privateMap) {
|
|
1101
|
+
var descriptor = lruCache_class_extract_field_descriptor(receiver, privateMap, "get");
|
|
1102
|
+
return lruCache_class_apply_descriptor_get(receiver, descriptor);
|
|
1103
|
+
}
|
|
1104
|
+
function lruCache_class_private_field_init(obj, privateMap, value) {
|
|
1105
|
+
lruCache_check_private_redeclaration(obj, privateMap);
|
|
1106
|
+
privateMap.set(obj, value);
|
|
1107
|
+
}
|
|
1108
|
+
function lruCache_class_private_field_set(receiver, privateMap, value) {
|
|
1109
|
+
var descriptor = lruCache_class_extract_field_descriptor(receiver, privateMap, "set");
|
|
1110
|
+
lruCache_class_apply_descriptor_set(receiver, descriptor, value);
|
|
1111
|
+
return value;
|
|
1112
|
+
}
|
|
1113
|
+
function lruCache_defineProperties(target, props) {
|
|
1114
|
+
for(var i = 0; i < props.length; i++){
|
|
1115
|
+
var descriptor = props[i];
|
|
1116
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
1117
|
+
descriptor.configurable = true;
|
|
1118
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
1119
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
function lruCache_create_class(Constructor, protoProps, staticProps) {
|
|
1123
|
+
if (protoProps) lruCache_defineProperties(Constructor.prototype, protoProps);
|
|
1124
|
+
if (staticProps) lruCache_defineProperties(Constructor, staticProps);
|
|
1125
|
+
return Constructor;
|
|
1126
|
+
}
|
|
1127
|
+
var _maxSize = /*#__PURE__*/ new WeakMap(), _maxKeyLength = /*#__PURE__*/ new WeakMap(), _maxValueLength = /*#__PURE__*/ new WeakMap(), _map = /*#__PURE__*/ new WeakMap();
|
|
1128
|
+
var lruCache_LRUCache = /*#__PURE__*/ function() {
|
|
1129
|
+
"use strict";
|
|
1130
|
+
function LRUCache() {
|
|
1131
|
+
var _ref = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, _ref_maxSize = _ref.maxSize, maxSize = void 0 === _ref_maxSize ? 256 : _ref_maxSize, _ref_maxKeyLength = _ref.maxKeyLength, maxKeyLength = void 0 === _ref_maxKeyLength ? 4096 : _ref_maxKeyLength, _ref_maxValueLength = _ref.maxValueLength, maxValueLength = void 0 === _ref_maxValueLength ? 1 / 0 : _ref_maxValueLength;
|
|
1132
|
+
lruCache_class_call_check(this, LRUCache);
|
|
1133
|
+
lruCache_class_private_field_init(this, _maxSize, {
|
|
1134
|
+
writable: true,
|
|
1135
|
+
value: void 0
|
|
1136
|
+
});
|
|
1137
|
+
lruCache_class_private_field_init(this, _maxKeyLength, {
|
|
1138
|
+
writable: true,
|
|
1139
|
+
value: void 0
|
|
1140
|
+
});
|
|
1141
|
+
lruCache_class_private_field_init(this, _maxValueLength, {
|
|
1142
|
+
writable: true,
|
|
1143
|
+
value: void 0
|
|
1144
|
+
});
|
|
1145
|
+
lruCache_class_private_field_init(this, _map, {
|
|
1146
|
+
writable: true,
|
|
1147
|
+
value: new Map()
|
|
1148
|
+
});
|
|
1149
|
+
lruCache_class_private_field_set(this, _maxSize, Math.max(1, maxSize));
|
|
1150
|
+
lruCache_class_private_field_set(this, _maxKeyLength, maxKeyLength);
|
|
1151
|
+
lruCache_class_private_field_set(this, _maxValueLength, maxValueLength);
|
|
1152
|
+
}
|
|
1153
|
+
lruCache_create_class(LRUCache, [
|
|
1154
|
+
{
|
|
1155
|
+
key: "get",
|
|
1156
|
+
value: function(key) {
|
|
1157
|
+
if ("string" != typeof key || key.length > lruCache_class_private_field_get(this, _maxKeyLength)) return;
|
|
1158
|
+
var value = lruCache_class_private_field_get(this, _map).get(key);
|
|
1159
|
+
if (void 0 === value) return;
|
|
1160
|
+
lruCache_class_private_field_get(this, _map)["delete"](key);
|
|
1161
|
+
lruCache_class_private_field_get(this, _map).set(key, value);
|
|
1162
|
+
return value;
|
|
1191
1163
|
}
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1164
|
+
},
|
|
1165
|
+
{
|
|
1166
|
+
key: "set",
|
|
1167
|
+
value: function(key, value) {
|
|
1168
|
+
if ("string" != typeof key || key.length > lruCache_class_private_field_get(this, _maxKeyLength)) return;
|
|
1169
|
+
if ("string" == typeof value && value.length > lruCache_class_private_field_get(this, _maxValueLength)) return;
|
|
1170
|
+
if (Array.isArray(value) && value.length > lruCache_class_private_field_get(this, _maxValueLength)) return;
|
|
1171
|
+
if (lruCache_class_private_field_get(this, _map).size >= lruCache_class_private_field_get(this, _maxSize)) {
|
|
1172
|
+
var firstKey = lruCache_class_private_field_get(this, _map).keys().next().value;
|
|
1173
|
+
lruCache_class_private_field_get(this, _map)["delete"](firstKey);
|
|
1174
|
+
}
|
|
1175
|
+
lruCache_class_private_field_get(this, _map).set(key, value);
|
|
1196
1176
|
}
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1177
|
+
},
|
|
1178
|
+
{
|
|
1179
|
+
key: "size",
|
|
1180
|
+
get: function() {
|
|
1181
|
+
return lruCache_class_private_field_get(this, _map).size;
|
|
1201
1182
|
}
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1183
|
+
},
|
|
1184
|
+
{
|
|
1185
|
+
key: "clear",
|
|
1186
|
+
value: function() {
|
|
1187
|
+
lruCache_class_private_field_get(this, _map).clear();
|
|
1207
1188
|
}
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1189
|
+
}
|
|
1190
|
+
]);
|
|
1191
|
+
return LRUCache;
|
|
1192
|
+
}();
|
|
1193
|
+
function escape_type_of(obj) {
|
|
1194
|
+
return obj && "undefined" != typeof Symbol && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
1195
|
+
}
|
|
1196
|
+
function escapeValue(value) {
|
|
1197
|
+
if ("string" == typeof value) return value.includes("'") ? "'".concat(value.replace(/'/g, "''"), "'") : "'".concat(value, "'");
|
|
1198
|
+
if (null == value) return "NULL";
|
|
1199
|
+
if ("number" == typeof value || (void 0 === value ? "undefined" : escape_type_of(value)) === "bigint") return String(value);
|
|
1200
|
+
if ("boolean" == typeof value) return value ? "TRUE" : "FALSE";
|
|
1201
|
+
if (value instanceof Date) return "'".concat(value.toISOString(), "'");
|
|
1202
|
+
throw new TypeError("Unsupported parameter type: ".concat(void 0 === value ? "undefined" : escape_type_of(value)));
|
|
1203
|
+
}
|
|
1204
|
+
new lruCache_LRUCache({
|
|
1205
|
+
maxSize: 256,
|
|
1206
|
+
maxKeyLength: 4096
|
|
1207
|
+
});
|
|
1208
|
+
function interpolateFromTemplate(template, params) {
|
|
1209
|
+
var segments = template.segments, paramCount = template.paramCount;
|
|
1210
|
+
if (params.length < paramCount) throw new Error("Too few parameters provided");
|
|
1211
|
+
if (params.length > paramCount) throw new Error("Too many parameters provided");
|
|
1212
|
+
if (0 === paramCount) return segments[0];
|
|
1213
|
+
var parts = [
|
|
1214
|
+
segments[0]
|
|
1215
|
+
];
|
|
1216
|
+
for(var i = 0; i < params.length; i++){
|
|
1217
|
+
parts.push(escapeValue(params[i]));
|
|
1218
|
+
parts.push(segments[i + 1]);
|
|
1219
|
+
}
|
|
1220
|
+
return parts.join("");
|
|
1221
|
+
}
|
|
1222
|
+
var constants_CC_SINGLE_QUOTE = 39;
|
|
1223
|
+
var constants_CC_DOUBLE_QUOTE = 34;
|
|
1224
|
+
var constants_CC_DASH = 45;
|
|
1225
|
+
var constants_CC_SLASH = 47;
|
|
1226
|
+
var constants_CC_STAR = 42;
|
|
1227
|
+
var constants_CC_NEWLINE = 10;
|
|
1228
|
+
var constants_CC_QUESTION = 63;
|
|
1229
|
+
var CC_SEMICOLON = 59;
|
|
1230
|
+
var CC_SPACE = 32;
|
|
1231
|
+
var constants_STATE_NORMAL = 0;
|
|
1232
|
+
var constants_STATE_SINGLE_QUOTE = 1;
|
|
1233
|
+
var constants_STATE_DOUBLE_QUOTE = 2;
|
|
1234
|
+
var constants_STATE_LINE_COMMENT = 3;
|
|
1235
|
+
var constants_STATE_BLOCK_COMMENT = 4;
|
|
1236
|
+
function _decodeU16(codes) {
|
|
1237
|
+
var len = codes.length;
|
|
1238
|
+
if (0 === len) return "";
|
|
1239
|
+
var batchSize = 1024;
|
|
1240
|
+
if (len <= batchSize) return String.fromCharCode.apply(null, codes);
|
|
1241
|
+
var parts = new Array(Math.ceil(len / batchSize));
|
|
1242
|
+
for(var i = 0; i < parts.length; i++){
|
|
1243
|
+
var start = i * batchSize;
|
|
1244
|
+
var end = Math.min(start + batchSize, len);
|
|
1245
|
+
parts[i] = String.fromCharCode.apply(null, codes.subarray(start, end));
|
|
1246
|
+
}
|
|
1247
|
+
return parts.join("");
|
|
1248
|
+
}
|
|
1249
|
+
var _normCache = new lruCache_LRUCache({
|
|
1250
|
+
maxSize: 256,
|
|
1251
|
+
maxKeyLength: 4096
|
|
1252
|
+
});
|
|
1253
|
+
function _normalize(sql) {
|
|
1254
|
+
var len = sql.length;
|
|
1255
|
+
var needed = len + 1;
|
|
1256
|
+
var outCodes = new Uint16Array(needed);
|
|
1257
|
+
var writePos = 0;
|
|
1258
|
+
var pendingSpace = false;
|
|
1259
|
+
var state = constants_STATE_NORMAL;
|
|
1260
|
+
var questionPositions = [];
|
|
1261
|
+
for(var i = 0; i < len; i++){
|
|
1262
|
+
var code = sql.charCodeAt(i);
|
|
1263
|
+
var nextCode = sql.charCodeAt(i + 1);
|
|
1264
|
+
if (state === constants_STATE_BLOCK_COMMENT) {
|
|
1265
|
+
if (code === constants_CC_STAR && nextCode === constants_CC_SLASH) {
|
|
1266
|
+
state = constants_STATE_NORMAL;
|
|
1267
|
+
i++;
|
|
1268
|
+
if (writePos > 0) pendingSpace = true;
|
|
1211
1269
|
}
|
|
1212
1270
|
continue;
|
|
1213
1271
|
}
|
|
1214
|
-
if (state ===
|
|
1215
|
-
if (code ===
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
continue;
|
|
1219
|
-
}
|
|
1220
|
-
state = STATE_NORMAL;
|
|
1221
|
-
stateStartPos = -1;
|
|
1272
|
+
if (state === constants_STATE_LINE_COMMENT) {
|
|
1273
|
+
if (code === constants_CC_NEWLINE) {
|
|
1274
|
+
state = constants_STATE_NORMAL;
|
|
1275
|
+
if (writePos > 0) pendingSpace = true;
|
|
1222
1276
|
}
|
|
1223
1277
|
continue;
|
|
1224
1278
|
}
|
|
1225
|
-
if (state ===
|
|
1226
|
-
if (code ===
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1279
|
+
if (state === constants_STATE_NORMAL) {
|
|
1280
|
+
if (code === constants_CC_DASH && nextCode === constants_CC_DASH) {
|
|
1281
|
+
state = constants_STATE_LINE_COMMENT;
|
|
1282
|
+
i++;
|
|
1283
|
+
continue;
|
|
1284
|
+
}
|
|
1285
|
+
if (code === constants_CC_SLASH && nextCode === constants_CC_STAR) {
|
|
1286
|
+
state = constants_STATE_BLOCK_COMMENT;
|
|
1287
|
+
i++;
|
|
1288
|
+
continue;
|
|
1233
1289
|
}
|
|
1290
|
+
}
|
|
1291
|
+
if (32 === code || 9 === code || 10 === code || 11 === code || 12 === code || 13 === code) {
|
|
1292
|
+
if (writePos > 0) pendingSpace = true;
|
|
1293
|
+
continue;
|
|
1294
|
+
}
|
|
1295
|
+
if (pendingSpace && writePos > 0) {
|
|
1296
|
+
outCodes[writePos++] = CC_SPACE;
|
|
1297
|
+
pendingSpace = false;
|
|
1298
|
+
}
|
|
1299
|
+
if (code === constants_CC_QUESTION && state === constants_STATE_NORMAL) questionPositions.push(writePos);
|
|
1300
|
+
outCodes[writePos++] = code;
|
|
1301
|
+
if (state === constants_STATE_NORMAL) {
|
|
1302
|
+
if (code === constants_CC_SINGLE_QUOTE) state = constants_STATE_SINGLE_QUOTE;
|
|
1303
|
+
else if (code === constants_CC_DOUBLE_QUOTE) state = constants_STATE_DOUBLE_QUOTE;
|
|
1234
1304
|
continue;
|
|
1235
1305
|
}
|
|
1236
|
-
if (state ===
|
|
1237
|
-
if (code ===
|
|
1306
|
+
if (state === constants_STATE_SINGLE_QUOTE) {
|
|
1307
|
+
if (code === constants_CC_SINGLE_QUOTE && nextCode === constants_CC_SINGLE_QUOTE) {
|
|
1308
|
+
outCodes[writePos++] = nextCode;
|
|
1309
|
+
i++;
|
|
1310
|
+
continue;
|
|
1311
|
+
}
|
|
1312
|
+
if (code === constants_CC_SINGLE_QUOTE) state = constants_STATE_NORMAL;
|
|
1238
1313
|
continue;
|
|
1239
1314
|
}
|
|
1240
|
-
if (state ===
|
|
1241
|
-
if (code ===
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1315
|
+
if (state === constants_STATE_DOUBLE_QUOTE) {
|
|
1316
|
+
if (code === constants_CC_DOUBLE_QUOTE && nextCode === constants_CC_DOUBLE_QUOTE) {
|
|
1317
|
+
outCodes[writePos++] = nextCode;
|
|
1318
|
+
i++;
|
|
1319
|
+
continue;
|
|
1245
1320
|
}
|
|
1321
|
+
if (code === constants_CC_DOUBLE_QUOTE) state = constants_STATE_NORMAL;
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
var normalized;
|
|
1325
|
+
if (0 === writePos) normalized = ";";
|
|
1326
|
+
else {
|
|
1327
|
+
while(writePos > 0 && outCodes[writePos - 1] === CC_SEMICOLON)writePos--;
|
|
1328
|
+
outCodes[writePos++] = CC_SEMICOLON;
|
|
1329
|
+
normalized = _decodeU16(outCodes.subarray(0, writePos));
|
|
1330
|
+
}
|
|
1331
|
+
var paramCount = questionPositions.length;
|
|
1332
|
+
if (0 === paramCount) return {
|
|
1333
|
+
normalized: normalized,
|
|
1334
|
+
segments: [
|
|
1335
|
+
normalized
|
|
1336
|
+
],
|
|
1337
|
+
paramCount: 0
|
|
1338
|
+
};
|
|
1339
|
+
var segments = [];
|
|
1340
|
+
var segStart = 0;
|
|
1341
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
1342
|
+
try {
|
|
1343
|
+
for(var _iterator = questionPositions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1344
|
+
var pos = _step.value;
|
|
1345
|
+
segments.push(normalized.slice(segStart, pos));
|
|
1346
|
+
segStart = pos + 1;
|
|
1347
|
+
}
|
|
1348
|
+
} catch (err) {
|
|
1349
|
+
_didIteratorError = true;
|
|
1350
|
+
_iteratorError = err;
|
|
1351
|
+
} finally{
|
|
1352
|
+
try {
|
|
1353
|
+
if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
|
|
1354
|
+
} finally{
|
|
1355
|
+
if (_didIteratorError) throw _iteratorError;
|
|
1246
1356
|
}
|
|
1247
1357
|
}
|
|
1248
|
-
|
|
1249
|
-
if (state === STATE_DOUBLE_QUOTE) throw new Error("Unterminated double-quoted identifier/string starting at position ".concat(stateStartPos + 1));
|
|
1250
|
-
if (state === STATE_BLOCK_COMMENT) throw new Error("Unterminated block comment starting at position ".concat(stateStartPos + 1));
|
|
1251
|
-
segments.push(sql.slice(segStart));
|
|
1358
|
+
segments.push(normalized.slice(segStart));
|
|
1252
1359
|
return {
|
|
1360
|
+
normalized: normalized,
|
|
1253
1361
|
segments: segments,
|
|
1254
|
-
paramCount:
|
|
1362
|
+
paramCount: paramCount
|
|
1255
1363
|
};
|
|
1256
1364
|
}
|
|
1257
|
-
function
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
var
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
if (0 === paramCount) return segments[0];
|
|
1271
|
-
var parts = [
|
|
1272
|
-
segments[0]
|
|
1273
|
-
];
|
|
1274
|
-
for(var i = 0; i < params.length; i++){
|
|
1275
|
-
parts.push(escapeValue(params[i]));
|
|
1276
|
-
parts.push(segments[i + 1]);
|
|
1277
|
-
}
|
|
1278
|
-
return parts.join("");
|
|
1365
|
+
function normalizeSQL(sql) {
|
|
1366
|
+
var cached = _normCache.get(sql);
|
|
1367
|
+
if (void 0 !== cached) return cached.normalized;
|
|
1368
|
+
var result = _normalize(sql);
|
|
1369
|
+
_normCache.set(sql, result);
|
|
1370
|
+
return result.normalized;
|
|
1371
|
+
}
|
|
1372
|
+
function normalizeSQLTemplate(sql) {
|
|
1373
|
+
var cached = _normCache.get(sql);
|
|
1374
|
+
if (void 0 !== cached) return cached;
|
|
1375
|
+
var result = _normalize(sql);
|
|
1376
|
+
_normCache.set(sql, result);
|
|
1377
|
+
return result;
|
|
1279
1378
|
}
|
|
1280
1379
|
var READ_ONLY_KINDS = new Set([
|
|
1281
1380
|
"SELECT",
|
|
@@ -1289,8 +1388,8 @@ var _classifyCache = new lruCache_LRUCache({
|
|
|
1289
1388
|
});
|
|
1290
1389
|
function classifySingle(stmt) {
|
|
1291
1390
|
var trimmed = stmt.trim();
|
|
1292
|
-
|
|
1293
|
-
var kind = trimmed.
|
|
1391
|
+
var firstSpace = trimmed.indexOf(" ");
|
|
1392
|
+
var kind = (-1 === firstSpace ? trimmed : trimmed.slice(0, firstSpace)).toUpperCase();
|
|
1294
1393
|
return READ_ONLY_KINDS.has(kind) ? "read" : "write";
|
|
1295
1394
|
}
|
|
1296
1395
|
function classifySQL(sql) {
|
|
@@ -1301,7 +1400,10 @@ function classifySQL(sql) {
|
|
|
1301
1400
|
if (0 === trimmed.length) return "write";
|
|
1302
1401
|
var result;
|
|
1303
1402
|
if (trimmed.includes(";")) {
|
|
1304
|
-
var stmts = trimmed.split(";")
|
|
1403
|
+
var stmts = trimmed.split(";").filter(function(s) {
|
|
1404
|
+
return s.trim().length > 0;
|
|
1405
|
+
});
|
|
1406
|
+
if (0 === stmts.length) return "write";
|
|
1305
1407
|
result = "read";
|
|
1306
1408
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
1307
1409
|
try {
|
|
@@ -1380,11 +1482,11 @@ function queue_class_private_field_update(receiver, privateMap) {
|
|
|
1380
1482
|
var descriptor = queue_class_extract_field_descriptor(receiver, privateMap, "update");
|
|
1381
1483
|
return queue_class_apply_descriptor_update(receiver, descriptor);
|
|
1382
1484
|
}
|
|
1383
|
-
function
|
|
1485
|
+
function queue_class_private_method_get(receiver, privateSet, fn) {
|
|
1384
1486
|
if (!privateSet.has(receiver)) throw new TypeError("attempted to get private field on non-instance");
|
|
1385
1487
|
return fn;
|
|
1386
1488
|
}
|
|
1387
|
-
function
|
|
1489
|
+
function queue_class_private_method_init(obj, privateSet) {
|
|
1388
1490
|
queue_check_private_redeclaration(obj, privateSet);
|
|
1389
1491
|
privateSet.add(obj);
|
|
1390
1492
|
}
|
|
@@ -1503,8 +1605,8 @@ var queue_Queue = /*#__PURE__*/ function() {
|
|
|
1503
1605
|
"use strict";
|
|
1504
1606
|
function Queue() {
|
|
1505
1607
|
queue_class_call_check(this, Queue);
|
|
1506
|
-
|
|
1507
|
-
|
|
1608
|
+
queue_class_private_method_init(this, _grow);
|
|
1609
|
+
queue_class_private_method_init(this, _shrinkIfNeeded);
|
|
1508
1610
|
queue_class_private_field_init(this, _items, {
|
|
1509
1611
|
writable: true,
|
|
1510
1612
|
value: new Array(INITIAL_CAPACITY)
|
|
@@ -1530,7 +1632,7 @@ var queue_Queue = /*#__PURE__*/ function() {
|
|
|
1530
1632
|
{
|
|
1531
1633
|
key: "enqueue",
|
|
1532
1634
|
value: function(value) {
|
|
1533
|
-
if (queue_class_private_field_get(this, _size) === queue_class_private_field_get(this, _items).length)
|
|
1635
|
+
if (queue_class_private_field_get(this, _size) === queue_class_private_field_get(this, _items).length) queue_class_private_method_get(this, _grow, grow).call(this);
|
|
1534
1636
|
queue_class_private_field_get(this, _items)[queue_class_private_field_get(this, _tail)] = value;
|
|
1535
1637
|
queue_class_private_field_set(this, _tail, queue_class_private_field_get(this, _tail) + 1 & queue_class_private_field_get(this, _mask));
|
|
1536
1638
|
queue_class_private_field_update(this, _size).value++;
|
|
@@ -1554,7 +1656,7 @@ var queue_Queue = /*#__PURE__*/ function() {
|
|
|
1554
1656
|
queue_class_private_field_set(this, _head, 0);
|
|
1555
1657
|
queue_class_private_field_set(this, _tail, 0);
|
|
1556
1658
|
queue_class_private_field_set(this, _size, 0);
|
|
1557
|
-
|
|
1659
|
+
queue_class_private_method_get(this, _shrinkIfNeeded, shrinkIfNeeded).call(this);
|
|
1558
1660
|
}
|
|
1559
1661
|
},
|
|
1560
1662
|
{
|
|
@@ -1715,95 +1817,81 @@ function shrinkIfNeeded() {
|
|
|
1715
1817
|
queue_class_private_field_set(this, _mask, INITIAL_CAPACITY - 1);
|
|
1716
1818
|
}
|
|
1717
1819
|
}
|
|
1718
|
-
function
|
|
1719
|
-
|
|
1720
|
-
var
|
|
1721
|
-
|
|
1722
|
-
return "".concat(normalized).concat(suffix, "\nSELECT '").concat(token, "' AS ").concat(TOKEN_COLUMN, ";\n");
|
|
1820
|
+
function _array_like_to_array(arr, len) {
|
|
1821
|
+
if (null == len || len > arr.length) len = arr.length;
|
|
1822
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
1823
|
+
return arr2;
|
|
1723
1824
|
}
|
|
1724
|
-
function
|
|
1725
|
-
|
|
1726
|
-
return "BEGIN" === s || "BEGIN TRANSACTION" === s || "COMMIT" === s || "COMMIT TRANSACTION" === s || "ROLLBACK" === s || "ROLLBACK TRANSACTION" === s || s.startsWith("BEGIN ") || s.startsWith("COMMIT ") || s.startsWith("ROLLBACK ");
|
|
1825
|
+
function _array_without_holes(arr) {
|
|
1826
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
1727
1827
|
}
|
|
1728
|
-
function
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
if (
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
parts.push(task.sql, "\n");
|
|
1741
|
-
}
|
|
1742
|
-
} catch (err) {
|
|
1743
|
-
_didIteratorError = true;
|
|
1744
|
-
_iteratorError = err;
|
|
1745
|
-
} finally{
|
|
1746
|
-
try {
|
|
1747
|
-
if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
|
|
1748
|
-
} finally{
|
|
1749
|
-
if (_didIteratorError) throw _iteratorError;
|
|
1750
|
-
}
|
|
1751
|
-
}
|
|
1752
|
-
parts.push("COMMIT;\n");
|
|
1753
|
-
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
1754
|
-
try {
|
|
1755
|
-
for(var _iterator1 = batch[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
1756
|
-
var task1 = _step1.value;
|
|
1757
|
-
parts.push("SELECT '".concat(task1.token, "' AS ").concat(TOKEN_COLUMN, ";\n"));
|
|
1758
|
-
}
|
|
1759
|
-
} catch (err) {
|
|
1760
|
-
_didIteratorError1 = true;
|
|
1761
|
-
_iteratorError1 = err;
|
|
1762
|
-
} finally{
|
|
1763
|
-
try {
|
|
1764
|
-
if (!_iteratorNormalCompletion1 && null != _iterator1["return"]) _iterator1["return"]();
|
|
1765
|
-
} finally{
|
|
1766
|
-
if (_didIteratorError1) throw _iteratorError1;
|
|
1767
|
-
}
|
|
1768
|
-
}
|
|
1769
|
-
return parts.join("");
|
|
1828
|
+
function inflightTracker_check_private_redeclaration(obj, privateCollection) {
|
|
1829
|
+
if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
1830
|
+
}
|
|
1831
|
+
function inflightTracker_class_apply_descriptor_get(receiver, descriptor) {
|
|
1832
|
+
if (descriptor.get) return descriptor.get.call(receiver);
|
|
1833
|
+
return descriptor.value;
|
|
1834
|
+
}
|
|
1835
|
+
function inflightTracker_class_apply_descriptor_set(receiver, descriptor, value) {
|
|
1836
|
+
if (descriptor.set) descriptor.set.call(receiver, value);
|
|
1837
|
+
else {
|
|
1838
|
+
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
1839
|
+
descriptor.value = value;
|
|
1770
1840
|
}
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
}
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
try {
|
|
1785
|
-
if (!_iteratorNormalCompletion2 && null != _iterator2["return"]) _iterator2["return"]();
|
|
1786
|
-
} finally{
|
|
1787
|
-
if (_didIteratorError2) throw _iteratorError2;
|
|
1788
|
-
}
|
|
1841
|
+
}
|
|
1842
|
+
function inflightTracker_class_apply_descriptor_update(receiver, descriptor) {
|
|
1843
|
+
if (descriptor.set) {
|
|
1844
|
+
if (!descriptor.get) throw new TypeError("attempted to read set only private field");
|
|
1845
|
+
if (!("__destrWrapper" in descriptor)) descriptor.__destrWrapper = {
|
|
1846
|
+
set value (v){
|
|
1847
|
+
descriptor.set.call(receiver, v);
|
|
1848
|
+
},
|
|
1849
|
+
get value () {
|
|
1850
|
+
return descriptor.get.call(receiver);
|
|
1851
|
+
}
|
|
1852
|
+
};
|
|
1853
|
+
return descriptor.__destrWrapper;
|
|
1789
1854
|
}
|
|
1790
|
-
|
|
1855
|
+
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
1856
|
+
return descriptor;
|
|
1791
1857
|
}
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
return raw.charCodeAt(3) === TC_FIRST_CHAR && raw === '[{"'.concat(TOKEN_COLUMN, '":"').concat(token, '"}]');
|
|
1858
|
+
function inflightTracker_class_call_check(instance, Constructor) {
|
|
1859
|
+
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
1795
1860
|
}
|
|
1796
|
-
function
|
|
1797
|
-
|
|
1798
|
-
return
|
|
1861
|
+
function inflightTracker_class_extract_field_descriptor(receiver, privateMap, action) {
|
|
1862
|
+
if (!privateMap.has(receiver)) throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
1863
|
+
return privateMap.get(receiver);
|
|
1799
1864
|
}
|
|
1800
|
-
function
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
return arr2;
|
|
1865
|
+
function inflightTracker_class_private_field_get(receiver, privateMap) {
|
|
1866
|
+
var descriptor = inflightTracker_class_extract_field_descriptor(receiver, privateMap, "get");
|
|
1867
|
+
return inflightTracker_class_apply_descriptor_get(receiver, descriptor);
|
|
1804
1868
|
}
|
|
1805
|
-
function
|
|
1806
|
-
|
|
1869
|
+
function inflightTracker_class_private_field_init(obj, privateMap, value) {
|
|
1870
|
+
inflightTracker_check_private_redeclaration(obj, privateMap);
|
|
1871
|
+
privateMap.set(obj, value);
|
|
1872
|
+
}
|
|
1873
|
+
function inflightTracker_class_private_field_set(receiver, privateMap, value) {
|
|
1874
|
+
var descriptor = inflightTracker_class_extract_field_descriptor(receiver, privateMap, "set");
|
|
1875
|
+
inflightTracker_class_apply_descriptor_set(receiver, descriptor, value);
|
|
1876
|
+
return value;
|
|
1877
|
+
}
|
|
1878
|
+
function inflightTracker_class_private_field_update(receiver, privateMap) {
|
|
1879
|
+
var descriptor = inflightTracker_class_extract_field_descriptor(receiver, privateMap, "update");
|
|
1880
|
+
return inflightTracker_class_apply_descriptor_update(receiver, descriptor);
|
|
1881
|
+
}
|
|
1882
|
+
function inflightTracker_defineProperties(target, props) {
|
|
1883
|
+
for(var i = 0; i < props.length; i++){
|
|
1884
|
+
var descriptor = props[i];
|
|
1885
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
1886
|
+
descriptor.configurable = true;
|
|
1887
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
1888
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
function inflightTracker_create_class(Constructor, protoProps, staticProps) {
|
|
1892
|
+
if (protoProps) inflightTracker_defineProperties(Constructor.prototype, protoProps);
|
|
1893
|
+
if (staticProps) inflightTracker_defineProperties(Constructor, staticProps);
|
|
1894
|
+
return Constructor;
|
|
1807
1895
|
}
|
|
1808
1896
|
function _iterable_to_array(iter) {
|
|
1809
1897
|
if ("undefined" != typeof Symbol && null != iter[Symbol.iterator] || null != iter["@@iterator"]) return Array.from(iter);
|
|
@@ -1822,12 +1910,94 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
1822
1910
|
if ("Map" === n || "Set" === n) return Array.from(n);
|
|
1823
1911
|
if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
1824
1912
|
}
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
(
|
|
1913
|
+
var _tasks = /*#__PURE__*/ new WeakMap(), inflightTracker_head = /*#__PURE__*/ new WeakMap();
|
|
1914
|
+
var inflightTracker_InflightTracker = /*#__PURE__*/ function() {
|
|
1915
|
+
"use strict";
|
|
1916
|
+
function InflightTracker() {
|
|
1917
|
+
inflightTracker_class_call_check(this, InflightTracker);
|
|
1918
|
+
inflightTracker_class_private_field_init(this, _tasks, {
|
|
1919
|
+
writable: true,
|
|
1920
|
+
value: []
|
|
1921
|
+
});
|
|
1922
|
+
inflightTracker_class_private_field_init(this, inflightTracker_head, {
|
|
1923
|
+
writable: true,
|
|
1924
|
+
value: 0
|
|
1925
|
+
});
|
|
1830
1926
|
}
|
|
1927
|
+
inflightTracker_create_class(InflightTracker, [
|
|
1928
|
+
{
|
|
1929
|
+
key: "count",
|
|
1930
|
+
get: function() {
|
|
1931
|
+
return inflightTracker_class_private_field_get(this, _tasks).length - inflightTracker_class_private_field_get(this, inflightTracker_head);
|
|
1932
|
+
}
|
|
1933
|
+
},
|
|
1934
|
+
{
|
|
1935
|
+
key: "first",
|
|
1936
|
+
get: function() {
|
|
1937
|
+
return inflightTracker_class_private_field_get(this, inflightTracker_head) < inflightTracker_class_private_field_get(this, _tasks).length ? inflightTracker_class_private_field_get(this, _tasks)[inflightTracker_class_private_field_get(this, inflightTracker_head)] : null;
|
|
1938
|
+
}
|
|
1939
|
+
},
|
|
1940
|
+
{
|
|
1941
|
+
key: "push",
|
|
1942
|
+
value: function() {
|
|
1943
|
+
for(var _len = arguments.length, items = new Array(_len), _key = 0; _key < _len; _key++)items[_key] = arguments[_key];
|
|
1944
|
+
var _$_class_private_field_get;
|
|
1945
|
+
(_$_class_private_field_get = inflightTracker_class_private_field_get(this, _tasks)).push.apply(_$_class_private_field_get, _to_consumable_array(items));
|
|
1946
|
+
}
|
|
1947
|
+
},
|
|
1948
|
+
{
|
|
1949
|
+
key: "shift",
|
|
1950
|
+
value: function() {
|
|
1951
|
+
if (inflightTracker_class_private_field_get(this, _tasks).length === inflightTracker_class_private_field_get(this, inflightTracker_head)) return null;
|
|
1952
|
+
var task = inflightTracker_class_private_field_get(this, _tasks)[inflightTracker_class_private_field_get(this, inflightTracker_head)];
|
|
1953
|
+
inflightTracker_class_private_field_get(this, _tasks)[inflightTracker_class_private_field_get(this, inflightTracker_head)] = null;
|
|
1954
|
+
inflightTracker_class_private_field_update(this, inflightTracker_head).value++;
|
|
1955
|
+
if (inflightTracker_class_private_field_get(this, inflightTracker_head) >= inflightTracker_class_private_field_get(this, _tasks).length) {
|
|
1956
|
+
inflightTracker_class_private_field_set(this, _tasks, []);
|
|
1957
|
+
inflightTracker_class_private_field_set(this, inflightTracker_head, 0);
|
|
1958
|
+
} else if (inflightTracker_class_private_field_get(this, inflightTracker_head) > INFLIGHT_COMPACT_THRESHOLD) {
|
|
1959
|
+
inflightTracker_class_private_field_set(this, _tasks, inflightTracker_class_private_field_get(this, _tasks).slice(inflightTracker_class_private_field_get(this, inflightTracker_head)));
|
|
1960
|
+
inflightTracker_class_private_field_set(this, inflightTracker_head, 0);
|
|
1961
|
+
}
|
|
1962
|
+
return task;
|
|
1963
|
+
}
|
|
1964
|
+
},
|
|
1965
|
+
{
|
|
1966
|
+
key: "clear",
|
|
1967
|
+
value: function() {
|
|
1968
|
+
inflightTracker_class_private_field_set(this, _tasks, []);
|
|
1969
|
+
inflightTracker_class_private_field_set(this, inflightTracker_head, 0);
|
|
1970
|
+
}
|
|
1971
|
+
},
|
|
1972
|
+
{
|
|
1973
|
+
key: "forEach",
|
|
1974
|
+
value: function(fn) {
|
|
1975
|
+
for(var i = inflightTracker_class_private_field_get(this, inflightTracker_head); i < inflightTracker_class_private_field_get(this, _tasks).length; i++)fn(inflightTracker_class_private_field_get(this, _tasks)[i]);
|
|
1976
|
+
}
|
|
1977
|
+
},
|
|
1978
|
+
{
|
|
1979
|
+
key: "toArray",
|
|
1980
|
+
value: function() {
|
|
1981
|
+
return inflightTracker_class_private_field_get(this, _tasks).slice(inflightTracker_class_private_field_get(this, inflightTracker_head));
|
|
1982
|
+
}
|
|
1983
|
+
},
|
|
1984
|
+
{
|
|
1985
|
+
key: "_tasksLength",
|
|
1986
|
+
get: function() {
|
|
1987
|
+
return inflightTracker_class_private_field_get(this, _tasks).length;
|
|
1988
|
+
}
|
|
1989
|
+
},
|
|
1990
|
+
{
|
|
1991
|
+
key: "_head",
|
|
1992
|
+
get: function() {
|
|
1993
|
+
return inflightTracker_class_private_field_get(this, inflightTracker_head);
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
]);
|
|
1997
|
+
return InflightTracker;
|
|
1998
|
+
}();
|
|
1999
|
+
function collectQueryRows(task, parsed) {
|
|
2000
|
+
if (Array.isArray(parsed)) for(var i = 0; i < parsed.length; i++)task.rows.push(parsed[i]);
|
|
1831
2001
|
}
|
|
1832
2002
|
function processStreamRows(task, parsed) {
|
|
1833
2003
|
if (!Array.isArray(parsed)) return;
|
|
@@ -1853,7 +2023,7 @@ function processStreamRows(task, parsed) {
|
|
|
1853
2023
|
}
|
|
1854
2024
|
}
|
|
1855
2025
|
}
|
|
1856
|
-
function
|
|
2026
|
+
function settleUtils_settleTask(task, error, value, metrics) {
|
|
1857
2027
|
var _ref = arguments.length > 4 && void 0 !== arguments[4] ? arguments[4] : {}, _ref_resetRowParser = _ref.resetRowParser, resetRowParser = void 0 === _ref_resetRowParser ? false : _ref_resetRowParser;
|
|
1858
2028
|
if (task.settled) return;
|
|
1859
2029
|
task.settled = true;
|
|
@@ -1870,11 +2040,159 @@ function settleTask(task, error, value, metrics) {
|
|
|
1870
2040
|
null == metrics || metrics.incrementTasksSuccess(duration);
|
|
1871
2041
|
task.resolve(value);
|
|
1872
2042
|
}
|
|
1873
|
-
function
|
|
1874
|
-
var
|
|
2043
|
+
function buildPayload(sql, token) {
|
|
2044
|
+
var _ref = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {}, _ref_skipNormalize = _ref.skipNormalize, skipNormalize = void 0 === _ref_skipNormalize ? false : _ref_skipNormalize;
|
|
2045
|
+
var normalized = skipNormalize ? sql : normalizeSQL(sql);
|
|
2046
|
+
var suffix = normalized.endsWith(";") ? "" : ";";
|
|
2047
|
+
return "".concat(normalized).concat(suffix, "\nSELECT '").concat(token, "' AS ").concat(TOKEN_COLUMN, ";\n");
|
|
2048
|
+
}
|
|
2049
|
+
function isTransactionControl(sql) {
|
|
2050
|
+
var f = sql.charCodeAt(0);
|
|
2051
|
+
if (66 === f || 98 === f) return "BEGIN" === sql || "BEGIN;" === sql || sql.startsWith("BEGIN ") || sql.startsWith("BEGIN;");
|
|
2052
|
+
if (67 === f || 99 === f) return "COMMIT" === sql || "COMMIT;" === sql || sql.startsWith("COMMIT ") || sql.startsWith("COMMIT;");
|
|
2053
|
+
if (82 === f || 114 === f) return "ROLLBACK" === sql || "ROLLBACK;" === sql || sql.startsWith("ROLLBACK ") || sql.startsWith("ROLLBACK;");
|
|
2054
|
+
return false;
|
|
2055
|
+
}
|
|
2056
|
+
function buildBatchPayload(batch) {
|
|
2057
|
+
var useWalBatch = batch.length > 1 && batch.every(function(t) {
|
|
2058
|
+
return "execute" === t.kind && !isTransactionControl(t.sql);
|
|
2059
|
+
});
|
|
2060
|
+
if (useWalBatch) {
|
|
2061
|
+
var parts = [
|
|
2062
|
+
"BEGIN;\n"
|
|
2063
|
+
];
|
|
2064
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
2065
|
+
try {
|
|
2066
|
+
for(var _iterator = batch[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2067
|
+
var task = _step.value;
|
|
2068
|
+
parts.push(task.sql, "\n");
|
|
2069
|
+
}
|
|
2070
|
+
} catch (err) {
|
|
2071
|
+
_didIteratorError = true;
|
|
2072
|
+
_iteratorError = err;
|
|
2073
|
+
} finally{
|
|
2074
|
+
try {
|
|
2075
|
+
if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
|
|
2076
|
+
} finally{
|
|
2077
|
+
if (_didIteratorError) throw _iteratorError;
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
parts.push("COMMIT;\n");
|
|
2081
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
2082
|
+
try {
|
|
2083
|
+
for(var _iterator1 = batch[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
2084
|
+
var task1 = _step1.value;
|
|
2085
|
+
parts.push("SELECT '".concat(task1.token, "' AS ").concat(TOKEN_COLUMN, ";\n"));
|
|
2086
|
+
}
|
|
2087
|
+
} catch (err) {
|
|
2088
|
+
_didIteratorError1 = true;
|
|
2089
|
+
_iteratorError1 = err;
|
|
2090
|
+
} finally{
|
|
2091
|
+
try {
|
|
2092
|
+
if (!_iteratorNormalCompletion1 && null != _iterator1["return"]) _iterator1["return"]();
|
|
2093
|
+
} finally{
|
|
2094
|
+
if (_didIteratorError1) throw _iteratorError1;
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
return parts.join("");
|
|
2098
|
+
}
|
|
2099
|
+
var parts1 = [];
|
|
2100
|
+
var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
|
|
1875
2101
|
try {
|
|
1876
|
-
for(var
|
|
1877
|
-
var
|
|
2102
|
+
for(var _iterator2 = batch[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true){
|
|
2103
|
+
var task2 = _step2.value;
|
|
2104
|
+
parts1.push(buildPayload(task2.sql, task2.token, {
|
|
2105
|
+
skipNormalize: true
|
|
2106
|
+
}));
|
|
2107
|
+
}
|
|
2108
|
+
} catch (err) {
|
|
2109
|
+
_didIteratorError2 = true;
|
|
2110
|
+
_iteratorError2 = err;
|
|
2111
|
+
} finally{
|
|
2112
|
+
try {
|
|
2113
|
+
if (!_iteratorNormalCompletion2 && null != _iterator2["return"]) _iterator2["return"]();
|
|
2114
|
+
} finally{
|
|
2115
|
+
if (_didIteratorError2) throw _iteratorError2;
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2118
|
+
return parts1.join("");
|
|
2119
|
+
}
|
|
2120
|
+
var TC_FIRST_CHAR = TOKEN_COLUMN.charCodeAt(0);
|
|
2121
|
+
function buildSentinelStr(token) {
|
|
2122
|
+
return '[{"'.concat(TOKEN_COLUMN, '":"').concat(token, '"}]');
|
|
2123
|
+
}
|
|
2124
|
+
function isSentinelRaw(raw, token) {
|
|
2125
|
+
return raw.charCodeAt(3) === TC_FIRST_CHAR && raw === buildSentinelStr(token);
|
|
2126
|
+
}
|
|
2127
|
+
function isSentinelRow(value, token) {
|
|
2128
|
+
var _value_;
|
|
2129
|
+
return Array.isArray(value) && 1 === value.length && (null == (_value_ = value[0]) ? void 0 : _value_[TOKEN_COLUMN]) === token;
|
|
2130
|
+
}
|
|
2131
|
+
function pipelineUtils_array_like_to_array(arr, len) {
|
|
2132
|
+
if (null == len || len > arr.length) len = arr.length;
|
|
2133
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
2134
|
+
return arr2;
|
|
2135
|
+
}
|
|
2136
|
+
function pipelineUtils_array_without_holes(arr) {
|
|
2137
|
+
if (Array.isArray(arr)) return pipelineUtils_array_like_to_array(arr);
|
|
2138
|
+
}
|
|
2139
|
+
function pipelineUtils_iterable_to_array(iter) {
|
|
2140
|
+
if ("undefined" != typeof Symbol && null != iter[Symbol.iterator] || null != iter["@@iterator"]) return Array.from(iter);
|
|
2141
|
+
}
|
|
2142
|
+
function pipelineUtils_non_iterable_spread() {
|
|
2143
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2144
|
+
}
|
|
2145
|
+
function pipelineUtils_to_consumable_array(arr) {
|
|
2146
|
+
return pipelineUtils_array_without_holes(arr) || pipelineUtils_iterable_to_array(arr) || pipelineUtils_unsupported_iterable_to_array(arr) || pipelineUtils_non_iterable_spread();
|
|
2147
|
+
}
|
|
2148
|
+
function pipelineUtils_unsupported_iterable_to_array(o, minLen) {
|
|
2149
|
+
if (!o) return;
|
|
2150
|
+
if ("string" == typeof o) return pipelineUtils_array_like_to_array(o, minLen);
|
|
2151
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
2152
|
+
if ("Object" === n && o.constructor) n = o.constructor.name;
|
|
2153
|
+
if ("Map" === n || "Set" === n) return Array.from(n);
|
|
2154
|
+
if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return pipelineUtils_array_like_to_array(o, minLen);
|
|
2155
|
+
}
|
|
2156
|
+
function finalizePendingTasks(tasks, settle, pumpQueue, pendingStderr, inflight) {
|
|
2157
|
+
var hasStderrBuffer = pendingStderr && pendingStderr.length > 0;
|
|
2158
|
+
if (hasStderrBuffer) {
|
|
2159
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
2160
|
+
try {
|
|
2161
|
+
for(var _iterator = pendingStderr[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2162
|
+
var chunk = _step.value;
|
|
2163
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
2164
|
+
try {
|
|
2165
|
+
for(var _iterator1 = tasks[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
2166
|
+
var t = _step1.value;
|
|
2167
|
+
if ("query" === t.kind && 0 === t.rows.length) t.stderrText += chunk;
|
|
2168
|
+
}
|
|
2169
|
+
} catch (err) {
|
|
2170
|
+
_didIteratorError1 = true;
|
|
2171
|
+
_iteratorError1 = err;
|
|
2172
|
+
} finally{
|
|
2173
|
+
try {
|
|
2174
|
+
if (!_iteratorNormalCompletion1 && null != _iterator1["return"]) _iterator1["return"]();
|
|
2175
|
+
} finally{
|
|
2176
|
+
if (_didIteratorError1) throw _iteratorError1;
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
} catch (err) {
|
|
2181
|
+
_didIteratorError = true;
|
|
2182
|
+
_iteratorError = err;
|
|
2183
|
+
} finally{
|
|
2184
|
+
try {
|
|
2185
|
+
if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
|
|
2186
|
+
} finally{
|
|
2187
|
+
if (_didIteratorError) throw _iteratorError;
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
if (!inflight || 0 === inflight.count) pendingStderr.length = 0;
|
|
2191
|
+
}
|
|
2192
|
+
var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
|
|
2193
|
+
try {
|
|
2194
|
+
for(var _iterator2 = tasks[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true){
|
|
2195
|
+
var task = _step2.value;
|
|
1878
2196
|
if (task.stderrText) {
|
|
1879
2197
|
settle(task, new Error(task.stderrText.trim()), void 0);
|
|
1880
2198
|
continue;
|
|
@@ -1890,13 +2208,13 @@ function finalizePendingTasks(tasks, settle, pumpQueue) {
|
|
|
1890
2208
|
settle(task, null, void 0);
|
|
1891
2209
|
}
|
|
1892
2210
|
} catch (err) {
|
|
1893
|
-
|
|
1894
|
-
|
|
2211
|
+
_didIteratorError2 = true;
|
|
2212
|
+
_iteratorError2 = err;
|
|
1895
2213
|
} finally{
|
|
1896
2214
|
try {
|
|
1897
|
-
if (!
|
|
2215
|
+
if (!_iteratorNormalCompletion2 && null != _iterator2["return"]) _iterator2["return"]();
|
|
1898
2216
|
} finally{
|
|
1899
|
-
if (
|
|
2217
|
+
if (_didIteratorError2) throw _iteratorError2;
|
|
1900
2218
|
}
|
|
1901
2219
|
}
|
|
1902
2220
|
tasks.clear();
|
|
@@ -1908,13 +2226,292 @@ function prepareTaskTimeout(task, metrics) {
|
|
|
1908
2226
|
null == metrics || metrics.incrementTasksTimeout();
|
|
1909
2227
|
return createTimeoutError(task.timeout, task.sql);
|
|
1910
2228
|
}
|
|
1911
|
-
function
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
2229
|
+
function createSweeper(param) {
|
|
2230
|
+
var inflight = param.inflight, sweepIntervalMs = param.sweepIntervalMs, handleTaskTimeout = param.handleTaskTimeout;
|
|
2231
|
+
var sweepTimer = null;
|
|
2232
|
+
var schedule = function() {
|
|
2233
|
+
if (sweepTimer) return;
|
|
2234
|
+
sweepTimer = setTimeout(function() {
|
|
2235
|
+
sweepTimer = null;
|
|
2236
|
+
var now = performance.now();
|
|
2237
|
+
inflight.forEach(function(task) {
|
|
2238
|
+
if (now - task.startTime > task.timeout) handleTaskTimeout(task);
|
|
2239
|
+
});
|
|
2240
|
+
if (inflight.count > 0) schedule();
|
|
2241
|
+
}, sweepIntervalMs).unref();
|
|
2242
|
+
};
|
|
2243
|
+
var clear = function() {
|
|
2244
|
+
clearTimeout(sweepTimer);
|
|
2245
|
+
sweepTimer = null;
|
|
2246
|
+
};
|
|
2247
|
+
return {
|
|
2248
|
+
schedule: schedule,
|
|
2249
|
+
clear: clear,
|
|
2250
|
+
getSweepTimer: function() {
|
|
2251
|
+
return sweepTimer;
|
|
2252
|
+
}
|
|
2253
|
+
};
|
|
2254
|
+
}
|
|
2255
|
+
function createFinalizeScheduler(param) {
|
|
2256
|
+
var pendingFinalizeTasks = param.pendingFinalizeTasks, settle = param.settleTask, pumpQueue = param.pumpQueue, pendingStderr = param.pendingStderr, inflight = param.inflight;
|
|
2257
|
+
var scheduled = false;
|
|
2258
|
+
var immediate = null;
|
|
2259
|
+
var cancelled = false;
|
|
2260
|
+
var cancel = function() {
|
|
2261
|
+
cancelled = true;
|
|
2262
|
+
if (immediate) {
|
|
2263
|
+
clearImmediate(immediate);
|
|
2264
|
+
immediate = null;
|
|
2265
|
+
}
|
|
2266
|
+
};
|
|
2267
|
+
var check = function() {
|
|
2268
|
+
if (cancelled) return;
|
|
2269
|
+
if (scheduled) return;
|
|
2270
|
+
if (0 === pendingFinalizeTasks.size) return;
|
|
2271
|
+
scheduled = true;
|
|
2272
|
+
immediate = setImmediate(function() {
|
|
2273
|
+
immediate = null;
|
|
2274
|
+
if (cancelled) return;
|
|
2275
|
+
finalizePendingTasks(pendingFinalizeTasks, settle, pumpQueue, pendingStderr, inflight);
|
|
2276
|
+
scheduled = false;
|
|
2277
|
+
});
|
|
2278
|
+
};
|
|
2279
|
+
check.cancel = cancel;
|
|
2280
|
+
return check;
|
|
2281
|
+
}
|
|
2282
|
+
function handleParsedValue(raw, inflight, param) {
|
|
2283
|
+
var afterSentinel = param.afterSentinel, rejectAll = param.rejectAll;
|
|
2284
|
+
var task = inflight.first;
|
|
2285
|
+
if (!task) return;
|
|
2286
|
+
if (isSentinelRaw(raw, task.token)) {
|
|
2287
|
+
inflight.shift();
|
|
2288
|
+
afterSentinel(task);
|
|
2289
|
+
return;
|
|
2290
|
+
}
|
|
2291
|
+
if ("[]" === raw) return;
|
|
2292
|
+
var parsed;
|
|
2293
|
+
try {
|
|
2294
|
+
parsed = JSON.parse(raw);
|
|
2295
|
+
} catch (error) {
|
|
2296
|
+
rejectAll(new Error("Invalid JSON from sqlite3: ".concat(toError(error).message)));
|
|
2297
|
+
return;
|
|
2298
|
+
}
|
|
2299
|
+
if (isSentinelRow(parsed, task.token)) {
|
|
2300
|
+
inflight.shift();
|
|
2301
|
+
afterSentinel(task);
|
|
2302
|
+
return;
|
|
2303
|
+
}
|
|
2304
|
+
if (task.timedout) return;
|
|
2305
|
+
if ("query" === task.kind) return void collectQueryRows(task, parsed);
|
|
2306
|
+
if ("stream" === task.kind) processStreamRows(task, parsed);
|
|
2307
|
+
}
|
|
2308
|
+
function createPumpQueue(param) {
|
|
2309
|
+
var queue = param.queue, inflight = param.inflight, processManager = param.processManager, sweeper = param.sweeper, batchSize = param.batchSize, maxInflight = param.maxInflight;
|
|
2310
|
+
var nextBatchId = 1;
|
|
2311
|
+
return function pump() {
|
|
2312
|
+
var _inflight;
|
|
2313
|
+
if (processManager.draining) return void processManager.onDrained(function() {
|
|
2314
|
+
return pump();
|
|
2315
|
+
});
|
|
2316
|
+
if (inflight.count >= maxInflight) return;
|
|
2317
|
+
var batch = [];
|
|
2318
|
+
while(batch.length < batchSize && !queue.isEmpty() && inflight.count + batch.length < maxInflight){
|
|
2319
|
+
var task = queue.peek();
|
|
2320
|
+
if ("stream" === task.kind && (batch.length > 0 || inflight.count > 0)) break;
|
|
2321
|
+
queue.dequeue();
|
|
2322
|
+
batch.push(task);
|
|
2323
|
+
}
|
|
2324
|
+
if (0 === batch.length) return;
|
|
2325
|
+
var now = performance.now();
|
|
2326
|
+
var payload = buildBatchPayload(batch);
|
|
2327
|
+
var batchId = nextBatchId++;
|
|
2328
|
+
var useWalBatch = payload.startsWith("BEGIN;");
|
|
2329
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
2330
|
+
try {
|
|
2331
|
+
for(var _iterator = batch[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2332
|
+
var task1 = _step.value;
|
|
2333
|
+
task1.startTime = now;
|
|
2334
|
+
task1.batchId = batchId;
|
|
2335
|
+
task1.walBatch = useWalBatch;
|
|
2336
|
+
}
|
|
2337
|
+
} catch (err) {
|
|
2338
|
+
_didIteratorError = true;
|
|
2339
|
+
_iteratorError = err;
|
|
2340
|
+
} finally{
|
|
2341
|
+
try {
|
|
2342
|
+
if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
|
|
2343
|
+
} finally{
|
|
2344
|
+
if (_didIteratorError) throw _iteratorError;
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
(_inflight = inflight).push.apply(_inflight, pipelineUtils_to_consumable_array(batch));
|
|
2348
|
+
sweeper.schedule();
|
|
2349
|
+
processManager.write(payload);
|
|
2350
|
+
};
|
|
2351
|
+
}
|
|
2352
|
+
function handleSentinelTask(task, param) {
|
|
2353
|
+
var settleTask = param.settleTask, pendingFinalizeTasks = param.pendingFinalizeTasks, scheduleFinalizeCheck = param.scheduleFinalizeCheck, pumpQueue = param.pumpQueue;
|
|
2354
|
+
if (task.timedout) return void pumpQueue();
|
|
2355
|
+
if (task.consumerError) {
|
|
2356
|
+
settleTask(task, task.consumerError, void 0);
|
|
2357
|
+
pumpQueue();
|
|
2358
|
+
return;
|
|
2359
|
+
}
|
|
2360
|
+
pendingFinalizeTasks.add(task);
|
|
2361
|
+
scheduleFinalizeCheck();
|
|
2362
|
+
pumpQueue();
|
|
2363
|
+
}
|
|
2364
|
+
function handleStderrChunk(chunk, param) {
|
|
2365
|
+
var inflight = param.inflight, pendingFinalizeTasks = param.pendingFinalizeTasks, logger = param.logger, pendingStderr = param.pendingStderr;
|
|
2366
|
+
var inflightFirst = inflight.first;
|
|
2367
|
+
var firstPending = pendingFinalizeTasks.values().next().value;
|
|
2368
|
+
var zeroRowMatch = false;
|
|
2369
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
2370
|
+
try {
|
|
2371
|
+
for(var _iterator = pendingFinalizeTasks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2372
|
+
var t = _step.value;
|
|
2373
|
+
if ("query" === t.kind && 0 === t.rows.length) {
|
|
2374
|
+
t.stderrText += chunk;
|
|
2375
|
+
zeroRowMatch = true;
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2378
|
+
} catch (err) {
|
|
2379
|
+
_didIteratorError = true;
|
|
2380
|
+
_iteratorError = err;
|
|
2381
|
+
} finally{
|
|
2382
|
+
try {
|
|
2383
|
+
if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
|
|
2384
|
+
} finally{
|
|
2385
|
+
if (_didIteratorError) throw _iteratorError;
|
|
2386
|
+
}
|
|
2387
|
+
}
|
|
2388
|
+
if (zeroRowMatch) return;
|
|
2389
|
+
var task = null != inflightFirst ? inflightFirst : firstPending;
|
|
2390
|
+
if (!task) {
|
|
2391
|
+
var _logger_error;
|
|
2392
|
+
null == logger || null == (_logger_error = logger.error) || _logger_error.call(logger, chunk.trim());
|
|
2393
|
+
return;
|
|
2394
|
+
}
|
|
2395
|
+
if (null == task.batchId) {
|
|
2396
|
+
task.stderrText += chunk;
|
|
2397
|
+
return;
|
|
2398
|
+
}
|
|
2399
|
+
if (task.walBatch) {
|
|
2400
|
+
task.stderrText += chunk;
|
|
2401
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
2402
|
+
try {
|
|
2403
|
+
for(var _iterator1 = pendingFinalizeTasks[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
2404
|
+
var t1 = _step1.value;
|
|
2405
|
+
if (t1 !== task) t1.stderrText += chunk;
|
|
2406
|
+
}
|
|
2407
|
+
} catch (err) {
|
|
2408
|
+
_didIteratorError1 = true;
|
|
2409
|
+
_iteratorError1 = err;
|
|
2410
|
+
} finally{
|
|
2411
|
+
try {
|
|
2412
|
+
if (!_iteratorNormalCompletion1 && null != _iterator1["return"]) _iterator1["return"]();
|
|
2413
|
+
} finally{
|
|
2414
|
+
if (_didIteratorError1) throw _iteratorError1;
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
inflight.forEach(function(t) {
|
|
2418
|
+
if (t !== task) t.stderrText += chunk;
|
|
2419
|
+
});
|
|
2420
|
+
return;
|
|
2421
|
+
}
|
|
2422
|
+
if (task === inflightFirst) {
|
|
2423
|
+
if (inflight.count > 1) null == pendingStderr || pendingStderr.push(chunk);
|
|
2424
|
+
else if (pendingFinalizeTasks.size > 0) {
|
|
2425
|
+
var hasZeroRowQuery = false;
|
|
2426
|
+
var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
|
|
2427
|
+
try {
|
|
2428
|
+
for(var _iterator2 = pendingFinalizeTasks[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true){
|
|
2429
|
+
var t2 = _step2.value;
|
|
2430
|
+
if ("query" === t2.kind && 0 === t2.rows.length) {
|
|
2431
|
+
hasZeroRowQuery = true;
|
|
2432
|
+
break;
|
|
2433
|
+
}
|
|
2434
|
+
}
|
|
2435
|
+
} catch (err) {
|
|
2436
|
+
_didIteratorError2 = true;
|
|
2437
|
+
_iteratorError2 = err;
|
|
2438
|
+
} finally{
|
|
2439
|
+
try {
|
|
2440
|
+
if (!_iteratorNormalCompletion2 && null != _iterator2["return"]) _iterator2["return"]();
|
|
2441
|
+
} finally{
|
|
2442
|
+
if (_didIteratorError2) throw _iteratorError2;
|
|
2443
|
+
}
|
|
2444
|
+
}
|
|
2445
|
+
if (hasZeroRowQuery) null == pendingStderr || pendingStderr.push(chunk);
|
|
2446
|
+
else if ("query" === task.kind && task.rows.length > 0) {
|
|
2447
|
+
var _logger_error1;
|
|
2448
|
+
null == logger || null == (_logger_error1 = logger.error) || _logger_error1.call(logger, chunk.trim());
|
|
2449
|
+
} else task.stderrText += chunk;
|
|
2450
|
+
} else if ("query" === task.kind && task.rows.length > 0) {
|
|
2451
|
+
var _logger_error2;
|
|
2452
|
+
null == logger || null == (_logger_error2 = logger.error) || _logger_error2.call(logger, chunk.trim());
|
|
2453
|
+
} else task.stderrText += chunk;
|
|
2454
|
+
return;
|
|
2455
|
+
}
|
|
2456
|
+
var _iteratorNormalCompletion3 = true, _didIteratorError3 = false, _iteratorError3 = void 0;
|
|
2457
|
+
try {
|
|
2458
|
+
for(var _iterator3 = pendingFinalizeTasks[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true){
|
|
2459
|
+
var t3 = _step3.value;
|
|
2460
|
+
t3.stderrText += chunk;
|
|
2461
|
+
}
|
|
2462
|
+
} catch (err) {
|
|
2463
|
+
_didIteratorError3 = true;
|
|
2464
|
+
_iteratorError3 = err;
|
|
2465
|
+
} finally{
|
|
2466
|
+
try {
|
|
2467
|
+
if (!_iteratorNormalCompletion3 && null != _iterator3["return"]) _iterator3["return"]();
|
|
2468
|
+
} finally{
|
|
2469
|
+
if (_didIteratorError3) throw _iteratorError3;
|
|
2470
|
+
}
|
|
2471
|
+
}
|
|
1915
2472
|
}
|
|
1916
|
-
function
|
|
1917
|
-
|
|
2473
|
+
function rejectAllTasks(param) {
|
|
2474
|
+
var inflight = param.inflight, queue = param.queue, pendingFinalizeTasks = param.pendingFinalizeTasks, settleTask = param.settleTask, error = param.error;
|
|
2475
|
+
var all = inflight.toArray();
|
|
2476
|
+
inflight.clear();
|
|
2477
|
+
var queued = queue.dequeue();
|
|
2478
|
+
while(queued){
|
|
2479
|
+
settleTask(queued, error, void 0);
|
|
2480
|
+
queued = queue.dequeue();
|
|
2481
|
+
}
|
|
2482
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
2483
|
+
try {
|
|
2484
|
+
for(var _iterator = all[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2485
|
+
var task = _step.value;
|
|
2486
|
+
settleTask(task, error, void 0);
|
|
2487
|
+
}
|
|
2488
|
+
} catch (err) {
|
|
2489
|
+
_didIteratorError = true;
|
|
2490
|
+
_iteratorError = err;
|
|
2491
|
+
} finally{
|
|
2492
|
+
try {
|
|
2493
|
+
if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
|
|
2494
|
+
} finally{
|
|
2495
|
+
if (_didIteratorError) throw _iteratorError;
|
|
2496
|
+
}
|
|
2497
|
+
}
|
|
2498
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
2499
|
+
try {
|
|
2500
|
+
for(var _iterator1 = pendingFinalizeTasks[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
2501
|
+
var task1 = _step1.value;
|
|
2502
|
+
settleTask(task1, error, void 0);
|
|
2503
|
+
}
|
|
2504
|
+
} catch (err) {
|
|
2505
|
+
_didIteratorError1 = true;
|
|
2506
|
+
_iteratorError1 = err;
|
|
2507
|
+
} finally{
|
|
2508
|
+
try {
|
|
2509
|
+
if (!_iteratorNormalCompletion1 && null != _iterator1["return"]) _iterator1["return"]();
|
|
2510
|
+
} finally{
|
|
2511
|
+
if (_didIteratorError1) throw _iteratorError1;
|
|
2512
|
+
}
|
|
2513
|
+
}
|
|
2514
|
+
pendingFinalizeTasks.clear();
|
|
1918
2515
|
}
|
|
1919
2516
|
function taskWorker_check_private_redeclaration(obj, privateCollection) {
|
|
1920
2517
|
if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
@@ -1964,44 +2561,25 @@ function taskWorker_defineProperties(target, props) {
|
|
|
1964
2561
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
1965
2562
|
descriptor.configurable = true;
|
|
1966
2563
|
if ("value" in descriptor) descriptor.writable = true;
|
|
1967
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
1968
|
-
}
|
|
1969
|
-
}
|
|
1970
|
-
function taskWorker_create_class(Constructor, protoProps, staticProps) {
|
|
1971
|
-
if (protoProps) taskWorker_defineProperties(Constructor.prototype, protoProps);
|
|
1972
|
-
if (staticProps) taskWorker_defineProperties(Constructor, staticProps);
|
|
1973
|
-
return Constructor;
|
|
1974
|
-
}
|
|
1975
|
-
function taskWorker_iterable_to_array(iter) {
|
|
1976
|
-
if ("undefined" != typeof Symbol && null != iter[Symbol.iterator] || null != iter["@@iterator"]) return Array.from(iter);
|
|
1977
|
-
}
|
|
1978
|
-
function taskWorker_non_iterable_spread() {
|
|
1979
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1980
|
-
}
|
|
1981
|
-
function taskWorker_to_consumable_array(arr) {
|
|
1982
|
-
return taskWorker_array_without_holes(arr) || taskWorker_iterable_to_array(arr) || taskWorker_unsupported_iterable_to_array(arr) || taskWorker_non_iterable_spread();
|
|
1983
|
-
}
|
|
1984
|
-
function taskWorker_unsupported_iterable_to_array(o, minLen) {
|
|
1985
|
-
if (!o) return;
|
|
1986
|
-
if ("string" == typeof o) return taskWorker_array_like_to_array(o, minLen);
|
|
1987
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1988
|
-
if ("Object" === n && o.constructor) n = o.constructor.name;
|
|
1989
|
-
if ("Map" === n || "Set" === n) return Array.from(n);
|
|
1990
|
-
if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return taskWorker_array_like_to_array(o, minLen);
|
|
2564
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
2565
|
+
}
|
|
2566
|
+
}
|
|
2567
|
+
function taskWorker_create_class(Constructor, protoProps, staticProps) {
|
|
2568
|
+
if (protoProps) taskWorker_defineProperties(Constructor.prototype, protoProps);
|
|
2569
|
+
if (staticProps) taskWorker_defineProperties(Constructor, staticProps);
|
|
2570
|
+
return Constructor;
|
|
1991
2571
|
}
|
|
1992
|
-
var _processManager = /*#__PURE__*/ new WeakMap(), _pendingQueue = /*#__PURE__*/ new WeakMap(),
|
|
2572
|
+
var _processManager = /*#__PURE__*/ new WeakMap(), _pendingQueue = /*#__PURE__*/ new WeakMap(), taskWorker_inflight = /*#__PURE__*/ new WeakMap(), _pendingFinalizeTasks = /*#__PURE__*/ new WeakMap(), _valueParser = /*#__PURE__*/ new WeakMap(), _statementTimeout = /*#__PURE__*/ new WeakMap(), _logger = /*#__PURE__*/ new WeakMap(), _name = /*#__PURE__*/ new WeakMap(), _batchSize = /*#__PURE__*/ new WeakMap(), _maxInflight = /*#__PURE__*/ new WeakMap(), _metrics = /*#__PURE__*/ new WeakMap(), _sweeper = /*#__PURE__*/ new WeakMap(), _scheduleFinalizeCheck = /*#__PURE__*/ new WeakMap(), _pump = /*#__PURE__*/ new WeakMap(), _pendingStderr = /*#__PURE__*/ new WeakMap(), _startProcess = /*#__PURE__*/ new WeakSet(), _pumpQueue = /*#__PURE__*/ new WeakSet(), _afterSentinel = /*#__PURE__*/ new WeakSet(), _handleStderrChunk = /*#__PURE__*/ new WeakSet(), _settleTask = /*#__PURE__*/ new WeakSet(), _rejectAll = /*#__PURE__*/ new WeakSet();
|
|
1993
2573
|
var taskWorker_TaskWorker = /*#__PURE__*/ function() {
|
|
1994
2574
|
"use strict";
|
|
1995
2575
|
function TaskWorker(param) {
|
|
1996
2576
|
var _this = this;
|
|
1997
|
-
var binary = param.binary, database = param.database, statementTimeout = param.statementTimeout, logger = param.logger, name = param.name, initMode = param.initMode, _param_batchSize = param.batchSize, batchSize = void 0 === _param_batchSize ? DEFAULT_BATCH_SIZE : _param_batchSize, _param_maxInflight = param.maxInflight, maxInflight = void 0 === _param_maxInflight ? DEFAULT_MAX_INFLIGHT : _param_maxInflight, metrics = param.metrics;
|
|
2577
|
+
var binary = param.binary, database = param.database, statementTimeout = param.statementTimeout, logger = param.logger, name = param.name, initMode = param.initMode, _param_batchSize = param.batchSize, batchSize = void 0 === _param_batchSize ? DEFAULT_BATCH_SIZE : _param_batchSize, _param_maxInflight = param.maxInflight, maxInflight = void 0 === _param_maxInflight ? DEFAULT_MAX_INFLIGHT : _param_maxInflight, metrics = param.metrics, _param_sweepInterval = param.sweepInterval, sweepInterval = void 0 === _param_sweepInterval ? 100 : _param_sweepInterval;
|
|
1998
2578
|
taskWorker_class_call_check(this, TaskWorker);
|
|
1999
2579
|
taskWorker_class_private_method_init(this, _startProcess);
|
|
2000
2580
|
taskWorker_class_private_method_init(this, _pumpQueue);
|
|
2001
|
-
taskWorker_class_private_method_init(this,
|
|
2002
|
-
taskWorker_class_private_method_init(this, _scheduleFinalizeCheck);
|
|
2581
|
+
taskWorker_class_private_method_init(this, _afterSentinel);
|
|
2003
2582
|
taskWorker_class_private_method_init(this, _handleStderrChunk);
|
|
2004
|
-
taskWorker_class_private_method_init(this, _handleTaskTimeout);
|
|
2005
2583
|
taskWorker_class_private_method_init(this, _settleTask);
|
|
2006
2584
|
taskWorker_class_private_method_init(this, _rejectAll);
|
|
2007
2585
|
taskWorker_class_private_field_init(this, _processManager, {
|
|
@@ -2012,18 +2590,14 @@ var taskWorker_TaskWorker = /*#__PURE__*/ function() {
|
|
|
2012
2590
|
writable: true,
|
|
2013
2591
|
value: new queue_Queue()
|
|
2014
2592
|
});
|
|
2015
|
-
taskWorker_class_private_field_init(this,
|
|
2593
|
+
taskWorker_class_private_field_init(this, taskWorker_inflight, {
|
|
2016
2594
|
writable: true,
|
|
2017
|
-
value:
|
|
2595
|
+
value: new inflightTracker_InflightTracker()
|
|
2018
2596
|
});
|
|
2019
2597
|
taskWorker_class_private_field_init(this, _pendingFinalizeTasks, {
|
|
2020
2598
|
writable: true,
|
|
2021
2599
|
value: new Set()
|
|
2022
2600
|
});
|
|
2023
|
-
taskWorker_class_private_field_init(this, _scheduledFinalize, {
|
|
2024
|
-
writable: true,
|
|
2025
|
-
value: false
|
|
2026
|
-
});
|
|
2027
2601
|
taskWorker_class_private_field_init(this, _valueParser, {
|
|
2028
2602
|
writable: true,
|
|
2029
2603
|
value: void 0
|
|
@@ -2052,6 +2626,22 @@ var taskWorker_TaskWorker = /*#__PURE__*/ function() {
|
|
|
2052
2626
|
writable: true,
|
|
2053
2627
|
value: void 0
|
|
2054
2628
|
});
|
|
2629
|
+
taskWorker_class_private_field_init(this, _sweeper, {
|
|
2630
|
+
writable: true,
|
|
2631
|
+
value: void 0
|
|
2632
|
+
});
|
|
2633
|
+
taskWorker_class_private_field_init(this, _scheduleFinalizeCheck, {
|
|
2634
|
+
writable: true,
|
|
2635
|
+
value: void 0
|
|
2636
|
+
});
|
|
2637
|
+
taskWorker_class_private_field_init(this, _pump, {
|
|
2638
|
+
writable: true,
|
|
2639
|
+
value: void 0
|
|
2640
|
+
});
|
|
2641
|
+
taskWorker_class_private_field_init(this, _pendingStderr, {
|
|
2642
|
+
writable: true,
|
|
2643
|
+
value: []
|
|
2644
|
+
});
|
|
2055
2645
|
taskWorker_class_private_field_set(this, _name, null != name ? name : "worker");
|
|
2056
2646
|
taskWorker_class_private_field_set(this, _statementTimeout, statementTimeout);
|
|
2057
2647
|
taskWorker_class_private_field_set(this, _logger, logger);
|
|
@@ -2061,13 +2651,47 @@ var taskWorker_TaskWorker = /*#__PURE__*/ function() {
|
|
|
2061
2651
|
taskWorker_class_private_field_set(this, _processManager, new process_ProcessManager({
|
|
2062
2652
|
binary: binary,
|
|
2063
2653
|
database: database,
|
|
2064
|
-
initMode: initMode
|
|
2065
|
-
|
|
2066
|
-
|
|
2654
|
+
initMode: initMode
|
|
2655
|
+
}));
|
|
2656
|
+
taskWorker_class_private_field_get(this, _processManager).setOnDrainCallback(function() {
|
|
2657
|
+
return taskWorker_class_private_method_get(_this, _pumpQueue, taskWorker_pumpQueue).call(_this);
|
|
2658
|
+
});
|
|
2659
|
+
taskWorker_class_private_field_set(this, _sweeper, createSweeper({
|
|
2660
|
+
inflight: taskWorker_class_private_field_get(this, taskWorker_inflight),
|
|
2661
|
+
sweepIntervalMs: sweepInterval,
|
|
2662
|
+
handleTaskTimeout: function(task) {
|
|
2663
|
+
var error = prepareTaskTimeout(task, taskWorker_class_private_field_get(_this, _metrics));
|
|
2664
|
+
if (error) taskWorker_class_private_method_get(_this, _settleTask, settleTask1).call(_this, task, error, void 0);
|
|
2067
2665
|
}
|
|
2068
2666
|
}));
|
|
2667
|
+
taskWorker_class_private_field_set(this, _pump, createPumpQueue({
|
|
2668
|
+
queue: taskWorker_class_private_field_get(this, _pendingQueue),
|
|
2669
|
+
inflight: taskWorker_class_private_field_get(this, taskWorker_inflight),
|
|
2670
|
+
processManager: taskWorker_class_private_field_get(this, _processManager),
|
|
2671
|
+
sweeper: taskWorker_class_private_field_get(this, _sweeper),
|
|
2672
|
+
batchSize: taskWorker_class_private_field_get(this, _batchSize),
|
|
2673
|
+
maxInflight: taskWorker_class_private_field_get(this, _maxInflight)
|
|
2674
|
+
}));
|
|
2675
|
+
taskWorker_class_private_field_set(this, _scheduleFinalizeCheck, createFinalizeScheduler({
|
|
2676
|
+
pendingFinalizeTasks: taskWorker_class_private_field_get(this, _pendingFinalizeTasks),
|
|
2677
|
+
settleTask: function(t, e, v1) {
|
|
2678
|
+
return taskWorker_class_private_method_get(_this, _settleTask, settleTask1).call(_this, t, e, v1);
|
|
2679
|
+
},
|
|
2680
|
+
pumpQueue: function() {
|
|
2681
|
+
return taskWorker_class_private_method_get(_this, _pumpQueue, taskWorker_pumpQueue).call(_this);
|
|
2682
|
+
},
|
|
2683
|
+
pendingStderr: taskWorker_class_private_field_get(this, _pendingStderr),
|
|
2684
|
+
inflight: taskWorker_class_private_field_get(this, taskWorker_inflight)
|
|
2685
|
+
}));
|
|
2069
2686
|
taskWorker_class_private_field_set(this, _valueParser, createJsonValueParser(function(raw) {
|
|
2070
|
-
|
|
2687
|
+
handleParsedValue(raw, taskWorker_class_private_field_get(_this, taskWorker_inflight), {
|
|
2688
|
+
afterSentinel: function(task) {
|
|
2689
|
+
return taskWorker_class_private_method_get(_this, _afterSentinel, taskWorker_afterSentinel).call(_this, task);
|
|
2690
|
+
},
|
|
2691
|
+
rejectAll: function(error) {
|
|
2692
|
+
return taskWorker_class_private_method_get(_this, _rejectAll, taskWorker_rejectAll).call(_this, error);
|
|
2693
|
+
}
|
|
2694
|
+
});
|
|
2071
2695
|
}));
|
|
2072
2696
|
taskWorker_class_private_method_get(this, _startProcess, startProcess).call(this);
|
|
2073
2697
|
}
|
|
@@ -2081,13 +2705,13 @@ var taskWorker_TaskWorker = /*#__PURE__*/ function() {
|
|
|
2081
2705
|
{
|
|
2082
2706
|
key: "idle",
|
|
2083
2707
|
get: function() {
|
|
2084
|
-
return 0 === taskWorker_class_private_field_get(this,
|
|
2708
|
+
return 0 === taskWorker_class_private_field_get(this, taskWorker_inflight).count && taskWorker_class_private_field_get(this, _pendingQueue).isEmpty() && 0 === taskWorker_class_private_field_get(this, _pendingFinalizeTasks).size;
|
|
2085
2709
|
}
|
|
2086
2710
|
},
|
|
2087
2711
|
{
|
|
2088
2712
|
key: "pendingStatements",
|
|
2089
2713
|
get: function() {
|
|
2090
|
-
return taskWorker_class_private_field_get(this, _pendingQueue).size + taskWorker_class_private_field_get(this,
|
|
2714
|
+
return taskWorker_class_private_field_get(this, _pendingQueue).size + taskWorker_class_private_field_get(this, taskWorker_inflight).count + taskWorker_class_private_field_get(this, _pendingFinalizeTasks).size;
|
|
2091
2715
|
}
|
|
2092
2716
|
},
|
|
2093
2717
|
{
|
|
@@ -2107,8 +2731,6 @@ var taskWorker_TaskWorker = /*#__PURE__*/ function() {
|
|
|
2107
2731
|
consumerError: null,
|
|
2108
2732
|
stderrText: "",
|
|
2109
2733
|
settled: false,
|
|
2110
|
-
errorScheduled: false,
|
|
2111
|
-
timer: null,
|
|
2112
2734
|
startTime: 0
|
|
2113
2735
|
};
|
|
2114
2736
|
null == (_$_class_private_field_get = taskWorker_class_private_field_get(this, _metrics)) || _$_class_private_field_get.incrementTasksTotal(config.kind);
|
|
@@ -2116,6 +2738,14 @@ var taskWorker_TaskWorker = /*#__PURE__*/ function() {
|
|
|
2116
2738
|
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2117
2739
|
}
|
|
2118
2740
|
},
|
|
2741
|
+
{
|
|
2742
|
+
key: "_sweepTimer",
|
|
2743
|
+
get: function() {
|
|
2744
|
+
var _$_class_private_field_get;
|
|
2745
|
+
var _class_private_field_get_getSweepTimer;
|
|
2746
|
+
return null != (_class_private_field_get_getSweepTimer = null == (_$_class_private_field_get = taskWorker_class_private_field_get(this, _sweeper)) ? void 0 : _$_class_private_field_get.getSweepTimer()) ? _class_private_field_get_getSweepTimer : null;
|
|
2747
|
+
}
|
|
2748
|
+
},
|
|
2119
2749
|
{
|
|
2120
2750
|
key: "_process",
|
|
2121
2751
|
get: function() {
|
|
@@ -2125,6 +2755,9 @@ var taskWorker_TaskWorker = /*#__PURE__*/ function() {
|
|
|
2125
2755
|
{
|
|
2126
2756
|
key: "kill",
|
|
2127
2757
|
value: function() {
|
|
2758
|
+
var _class_private_field_get_cancel, _$_class_private_field_get;
|
|
2759
|
+
taskWorker_class_private_field_get(this, _sweeper).clear();
|
|
2760
|
+
null == (_class_private_field_get_cancel = (_$_class_private_field_get = taskWorker_class_private_field_get(this, _scheduleFinalizeCheck)).cancel) || _class_private_field_get_cancel.call(_$_class_private_field_get);
|
|
2128
2761
|
taskWorker_class_private_method_get(this, _rejectAll, taskWorker_rejectAll).call(this, new Error("".concat(taskWorker_class_private_field_get(this, _name), " is killed")));
|
|
2129
2762
|
taskWorker_class_private_field_get(this, _processManager).kill();
|
|
2130
2763
|
}
|
|
@@ -2139,7 +2772,7 @@ function startProcess() {
|
|
|
2139
2772
|
taskWorker_class_private_field_get(_this, _valueParser).feed(chunk);
|
|
2140
2773
|
});
|
|
2141
2774
|
proc.stderr.on("data", function(chunk) {
|
|
2142
|
-
taskWorker_class_private_method_get(_this, _handleStderrChunk,
|
|
2775
|
+
taskWorker_class_private_method_get(_this, _handleStderrChunk, taskWorker_handleStderrChunk1).call(_this, chunk);
|
|
2143
2776
|
});
|
|
2144
2777
|
proc.on("error", function(error) {
|
|
2145
2778
|
var _class_private_field_get_error, _$_class_private_field_get;
|
|
@@ -2154,167 +2787,46 @@ function startProcess() {
|
|
|
2154
2787
|
});
|
|
2155
2788
|
}
|
|
2156
2789
|
function taskWorker_pumpQueue() {
|
|
2157
|
-
|
|
2158
|
-
var _$_class_private_field_get;
|
|
2159
|
-
if (taskWorker_class_private_field_get(this, _processManager).draining) return;
|
|
2160
|
-
if (taskWorker_class_private_field_get(this, _inflightTasks).length >= taskWorker_class_private_field_get(this, _maxInflight)) return;
|
|
2161
|
-
var batch = [];
|
|
2162
|
-
while(batch.length < taskWorker_class_private_field_get(this, _batchSize) && !taskWorker_class_private_field_get(this, _pendingQueue).isEmpty() && taskWorker_class_private_field_get(this, _inflightTasks).length + batch.length < taskWorker_class_private_field_get(this, _maxInflight)){
|
|
2163
|
-
var task = taskWorker_class_private_field_get(this, _pendingQueue).peek();
|
|
2164
|
-
if ("stream" === task.kind && (batch.length > 0 || taskWorker_class_private_field_get(this, _inflightTasks).length > 0)) break;
|
|
2165
|
-
taskWorker_class_private_field_get(this, _pendingQueue).dequeue();
|
|
2166
|
-
batch.push(task);
|
|
2167
|
-
}
|
|
2168
|
-
if (0 === batch.length) return;
|
|
2169
|
-
var now = performance.now();
|
|
2170
|
-
var payload = buildBatchPayload(batch);
|
|
2171
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
2172
|
-
try {
|
|
2173
|
-
var _this1, _loop = function() {
|
|
2174
|
-
var task = _step.value;
|
|
2175
|
-
task.startTime = now;
|
|
2176
|
-
var _task_timeout;
|
|
2177
|
-
task.timer = setTimeout(function() {
|
|
2178
|
-
return taskWorker_class_private_method_get(_this, _handleTaskTimeout, handleTaskTimeout).call(_this, task);
|
|
2179
|
-
}, null != (_task_timeout = task.timeout) ? _task_timeout : taskWorker_class_private_field_get(_this1, _statementTimeout));
|
|
2180
|
-
};
|
|
2181
|
-
for(var _iterator = batch[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_this1 = this, _loop();
|
|
2182
|
-
} catch (err) {
|
|
2183
|
-
_didIteratorError = true;
|
|
2184
|
-
_iteratorError = err;
|
|
2185
|
-
} finally{
|
|
2186
|
-
try {
|
|
2187
|
-
if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
|
|
2188
|
-
} finally{
|
|
2189
|
-
if (_didIteratorError) throw _iteratorError;
|
|
2190
|
-
}
|
|
2191
|
-
}
|
|
2192
|
-
(_$_class_private_field_get = taskWorker_class_private_field_get(this, _inflightTasks)).push.apply(_$_class_private_field_get, taskWorker_to_consumable_array(batch));
|
|
2193
|
-
taskWorker_class_private_field_get(this, _processManager).write(payload);
|
|
2194
|
-
}
|
|
2195
|
-
function handleParsedValue(raw) {
|
|
2196
|
-
var task = taskWorker_class_private_field_get(this, _inflightTasks)[0];
|
|
2197
|
-
if (!task) return;
|
|
2198
|
-
if (isSentinelRaw(raw, task.token)) {
|
|
2199
|
-
clearTimeout(task.timer);
|
|
2200
|
-
taskWorker_class_private_field_get(this, _inflightTasks).shift();
|
|
2201
|
-
if (task.timedout) return void taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2202
|
-
if (task.stderrText) {
|
|
2203
|
-
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, new Error(task.stderrText.trim()), void 0);
|
|
2204
|
-
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2205
|
-
return;
|
|
2206
|
-
}
|
|
2207
|
-
if (task.consumerError) {
|
|
2208
|
-
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, task.consumerError, void 0);
|
|
2209
|
-
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2210
|
-
return;
|
|
2211
|
-
}
|
|
2212
|
-
taskWorker_class_private_field_get(this, _pendingFinalizeTasks).add(task);
|
|
2213
|
-
taskWorker_class_private_method_get(this, _scheduleFinalizeCheck, scheduleFinalizeCheck).call(this);
|
|
2214
|
-
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2215
|
-
return;
|
|
2216
|
-
}
|
|
2217
|
-
if ("[]" === raw) return;
|
|
2218
|
-
var parsed;
|
|
2219
|
-
try {
|
|
2220
|
-
parsed = JSON.parse(raw);
|
|
2221
|
-
} catch (error) {
|
|
2222
|
-
taskWorker_class_private_method_get(this, _rejectAll, taskWorker_rejectAll).call(this, new Error("Invalid JSON from sqlite3: ".concat(toError(error).message)));
|
|
2223
|
-
return;
|
|
2224
|
-
}
|
|
2225
|
-
if (isSentinelRow(parsed, task.token)) {
|
|
2226
|
-
clearTimeout(task.timer);
|
|
2227
|
-
taskWorker_class_private_field_get(this, _inflightTasks).shift();
|
|
2228
|
-
if (task.timedout) return void taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2229
|
-
if (task.stderrText) {
|
|
2230
|
-
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, new Error(task.stderrText.trim()), void 0);
|
|
2231
|
-
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2232
|
-
return;
|
|
2233
|
-
}
|
|
2234
|
-
if (task.consumerError) {
|
|
2235
|
-
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, task.consumerError, void 0);
|
|
2236
|
-
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2237
|
-
return;
|
|
2238
|
-
}
|
|
2239
|
-
taskWorker_class_private_field_get(this, _pendingFinalizeTasks).add(task);
|
|
2240
|
-
taskWorker_class_private_method_get(this, _scheduleFinalizeCheck, scheduleFinalizeCheck).call(this);
|
|
2241
|
-
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2242
|
-
return;
|
|
2243
|
-
}
|
|
2244
|
-
if ("query" === task.kind) return void collectQueryRows(task, parsed);
|
|
2245
|
-
if ("stream" === task.kind) processStreamRows(task, parsed);
|
|
2790
|
+
taskWorker_class_private_field_get(this, _pump).call(this);
|
|
2246
2791
|
}
|
|
2247
|
-
function
|
|
2792
|
+
function taskWorker_afterSentinel(task) {
|
|
2248
2793
|
var _this = this;
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
setImmediate(function() {
|
|
2252
|
-
taskWorker_class_private_field_set(_this, _scheduledFinalize, false);
|
|
2253
|
-
finalizePendingTasks(taskWorker_class_private_field_get(_this, _pendingFinalizeTasks), function(t, e, v1) {
|
|
2794
|
+
handleSentinelTask(task, {
|
|
2795
|
+
settleTask: function(t, e, v1) {
|
|
2254
2796
|
return taskWorker_class_private_method_get(_this, _settleTask, settleTask1).call(_this, t, e, v1);
|
|
2255
|
-
},
|
|
2797
|
+
},
|
|
2798
|
+
pendingFinalizeTasks: taskWorker_class_private_field_get(this, _pendingFinalizeTasks),
|
|
2799
|
+
scheduleFinalizeCheck: function() {
|
|
2800
|
+
return taskWorker_class_private_field_get(_this, _scheduleFinalizeCheck).call(_this);
|
|
2801
|
+
},
|
|
2802
|
+
pumpQueue: function() {
|
|
2256
2803
|
return taskWorker_class_private_method_get(_this, _pumpQueue, taskWorker_pumpQueue).call(_this);
|
|
2257
|
-
}
|
|
2804
|
+
}
|
|
2258
2805
|
});
|
|
2259
2806
|
}
|
|
2260
|
-
function
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
}
|
|
2268
|
-
task.stderrText += String(chunk);
|
|
2269
|
-
}
|
|
2270
|
-
function handleTaskTimeout(task) {
|
|
2271
|
-
var error = prepareTaskTimeout(task, taskWorker_class_private_field_get(this, _metrics));
|
|
2272
|
-
if (error) taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, error, void 0);
|
|
2807
|
+
function taskWorker_handleStderrChunk1(chunk) {
|
|
2808
|
+
handleStderrChunk(chunk, {
|
|
2809
|
+
inflight: taskWorker_class_private_field_get(this, taskWorker_inflight),
|
|
2810
|
+
pendingFinalizeTasks: taskWorker_class_private_field_get(this, _pendingFinalizeTasks),
|
|
2811
|
+
logger: taskWorker_class_private_field_get(this, _logger),
|
|
2812
|
+
pendingStderr: taskWorker_class_private_field_get(this, _pendingStderr)
|
|
2813
|
+
});
|
|
2273
2814
|
}
|
|
2274
2815
|
function settleTask1(task, error, value) {
|
|
2275
|
-
|
|
2816
|
+
settleUtils_settleTask(task, error, value, taskWorker_class_private_field_get(this, _metrics));
|
|
2276
2817
|
}
|
|
2277
2818
|
function taskWorker_rejectAll(error) {
|
|
2278
|
-
var
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, error, void 0);
|
|
2290
|
-
}
|
|
2291
|
-
} catch (err) {
|
|
2292
|
-
_didIteratorError = true;
|
|
2293
|
-
_iteratorError = err;
|
|
2294
|
-
} finally{
|
|
2295
|
-
try {
|
|
2296
|
-
if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
|
|
2297
|
-
} finally{
|
|
2298
|
-
if (_didIteratorError) throw _iteratorError;
|
|
2299
|
-
}
|
|
2300
|
-
}
|
|
2301
|
-
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
2302
|
-
try {
|
|
2303
|
-
for(var _iterator1 = taskWorker_class_private_field_get(this, _pendingFinalizeTasks)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
2304
|
-
var task1 = _step1.value;
|
|
2305
|
-
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task1, error, void 0);
|
|
2306
|
-
}
|
|
2307
|
-
} catch (err) {
|
|
2308
|
-
_didIteratorError1 = true;
|
|
2309
|
-
_iteratorError1 = err;
|
|
2310
|
-
} finally{
|
|
2311
|
-
try {
|
|
2312
|
-
if (!_iteratorNormalCompletion1 && null != _iterator1["return"]) _iterator1["return"]();
|
|
2313
|
-
} finally{
|
|
2314
|
-
if (_didIteratorError1) throw _iteratorError1;
|
|
2315
|
-
}
|
|
2316
|
-
}
|
|
2317
|
-
taskWorker_class_private_field_get(this, _pendingFinalizeTasks).clear();
|
|
2819
|
+
var _this = this;
|
|
2820
|
+
taskWorker_class_private_field_get(this, _sweeper).clear();
|
|
2821
|
+
rejectAllTasks({
|
|
2822
|
+
inflight: taskWorker_class_private_field_get(this, taskWorker_inflight),
|
|
2823
|
+
queue: taskWorker_class_private_field_get(this, _pendingQueue),
|
|
2824
|
+
pendingFinalizeTasks: taskWorker_class_private_field_get(this, _pendingFinalizeTasks),
|
|
2825
|
+
settleTask: function(t, e, v1) {
|
|
2826
|
+
return taskWorker_class_private_method_get(_this, _settleTask, settleTask1).call(_this, t, e, v1);
|
|
2827
|
+
},
|
|
2828
|
+
error: error
|
|
2829
|
+
});
|
|
2318
2830
|
}
|
|
2319
2831
|
function readerPool_check_private_redeclaration(obj, privateCollection) {
|
|
2320
2832
|
if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
@@ -2387,7 +2899,7 @@ var readerPool_ReaderPool = /*#__PURE__*/ function() {
|
|
|
2387
2899
|
logger: logger,
|
|
2388
2900
|
metrics: metrics,
|
|
2389
2901
|
name: "reader-".concat(i),
|
|
2390
|
-
initMode: ":memory:" !== database ? "none" : "
|
|
2902
|
+
initMode: ":memory:" !== database ? "none" : "none"
|
|
2391
2903
|
});
|
|
2392
2904
|
readerPool_class_private_field_get(this, _workers).push(worker);
|
|
2393
2905
|
}
|
|
@@ -2410,9 +2922,19 @@ var readerPool_ReaderPool = /*#__PURE__*/ function() {
|
|
|
2410
2922
|
{
|
|
2411
2923
|
key: "enqueue",
|
|
2412
2924
|
value: function(task) {
|
|
2413
|
-
var
|
|
2925
|
+
var minLoad = 1 / 0;
|
|
2926
|
+
var candidates = [];
|
|
2927
|
+
for(var i = 0; i < readerPool_class_private_field_get(this, _workers).length; i++){
|
|
2928
|
+
var load = readerPool_class_private_field_get(this, _workers)[i].pendingStatements;
|
|
2929
|
+
if (load < minLoad) {
|
|
2930
|
+
minLoad = load;
|
|
2931
|
+
candidates.length = 0;
|
|
2932
|
+
candidates.push(i);
|
|
2933
|
+
} else if (load === minLoad) candidates.push(i);
|
|
2934
|
+
}
|
|
2935
|
+
var idx = candidates[readerPool_class_private_field_get(this, _rrIndex) % candidates.length];
|
|
2414
2936
|
readerPool_class_private_field_set(this, _rrIndex, readerPool_class_private_field_get(this, _rrIndex) + 1 >>> 0);
|
|
2415
|
-
|
|
2937
|
+
readerPool_class_private_field_get(this, _workers)[idx].enqueue(task);
|
|
2416
2938
|
}
|
|
2417
2939
|
},
|
|
2418
2940
|
{
|
|
@@ -2658,6 +3180,10 @@ var metrics_Metrics = /*#__PURE__*/ function() {
|
|
|
2658
3180
|
key: "snapshot",
|
|
2659
3181
|
value: function() {
|
|
2660
3182
|
var elapsed = (Date.now() - metrics_class_private_field_get(this, _startTime)) / 1000;
|
|
3183
|
+
var avgTaskDuration;
|
|
3184
|
+
avgTaskDuration = metrics_class_private_field_get(this, _tasksSuccess) > 0 ? metrics_class_private_field_get(this, _totalDuration) / metrics_class_private_field_get(this, _tasksSuccess) : 0;
|
|
3185
|
+
var throughput;
|
|
3186
|
+
throughput = elapsed > 0 ? metrics_class_private_field_get(this, _tasksTotal) / elapsed : 0;
|
|
2661
3187
|
return {
|
|
2662
3188
|
tasksTotal: metrics_class_private_field_get(this, _tasksTotal),
|
|
2663
3189
|
tasksSuccess: metrics_class_private_field_get(this, _tasksSuccess),
|
|
@@ -2667,8 +3193,8 @@ var metrics_Metrics = /*#__PURE__*/ function() {
|
|
|
2667
3193
|
executeCount: metrics_class_private_field_get(this, _executeCount),
|
|
2668
3194
|
queryCount: metrics_class_private_field_get(this, _queryCount),
|
|
2669
3195
|
streamCount: metrics_class_private_field_get(this, _streamCount),
|
|
2670
|
-
|
|
2671
|
-
|
|
3196
|
+
avgTaskDuration: avgTaskDuration,
|
|
3197
|
+
throughput: throughput,
|
|
2672
3198
|
uptime: elapsed
|
|
2673
3199
|
};
|
|
2674
3200
|
}
|
|
@@ -2905,9 +3431,7 @@ var transactionScope_TransactionScope = /*#__PURE__*/ function() {
|
|
|
2905
3431
|
release = resolve;
|
|
2906
3432
|
});
|
|
2907
3433
|
previous = transactionScope_class_private_field_get(_this, _scopeChain);
|
|
2908
|
-
transactionScope_class_private_field_set(_this, _scopeChain,
|
|
2909
|
-
return gate;
|
|
2910
|
-
}));
|
|
3434
|
+
transactionScope_class_private_field_set(_this, _scopeChain, gate);
|
|
2911
3435
|
return [
|
|
2912
3436
|
4,
|
|
2913
3437
|
previous["catch"](function() {})
|
|
@@ -2944,7 +3468,7 @@ var transactionScope_TransactionScope = /*#__PURE__*/ function() {
|
|
|
2944
3468
|
value: function(error) {
|
|
2945
3469
|
var task = transactionScope_class_private_field_get(this, _deferredQueue).dequeue();
|
|
2946
3470
|
while(task){
|
|
2947
|
-
|
|
3471
|
+
settleUtils_settleTask(task, error, void 0, null);
|
|
2948
3472
|
task = transactionScope_class_private_field_get(this, _deferredQueue).dequeue();
|
|
2949
3473
|
}
|
|
2950
3474
|
}
|
|
@@ -2952,14 +3476,6 @@ var transactionScope_TransactionScope = /*#__PURE__*/ function() {
|
|
|
2952
3476
|
]);
|
|
2953
3477
|
return TransactionScope;
|
|
2954
3478
|
}();
|
|
2955
|
-
function pipelineEngine_array_like_to_array(arr, len) {
|
|
2956
|
-
if (null == len || len > arr.length) len = arr.length;
|
|
2957
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
2958
|
-
return arr2;
|
|
2959
|
-
}
|
|
2960
|
-
function pipelineEngine_array_without_holes(arr) {
|
|
2961
|
-
if (Array.isArray(arr)) return pipelineEngine_array_like_to_array(arr);
|
|
2962
|
-
}
|
|
2963
3479
|
function pipelineEngine_check_private_redeclaration(obj, privateCollection) {
|
|
2964
3480
|
if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
2965
3481
|
}
|
|
@@ -3016,52 +3532,29 @@ function pipelineEngine_create_class(Constructor, protoProps, staticProps) {
|
|
|
3016
3532
|
if (staticProps) pipelineEngine_defineProperties(Constructor, staticProps);
|
|
3017
3533
|
return Constructor;
|
|
3018
3534
|
}
|
|
3019
|
-
|
|
3020
|
-
if ("undefined" != typeof Symbol && null != iter[Symbol.iterator] || null != iter["@@iterator"]) return Array.from(iter);
|
|
3021
|
-
}
|
|
3022
|
-
function pipelineEngine_non_iterable_spread() {
|
|
3023
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
3024
|
-
}
|
|
3025
|
-
function pipelineEngine_to_consumable_array(arr) {
|
|
3026
|
-
return pipelineEngine_array_without_holes(arr) || pipelineEngine_iterable_to_array(arr) || pipelineEngine_unsupported_iterable_to_array(arr) || pipelineEngine_non_iterable_spread();
|
|
3027
|
-
}
|
|
3028
|
-
function pipelineEngine_unsupported_iterable_to_array(o, minLen) {
|
|
3029
|
-
if (!o) return;
|
|
3030
|
-
if ("string" == typeof o) return pipelineEngine_array_like_to_array(o, minLen);
|
|
3031
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
3032
|
-
if ("Object" === n && o.constructor) n = o.constructor.name;
|
|
3033
|
-
if ("Map" === n || "Set" === n) return Array.from(n);
|
|
3034
|
-
if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return pipelineEngine_array_like_to_array(o, minLen);
|
|
3035
|
-
}
|
|
3036
|
-
var _queue = /*#__PURE__*/ new WeakMap(), pipelineEngine_inflightTasks = /*#__PURE__*/ new WeakMap(), pipelineEngine_pendingFinalizeTasks = /*#__PURE__*/ new WeakMap(), pipelineEngine_scheduledFinalize = /*#__PURE__*/ new WeakMap(), _sharedValueParser = /*#__PURE__*/ new WeakMap(), pipelineEngine_processManager = /*#__PURE__*/ new WeakMap(), pipelineEngine_metrics = /*#__PURE__*/ new WeakMap(), pipelineEngine_statementTimeout = /*#__PURE__*/ new WeakMap(), pipelineEngine_logger = /*#__PURE__*/ new WeakMap(), pipelineEngine_batchSize = /*#__PURE__*/ new WeakMap(), pipelineEngine_maxInflight = /*#__PURE__*/ new WeakMap(), _onTaskTimeout = /*#__PURE__*/ new WeakMap(), _active = /*#__PURE__*/ new WeakMap(), _sweepTimer = /*#__PURE__*/ new WeakMap(), _sweepIntervalMs = /*#__PURE__*/ new WeakMap(), core_pipelineEngine_pumpQueue = /*#__PURE__*/ new WeakSet(), pipelineEngine_handleParsedValue = /*#__PURE__*/ new WeakSet(), core_pipelineEngine_scheduleFinalizeCheck = /*#__PURE__*/ new WeakSet(), _scheduleSweep = /*#__PURE__*/ new WeakSet(), core_pipelineEngine_handleTaskTimeout = /*#__PURE__*/ new WeakSet(), pipelineEngine_settleTask = /*#__PURE__*/ new WeakSet();
|
|
3535
|
+
var _queue = /*#__PURE__*/ new WeakMap(), pipelineEngine_inflight = /*#__PURE__*/ new WeakMap(), pipelineEngine_pendingFinalizeTasks = /*#__PURE__*/ new WeakMap(), _sharedValueParser = /*#__PURE__*/ new WeakMap(), pipelineEngine_processManager = /*#__PURE__*/ new WeakMap(), pipelineEngine_metrics = /*#__PURE__*/ new WeakMap(), pipelineEngine_statementTimeout = /*#__PURE__*/ new WeakMap(), pipelineEngine_logger = /*#__PURE__*/ new WeakMap(), pipelineEngine_batchSize = /*#__PURE__*/ new WeakMap(), pipelineEngine_maxInflight = /*#__PURE__*/ new WeakMap(), _onTaskTimeout = /*#__PURE__*/ new WeakMap(), _active = /*#__PURE__*/ new WeakMap(), pipelineEngine_sweeper = /*#__PURE__*/ new WeakMap(), pipelineEngine_scheduleFinalizeCheck = /*#__PURE__*/ new WeakMap(), pipelineEngine_pump = /*#__PURE__*/ new WeakMap(), pipelineEngine_pendingStderr = /*#__PURE__*/ new WeakMap(), core_pipelineEngine_pumpQueue = /*#__PURE__*/ new WeakSet(), core_pipelineEngine_afterSentinel = /*#__PURE__*/ new WeakSet(), pipelineEngine_settleTask = /*#__PURE__*/ new WeakSet();
|
|
3037
3536
|
var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
3038
3537
|
"use strict";
|
|
3039
3538
|
function PipelineEngine(processManager, param) {
|
|
3040
3539
|
var _this = this;
|
|
3041
3540
|
var metrics = param.metrics, statementTimeout = param.statementTimeout, logger = param.logger, _param_batchSize = param.batchSize, batchSize = void 0 === _param_batchSize ? DEFAULT_BATCH_SIZE : _param_batchSize, _param_maxInflight = param.maxInflight, maxInflight = void 0 === _param_maxInflight ? DEFAULT_MAX_INFLIGHT : _param_maxInflight, onTaskTimeout = param.onTaskTimeout, _param_sweepInterval = param.sweepInterval, sweepInterval = void 0 === _param_sweepInterval ? 100 : _param_sweepInterval;
|
|
3042
3541
|
pipelineEngine_class_call_check(this, PipelineEngine);
|
|
3542
|
+
var _this1, _this2;
|
|
3043
3543
|
pipelineEngine_class_private_method_init(this, core_pipelineEngine_pumpQueue);
|
|
3044
|
-
pipelineEngine_class_private_method_init(this,
|
|
3045
|
-
pipelineEngine_class_private_method_init(this, core_pipelineEngine_scheduleFinalizeCheck);
|
|
3046
|
-
pipelineEngine_class_private_method_init(this, _scheduleSweep);
|
|
3047
|
-
pipelineEngine_class_private_method_init(this, core_pipelineEngine_handleTaskTimeout);
|
|
3544
|
+
pipelineEngine_class_private_method_init(this, core_pipelineEngine_afterSentinel);
|
|
3048
3545
|
pipelineEngine_class_private_method_init(this, pipelineEngine_settleTask);
|
|
3049
3546
|
pipelineEngine_class_private_field_init(this, _queue, {
|
|
3050
3547
|
writable: true,
|
|
3051
3548
|
value: new queue_Queue()
|
|
3052
3549
|
});
|
|
3053
|
-
pipelineEngine_class_private_field_init(this,
|
|
3550
|
+
pipelineEngine_class_private_field_init(this, pipelineEngine_inflight, {
|
|
3054
3551
|
writable: true,
|
|
3055
|
-
value:
|
|
3552
|
+
value: new inflightTracker_InflightTracker()
|
|
3056
3553
|
});
|
|
3057
3554
|
pipelineEngine_class_private_field_init(this, pipelineEngine_pendingFinalizeTasks, {
|
|
3058
3555
|
writable: true,
|
|
3059
3556
|
value: new Set()
|
|
3060
3557
|
});
|
|
3061
|
-
pipelineEngine_class_private_field_init(this, pipelineEngine_scheduledFinalize, {
|
|
3062
|
-
writable: true,
|
|
3063
|
-
value: false
|
|
3064
|
-
});
|
|
3065
3558
|
pipelineEngine_class_private_field_init(this, _sharedValueParser, {
|
|
3066
3559
|
writable: true,
|
|
3067
3560
|
value: void 0
|
|
@@ -3098,14 +3591,22 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3098
3591
|
writable: true,
|
|
3099
3592
|
value: false
|
|
3100
3593
|
});
|
|
3101
|
-
pipelineEngine_class_private_field_init(this,
|
|
3594
|
+
pipelineEngine_class_private_field_init(this, pipelineEngine_sweeper, {
|
|
3102
3595
|
writable: true,
|
|
3103
|
-
value:
|
|
3596
|
+
value: void 0
|
|
3597
|
+
});
|
|
3598
|
+
pipelineEngine_class_private_field_init(this, pipelineEngine_scheduleFinalizeCheck, {
|
|
3599
|
+
writable: true,
|
|
3600
|
+
value: void 0
|
|
3104
3601
|
});
|
|
3105
|
-
pipelineEngine_class_private_field_init(this,
|
|
3602
|
+
pipelineEngine_class_private_field_init(this, pipelineEngine_pump, {
|
|
3106
3603
|
writable: true,
|
|
3107
3604
|
value: void 0
|
|
3108
3605
|
});
|
|
3606
|
+
pipelineEngine_class_private_field_init(this, pipelineEngine_pendingStderr, {
|
|
3607
|
+
writable: true,
|
|
3608
|
+
value: []
|
|
3609
|
+
});
|
|
3109
3610
|
pipelineEngine_class_private_field_set(this, pipelineEngine_processManager, processManager);
|
|
3110
3611
|
pipelineEngine_class_private_field_set(this, pipelineEngine_metrics, metrics);
|
|
3111
3612
|
pipelineEngine_class_private_field_set(this, pipelineEngine_statementTimeout, statementTimeout);
|
|
@@ -3113,19 +3614,57 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3113
3614
|
pipelineEngine_class_private_field_set(this, pipelineEngine_batchSize, batchSize);
|
|
3114
3615
|
pipelineEngine_class_private_field_set(this, pipelineEngine_maxInflight, maxInflight);
|
|
3115
3616
|
pipelineEngine_class_private_field_set(this, _onTaskTimeout, null != onTaskTimeout ? onTaskTimeout : function() {});
|
|
3617
|
+
pipelineEngine_class_private_field_set(this, pipelineEngine_sweeper, createSweeper({
|
|
3618
|
+
inflight: pipelineEngine_class_private_field_get(this, pipelineEngine_inflight),
|
|
3619
|
+
sweepIntervalMs: sweepInterval,
|
|
3620
|
+
handleTaskTimeout: function(task) {
|
|
3621
|
+
var error = prepareTaskTimeout(task, pipelineEngine_class_private_field_get(_this, pipelineEngine_metrics));
|
|
3622
|
+
if (error) {
|
|
3623
|
+
pipelineEngine_class_private_method_get(_this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(_this, task, error, void 0);
|
|
3624
|
+
null == (_this1 = pipelineEngine_class_private_field_get(_this2 = _this, _onTaskTimeout)) || _this1.call(_this2, task);
|
|
3625
|
+
}
|
|
3626
|
+
}
|
|
3627
|
+
}));
|
|
3628
|
+
pipelineEngine_class_private_field_set(this, pipelineEngine_pump, createPumpQueue({
|
|
3629
|
+
queue: pipelineEngine_class_private_field_get(this, _queue),
|
|
3630
|
+
inflight: pipelineEngine_class_private_field_get(this, pipelineEngine_inflight),
|
|
3631
|
+
processManager: pipelineEngine_class_private_field_get(this, pipelineEngine_processManager),
|
|
3632
|
+
sweeper: pipelineEngine_class_private_field_get(this, pipelineEngine_sweeper),
|
|
3633
|
+
batchSize: pipelineEngine_class_private_field_get(this, pipelineEngine_batchSize),
|
|
3634
|
+
maxInflight: pipelineEngine_class_private_field_get(this, pipelineEngine_maxInflight)
|
|
3635
|
+
}));
|
|
3636
|
+
pipelineEngine_class_private_field_set(this, pipelineEngine_scheduleFinalizeCheck, createFinalizeScheduler({
|
|
3637
|
+
pendingFinalizeTasks: pipelineEngine_class_private_field_get(this, pipelineEngine_pendingFinalizeTasks),
|
|
3638
|
+
settleTask: function(t, e, v1) {
|
|
3639
|
+
return pipelineEngine_class_private_method_get(_this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(_this, t, e, v1);
|
|
3640
|
+
},
|
|
3641
|
+
pumpQueue: function() {
|
|
3642
|
+
return pipelineEngine_class_private_method_get(_this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(_this);
|
|
3643
|
+
},
|
|
3644
|
+
pendingStderr: pipelineEngine_class_private_field_get(this, pipelineEngine_pendingStderr),
|
|
3645
|
+
inflight: pipelineEngine_class_private_field_get(this, pipelineEngine_inflight)
|
|
3646
|
+
}));
|
|
3116
3647
|
pipelineEngine_class_private_field_set(this, _sharedValueParser, createJsonValueParser(function(raw) {
|
|
3117
|
-
|
|
3648
|
+
handleParsedValue(raw, pipelineEngine_class_private_field_get(_this, pipelineEngine_inflight), {
|
|
3649
|
+
afterSentinel: function(task) {
|
|
3650
|
+
return pipelineEngine_class_private_method_get(_this, core_pipelineEngine_afterSentinel, pipelineEngine_afterSentinel).call(_this, task);
|
|
3651
|
+
},
|
|
3652
|
+
rejectAll: function(error) {
|
|
3653
|
+
return _this.rejectAll(error);
|
|
3654
|
+
}
|
|
3655
|
+
});
|
|
3118
3656
|
}));
|
|
3119
3657
|
pipelineEngine_class_private_field_get(this, pipelineEngine_processManager).setOnDrainCallback(function() {
|
|
3120
3658
|
return pipelineEngine_class_private_method_get(_this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(_this);
|
|
3121
3659
|
});
|
|
3122
|
-
pipelineEngine_class_private_field_set(this, _sweepIntervalMs, sweepInterval);
|
|
3123
3660
|
}
|
|
3124
3661
|
pipelineEngine_create_class(PipelineEngine, [
|
|
3125
3662
|
{
|
|
3126
3663
|
key: "_sweepTimer",
|
|
3127
3664
|
get: function() {
|
|
3128
|
-
|
|
3665
|
+
var _$_class_private_field_get;
|
|
3666
|
+
var _class_private_field_get_getSweepTimer;
|
|
3667
|
+
return null != (_class_private_field_get_getSweepTimer = null == (_$_class_private_field_get = pipelineEngine_class_private_field_get(this, pipelineEngine_sweeper)) ? void 0 : _$_class_private_field_get.getSweepTimer()) ? _class_private_field_get_getSweepTimer : null;
|
|
3129
3668
|
}
|
|
3130
3669
|
},
|
|
3131
3670
|
{
|
|
@@ -3143,7 +3682,7 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3143
3682
|
{
|
|
3144
3683
|
key: "pendingStatements",
|
|
3145
3684
|
get: function() {
|
|
3146
|
-
return pipelineEngine_class_private_field_get(this, _queue).size + pipelineEngine_class_private_field_get(this,
|
|
3685
|
+
return pipelineEngine_class_private_field_get(this, _queue).size + pipelineEngine_class_private_field_get(this, pipelineEngine_inflight).count + pipelineEngine_class_private_field_get(this, pipelineEngine_pendingFinalizeTasks).size;
|
|
3147
3686
|
}
|
|
3148
3687
|
},
|
|
3149
3688
|
{
|
|
@@ -3176,7 +3715,7 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3176
3715
|
{
|
|
3177
3716
|
key: "handleStdoutChunk",
|
|
3178
3717
|
value: function(chunk) {
|
|
3179
|
-
var task = pipelineEngine_class_private_field_get(this,
|
|
3718
|
+
var task = pipelineEngine_class_private_field_get(this, pipelineEngine_inflight).first;
|
|
3180
3719
|
if (!task) return;
|
|
3181
3720
|
if ("stream" === task.kind && task.rowParser && !task.rowParser.finished && !task.timedout) {
|
|
3182
3721
|
var leftover = task.rowParser.feed(chunk);
|
|
@@ -3189,68 +3728,37 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3189
3728
|
{
|
|
3190
3729
|
key: "handleStderrChunk",
|
|
3191
3730
|
value: function(chunk) {
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
}
|
|
3199
|
-
task.stderrText += String(chunk);
|
|
3731
|
+
handleStderrChunk(chunk, {
|
|
3732
|
+
inflight: pipelineEngine_class_private_field_get(this, pipelineEngine_inflight),
|
|
3733
|
+
pendingFinalizeTasks: pipelineEngine_class_private_field_get(this, pipelineEngine_pendingFinalizeTasks),
|
|
3734
|
+
logger: pipelineEngine_class_private_field_get(this, pipelineEngine_logger),
|
|
3735
|
+
pendingStderr: pipelineEngine_class_private_field_get(this, pipelineEngine_pendingStderr)
|
|
3736
|
+
});
|
|
3200
3737
|
}
|
|
3201
3738
|
},
|
|
3202
3739
|
{
|
|
3203
3740
|
key: "rejectAll",
|
|
3204
3741
|
value: function(error) {
|
|
3742
|
+
var _this = this;
|
|
3205
3743
|
pipelineEngine_class_private_field_get(this, _sharedValueParser).reset();
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
}
|
|
3215
|
-
_didIteratorError = true;
|
|
3216
|
-
_iteratorError = err;
|
|
3217
|
-
} finally{
|
|
3218
|
-
try {
|
|
3219
|
-
if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
|
|
3220
|
-
} finally{
|
|
3221
|
-
if (_didIteratorError) throw _iteratorError;
|
|
3222
|
-
}
|
|
3223
|
-
}
|
|
3224
|
-
var queued = pipelineEngine_class_private_field_get(this, _queue).dequeue();
|
|
3225
|
-
while(queued){
|
|
3226
|
-
pipelineEngine_class_private_method_get(this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(this, queued, error, void 0);
|
|
3227
|
-
queued = pipelineEngine_class_private_field_get(this, _queue).dequeue();
|
|
3228
|
-
}
|
|
3229
|
-
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
3230
|
-
try {
|
|
3231
|
-
for(var _iterator1 = pipelineEngine_class_private_field_get(this, pipelineEngine_pendingFinalizeTasks)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
3232
|
-
var task1 = _step1.value;
|
|
3233
|
-
pipelineEngine_class_private_method_get(this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(this, task1, error, void 0);
|
|
3234
|
-
}
|
|
3235
|
-
} catch (err) {
|
|
3236
|
-
_didIteratorError1 = true;
|
|
3237
|
-
_iteratorError1 = err;
|
|
3238
|
-
} finally{
|
|
3239
|
-
try {
|
|
3240
|
-
if (!_iteratorNormalCompletion1 && null != _iterator1["return"]) _iterator1["return"]();
|
|
3241
|
-
} finally{
|
|
3242
|
-
if (_didIteratorError1) throw _iteratorError1;
|
|
3243
|
-
}
|
|
3244
|
-
}
|
|
3245
|
-
pipelineEngine_class_private_field_get(this, pipelineEngine_pendingFinalizeTasks).clear();
|
|
3744
|
+
rejectAllTasks({
|
|
3745
|
+
inflight: pipelineEngine_class_private_field_get(this, pipelineEngine_inflight),
|
|
3746
|
+
queue: pipelineEngine_class_private_field_get(this, _queue),
|
|
3747
|
+
pendingFinalizeTasks: pipelineEngine_class_private_field_get(this, pipelineEngine_pendingFinalizeTasks),
|
|
3748
|
+
settleTask: function(t, e, v1) {
|
|
3749
|
+
return pipelineEngine_class_private_method_get(_this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(_this, t, e, v1);
|
|
3750
|
+
},
|
|
3751
|
+
error: error
|
|
3752
|
+
});
|
|
3246
3753
|
}
|
|
3247
3754
|
},
|
|
3248
3755
|
{
|
|
3249
3756
|
key: "kill",
|
|
3250
3757
|
value: function() {
|
|
3758
|
+
var _class_private_field_get_cancel, _$_class_private_field_get;
|
|
3251
3759
|
pipelineEngine_class_private_field_set(this, _active, false);
|
|
3252
|
-
|
|
3253
|
-
|
|
3760
|
+
pipelineEngine_class_private_field_get(this, pipelineEngine_sweeper).clear();
|
|
3761
|
+
null == (_class_private_field_get_cancel = (_$_class_private_field_get = pipelineEngine_class_private_field_get(this, pipelineEngine_scheduleFinalizeCheck)).cancel) || _class_private_field_get_cancel.call(_$_class_private_field_get);
|
|
3254
3762
|
this.rejectAll(new Error("PipelineEngine is killed"));
|
|
3255
3763
|
}
|
|
3256
3764
|
}
|
|
@@ -3258,118 +3766,26 @@ var pipelineEngine_PipelineEngine = /*#__PURE__*/ function() {
|
|
|
3258
3766
|
return PipelineEngine;
|
|
3259
3767
|
}();
|
|
3260
3768
|
function pipelineEngine_pumpQueue() {
|
|
3261
|
-
var _$_class_private_field_get;
|
|
3262
3769
|
if (!pipelineEngine_class_private_field_get(this, _active)) return;
|
|
3263
|
-
|
|
3264
|
-
if (pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks).length >= pipelineEngine_class_private_field_get(this, pipelineEngine_maxInflight)) return;
|
|
3265
|
-
var batch = [];
|
|
3266
|
-
while(batch.length < pipelineEngine_class_private_field_get(this, pipelineEngine_batchSize) && !pipelineEngine_class_private_field_get(this, _queue).isEmpty() && pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks).length + batch.length < pipelineEngine_class_private_field_get(this, pipelineEngine_maxInflight)){
|
|
3267
|
-
var task = pipelineEngine_class_private_field_get(this, _queue).peek();
|
|
3268
|
-
if ("stream" === task.kind && (batch.length > 0 || pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks).length > 0)) break;
|
|
3269
|
-
pipelineEngine_class_private_field_get(this, _queue).dequeue();
|
|
3270
|
-
batch.push(task);
|
|
3271
|
-
}
|
|
3272
|
-
if (0 === batch.length) return;
|
|
3273
|
-
var now = performance.now();
|
|
3274
|
-
var payload = buildBatchPayload(batch);
|
|
3275
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
3276
|
-
try {
|
|
3277
|
-
for(var _iterator = batch[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3278
|
-
var task1 = _step.value;
|
|
3279
|
-
task1.startTime = now;
|
|
3280
|
-
}
|
|
3281
|
-
} catch (err) {
|
|
3282
|
-
_didIteratorError = true;
|
|
3283
|
-
_iteratorError = err;
|
|
3284
|
-
} finally{
|
|
3285
|
-
try {
|
|
3286
|
-
if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
|
|
3287
|
-
} finally{
|
|
3288
|
-
if (_didIteratorError) throw _iteratorError;
|
|
3289
|
-
}
|
|
3290
|
-
}
|
|
3291
|
-
(_$_class_private_field_get = pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks)).push.apply(_$_class_private_field_get, pipelineEngine_to_consumable_array(batch));
|
|
3292
|
-
pipelineEngine_class_private_method_get(this, _scheduleSweep, scheduleSweep).call(this);
|
|
3293
|
-
pipelineEngine_class_private_field_get(this, pipelineEngine_processManager).write(payload);
|
|
3294
|
-
}
|
|
3295
|
-
function core_pipelineEngine_handleParsedValue(raw) {
|
|
3296
|
-
var task = pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks)[0];
|
|
3297
|
-
if (!task) return;
|
|
3298
|
-
if (isSentinelRaw(raw, task.token)) {
|
|
3299
|
-
pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks).shift();
|
|
3300
|
-
if (task.timedout) return void pipelineEngine_class_private_method_get(this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(this);
|
|
3301
|
-
if (task.consumerError) {
|
|
3302
|
-
pipelineEngine_class_private_method_get(this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(this, task, task.consumerError, void 0);
|
|
3303
|
-
pipelineEngine_class_private_method_get(this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(this);
|
|
3304
|
-
return;
|
|
3305
|
-
}
|
|
3306
|
-
pipelineEngine_class_private_field_get(this, pipelineEngine_pendingFinalizeTasks).add(task);
|
|
3307
|
-
pipelineEngine_class_private_method_get(this, core_pipelineEngine_scheduleFinalizeCheck, pipelineEngine_scheduleFinalizeCheck).call(this);
|
|
3308
|
-
pipelineEngine_class_private_method_get(this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(this);
|
|
3309
|
-
return;
|
|
3310
|
-
}
|
|
3311
|
-
if ("[]" === raw) return;
|
|
3312
|
-
var parsed;
|
|
3313
|
-
try {
|
|
3314
|
-
parsed = JSON.parse(raw);
|
|
3315
|
-
} catch (error) {
|
|
3316
|
-
this.rejectAll(new Error("Invalid JSON from sqlite3: ".concat(toError(error).message)));
|
|
3317
|
-
return;
|
|
3318
|
-
}
|
|
3319
|
-
if (isSentinelRow(parsed, task.token)) {
|
|
3320
|
-
pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks).shift();
|
|
3321
|
-
if (task.timedout) return void pipelineEngine_class_private_method_get(this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(this);
|
|
3322
|
-
if (task.consumerError) {
|
|
3323
|
-
pipelineEngine_class_private_method_get(this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(this, task, task.consumerError, void 0);
|
|
3324
|
-
pipelineEngine_class_private_method_get(this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(this);
|
|
3325
|
-
return;
|
|
3326
|
-
}
|
|
3327
|
-
pipelineEngine_class_private_field_get(this, pipelineEngine_pendingFinalizeTasks).add(task);
|
|
3328
|
-
pipelineEngine_class_private_method_get(this, core_pipelineEngine_scheduleFinalizeCheck, pipelineEngine_scheduleFinalizeCheck).call(this);
|
|
3329
|
-
pipelineEngine_class_private_method_get(this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(this);
|
|
3330
|
-
return;
|
|
3331
|
-
}
|
|
3332
|
-
if (task.timedout) return;
|
|
3333
|
-
if ("query" === task.kind) return void collectQueryRows(task, parsed);
|
|
3334
|
-
if ("stream" === task.kind) processStreamRows(task, parsed);
|
|
3770
|
+
pipelineEngine_class_private_field_get(this, pipelineEngine_pump).call(this);
|
|
3335
3771
|
}
|
|
3336
|
-
function
|
|
3772
|
+
function pipelineEngine_afterSentinel(task) {
|
|
3337
3773
|
var _this = this;
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
setImmediate(function() {
|
|
3341
|
-
pipelineEngine_class_private_field_set(_this, pipelineEngine_scheduledFinalize, false);
|
|
3342
|
-
finalizePendingTasks(pipelineEngine_class_private_field_get(_this, pipelineEngine_pendingFinalizeTasks), function(t, e, v1) {
|
|
3774
|
+
handleSentinelTask(task, {
|
|
3775
|
+
settleTask: function(t, e, v1) {
|
|
3343
3776
|
return pipelineEngine_class_private_method_get(_this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(_this, t, e, v1);
|
|
3344
|
-
},
|
|
3777
|
+
},
|
|
3778
|
+
pendingFinalizeTasks: pipelineEngine_class_private_field_get(this, pipelineEngine_pendingFinalizeTasks),
|
|
3779
|
+
scheduleFinalizeCheck: function() {
|
|
3780
|
+
return pipelineEngine_class_private_field_get(_this, pipelineEngine_scheduleFinalizeCheck).call(_this);
|
|
3781
|
+
},
|
|
3782
|
+
pumpQueue: function() {
|
|
3345
3783
|
return pipelineEngine_class_private_method_get(_this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(_this);
|
|
3346
|
-
});
|
|
3347
|
-
});
|
|
3348
|
-
}
|
|
3349
|
-
function scheduleSweep() {
|
|
3350
|
-
var _this = this;
|
|
3351
|
-
if (pipelineEngine_class_private_field_get(this, _sweepTimer)) return;
|
|
3352
|
-
pipelineEngine_class_private_field_set(this, _sweepTimer, setTimeout(function() {
|
|
3353
|
-
pipelineEngine_class_private_field_set(_this, _sweepTimer, null);
|
|
3354
|
-
var inflight = pipelineEngine_class_private_field_get(_this, pipelineEngine_inflightTasks);
|
|
3355
|
-
var now = performance.now();
|
|
3356
|
-
for(var i = 0; i < inflight.length; i++){
|
|
3357
|
-
var task = inflight[i];
|
|
3358
|
-
if (now - task.startTime > task.timeout) pipelineEngine_class_private_method_get(_this, core_pipelineEngine_handleTaskTimeout, pipelineEngine_handleTaskTimeout).call(_this, task);
|
|
3359
3784
|
}
|
|
3360
|
-
|
|
3361
|
-
}, pipelineEngine_class_private_field_get(this, _sweepIntervalMs)).unref());
|
|
3362
|
-
}
|
|
3363
|
-
function pipelineEngine_handleTaskTimeout(task) {
|
|
3364
|
-
var _this, _this1;
|
|
3365
|
-
var error = prepareTaskTimeout(task, pipelineEngine_class_private_field_get(this, pipelineEngine_metrics));
|
|
3366
|
-
if (error) {
|
|
3367
|
-
pipelineEngine_class_private_method_get(this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(this, task, error, void 0);
|
|
3368
|
-
null == (_this = pipelineEngine_class_private_field_get(_this1 = this, _onTaskTimeout)) || _this.call(_this1, task);
|
|
3369
|
-
}
|
|
3785
|
+
});
|
|
3370
3786
|
}
|
|
3371
3787
|
function pipelineEngine_settleTask1(task, error, value) {
|
|
3372
|
-
|
|
3788
|
+
settleUtils_settleTask(task, error, value, pipelineEngine_class_private_field_get(this, pipelineEngine_metrics), {
|
|
3373
3789
|
resetRowParser: true
|
|
3374
3790
|
});
|
|
3375
3791
|
}
|
|
@@ -3876,31 +4292,6 @@ var executor_SQLiteExecutor = /*#__PURE__*/ function() {
|
|
|
3876
4292
|
case 1:
|
|
3877
4293
|
_state.sent();
|
|
3878
4294
|
executor_class_private_field_get(_this, executor_processManager).kill();
|
|
3879
|
-
_state.label = 2;
|
|
3880
|
-
case 2:
|
|
3881
|
-
_state.trys.push([
|
|
3882
|
-
2,
|
|
3883
|
-
4,
|
|
3884
|
-
,
|
|
3885
|
-
5
|
|
3886
|
-
]);
|
|
3887
|
-
return [
|
|
3888
|
-
4,
|
|
3889
|
-
(0, __WEBPACK_EXTERNAL_MODULE_node_events_0a6aefe7__.once)(executor_class_private_field_get(_this, executor_processManager).process, "close")
|
|
3890
|
-
];
|
|
3891
|
-
case 3:
|
|
3892
|
-
_state.sent();
|
|
3893
|
-
return [
|
|
3894
|
-
3,
|
|
3895
|
-
5
|
|
3896
|
-
];
|
|
3897
|
-
case 4:
|
|
3898
|
-
_state.sent();
|
|
3899
|
-
return [
|
|
3900
|
-
3,
|
|
3901
|
-
5
|
|
3902
|
-
];
|
|
3903
|
-
case 5:
|
|
3904
4295
|
return [
|
|
3905
4296
|
2
|
|
3906
4297
|
];
|
|
@@ -3968,20 +4359,18 @@ function executor_enqueue(kind, sql, params, options, scopeId) {
|
|
|
3968
4359
|
var token = generateToken();
|
|
3969
4360
|
var _options_onRow;
|
|
3970
4361
|
var onRow = null != (_options_onRow = null == options ? void 0 : options.onRow) ? _options_onRow : null;
|
|
3971
|
-
var
|
|
4362
|
+
var template = normalizeSQLTemplate(sql);
|
|
3972
4363
|
var formatted;
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
if (scopeId) return executor_class_private_method_get(this, _enqueueWriter, enqueueWriter).call(this, kind, formatted, timeout, token, onRow, scopeId, sqlNormalized);
|
|
4364
|
+
formatted = 0 === params.length && 0 === template.paramCount ? template.normalized : interpolateFromTemplate(template, params);
|
|
4365
|
+
if (scopeId) return executor_class_private_method_get(this, _enqueueWriter, enqueueWriter).call(this, kind, formatted, timeout, token, onRow, scopeId);
|
|
3976
4366
|
if (executor_class_private_field_get(this, _readerPool)) {
|
|
3977
4367
|
if ("stream" === kind || "query" === kind) return executor_class_private_method_get(this, _enqueueReader, enqueueReader).call(this, kind, formatted, timeout, token, onRow);
|
|
3978
|
-
if ("execute" === kind && "read" === classifySQL(normalized)) return executor_class_private_method_get(this, _enqueueReader, enqueueReader).call(this, kind, formatted, timeout, token, onRow);
|
|
4368
|
+
if ("execute" === kind && "read" === classifySQL(template.normalized)) return executor_class_private_method_get(this, _enqueueReader, enqueueReader).call(this, kind, formatted, timeout, token, onRow);
|
|
3979
4369
|
}
|
|
3980
|
-
return executor_class_private_method_get(this, _enqueueWriter, enqueueWriter).call(this, kind, formatted, timeout, token, onRow, null
|
|
4370
|
+
return executor_class_private_method_get(this, _enqueueWriter, enqueueWriter).call(this, kind, formatted, timeout, token, onRow, null);
|
|
3981
4371
|
}
|
|
3982
4372
|
function enqueueWriter(kind, sql, timeout, token, onRow, scopeId) {
|
|
3983
4373
|
var _this = this;
|
|
3984
|
-
var sqlNormalized = arguments.length > 6 && void 0 !== arguments[6] ? arguments[6] : false;
|
|
3985
4374
|
executor_class_private_field_get(this, executor_metrics).incrementTasksTotal(kind);
|
|
3986
4375
|
return new Promise(function(resolve, reject) {
|
|
3987
4376
|
var task = {
|
|
@@ -3991,13 +4380,11 @@ function enqueueWriter(kind, sql, timeout, token, onRow, scopeId) {
|
|
|
3991
4380
|
token: token,
|
|
3992
4381
|
onRow: onRow,
|
|
3993
4382
|
scopeId: scopeId,
|
|
3994
|
-
sqlNormalized: sqlNormalized,
|
|
3995
4383
|
resolve: resolve,
|
|
3996
4384
|
reject: reject,
|
|
3997
4385
|
consumerError: null,
|
|
3998
4386
|
stderrText: "",
|
|
3999
4387
|
settled: false,
|
|
4000
|
-
timer: null,
|
|
4001
4388
|
startTime: 0,
|
|
4002
4389
|
rowParser: null,
|
|
4003
4390
|
rows: "query" === kind ? [] : null
|