@smplkit/sdk 1.5.1 → 1.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/dist/index.cjs +191 -111
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +191 -111
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3974,11 +3974,11 @@ var require_stream_readable = __commonJS({
|
|
|
3974
3974
|
return Buffer2.isBuffer(obj) || obj instanceof OurUint8Array;
|
|
3975
3975
|
}
|
|
3976
3976
|
var debugUtil = __require("util");
|
|
3977
|
-
var
|
|
3977
|
+
var debug2;
|
|
3978
3978
|
if (debugUtil && debugUtil.debuglog) {
|
|
3979
|
-
|
|
3979
|
+
debug2 = debugUtil.debuglog("stream");
|
|
3980
3980
|
} else {
|
|
3981
|
-
|
|
3981
|
+
debug2 = function debug3() {
|
|
3982
3982
|
};
|
|
3983
3983
|
}
|
|
3984
3984
|
var BufferList = require_buffer_list();
|
|
@@ -4093,7 +4093,7 @@ var require_stream_readable = __commonJS({
|
|
|
4093
4093
|
return readableAddChunk(this, chunk, null, true, false);
|
|
4094
4094
|
};
|
|
4095
4095
|
function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
|
|
4096
|
-
|
|
4096
|
+
debug2("readableAddChunk", chunk);
|
|
4097
4097
|
var state = stream._readableState;
|
|
4098
4098
|
if (chunk === null) {
|
|
4099
4099
|
state.reading = false;
|
|
@@ -4200,13 +4200,13 @@ var require_stream_readable = __commonJS({
|
|
|
4200
4200
|
return state.length;
|
|
4201
4201
|
}
|
|
4202
4202
|
Readable.prototype.read = function(n) {
|
|
4203
|
-
|
|
4203
|
+
debug2("read", n);
|
|
4204
4204
|
n = parseInt(n, 10);
|
|
4205
4205
|
var state = this._readableState;
|
|
4206
4206
|
var nOrig = n;
|
|
4207
4207
|
if (n !== 0) state.emittedReadable = false;
|
|
4208
4208
|
if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) {
|
|
4209
|
-
|
|
4209
|
+
debug2("read: emitReadable", state.length, state.ended);
|
|
4210
4210
|
if (state.length === 0 && state.ended) endReadable(this);
|
|
4211
4211
|
else emitReadable(this);
|
|
4212
4212
|
return null;
|
|
@@ -4217,16 +4217,16 @@ var require_stream_readable = __commonJS({
|
|
|
4217
4217
|
return null;
|
|
4218
4218
|
}
|
|
4219
4219
|
var doRead = state.needReadable;
|
|
4220
|
-
|
|
4220
|
+
debug2("need readable", doRead);
|
|
4221
4221
|
if (state.length === 0 || state.length - n < state.highWaterMark) {
|
|
4222
4222
|
doRead = true;
|
|
4223
|
-
|
|
4223
|
+
debug2("length less than watermark", doRead);
|
|
4224
4224
|
}
|
|
4225
4225
|
if (state.ended || state.reading) {
|
|
4226
4226
|
doRead = false;
|
|
4227
|
-
|
|
4227
|
+
debug2("reading or ended", doRead);
|
|
4228
4228
|
} else if (doRead) {
|
|
4229
|
-
|
|
4229
|
+
debug2("do read");
|
|
4230
4230
|
state.reading = true;
|
|
4231
4231
|
state.sync = true;
|
|
4232
4232
|
if (state.length === 0) state.needReadable = true;
|
|
@@ -4252,7 +4252,7 @@ var require_stream_readable = __commonJS({
|
|
|
4252
4252
|
return ret;
|
|
4253
4253
|
};
|
|
4254
4254
|
function onEofChunk(stream, state) {
|
|
4255
|
-
|
|
4255
|
+
debug2("onEofChunk");
|
|
4256
4256
|
if (state.ended) return;
|
|
4257
4257
|
if (state.decoder) {
|
|
4258
4258
|
var chunk = state.decoder.end();
|
|
@@ -4274,17 +4274,17 @@ var require_stream_readable = __commonJS({
|
|
|
4274
4274
|
}
|
|
4275
4275
|
function emitReadable(stream) {
|
|
4276
4276
|
var state = stream._readableState;
|
|
4277
|
-
|
|
4277
|
+
debug2("emitReadable", state.needReadable, state.emittedReadable);
|
|
4278
4278
|
state.needReadable = false;
|
|
4279
4279
|
if (!state.emittedReadable) {
|
|
4280
|
-
|
|
4280
|
+
debug2("emitReadable", state.flowing);
|
|
4281
4281
|
state.emittedReadable = true;
|
|
4282
4282
|
process.nextTick(emitReadable_, stream);
|
|
4283
4283
|
}
|
|
4284
4284
|
}
|
|
4285
4285
|
function emitReadable_(stream) {
|
|
4286
4286
|
var state = stream._readableState;
|
|
4287
|
-
|
|
4287
|
+
debug2("emitReadable_", state.destroyed, state.length, state.ended);
|
|
4288
4288
|
if (!state.destroyed && (state.length || state.ended)) {
|
|
4289
4289
|
stream.emit("readable");
|
|
4290
4290
|
state.emittedReadable = false;
|
|
@@ -4301,7 +4301,7 @@ var require_stream_readable = __commonJS({
|
|
|
4301
4301
|
function maybeReadMore_(stream, state) {
|
|
4302
4302
|
while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) {
|
|
4303
4303
|
var len = state.length;
|
|
4304
|
-
|
|
4304
|
+
debug2("maybeReadMore read 0");
|
|
4305
4305
|
stream.read(0);
|
|
4306
4306
|
if (len === state.length)
|
|
4307
4307
|
break;
|
|
@@ -4326,14 +4326,14 @@ var require_stream_readable = __commonJS({
|
|
|
4326
4326
|
break;
|
|
4327
4327
|
}
|
|
4328
4328
|
state.pipesCount += 1;
|
|
4329
|
-
|
|
4329
|
+
debug2("pipe count=%d opts=%j", state.pipesCount, pipeOpts);
|
|
4330
4330
|
var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
|
|
4331
4331
|
var endFn = doEnd ? onend : unpipe;
|
|
4332
4332
|
if (state.endEmitted) process.nextTick(endFn);
|
|
4333
4333
|
else src.once("end", endFn);
|
|
4334
4334
|
dest.on("unpipe", onunpipe);
|
|
4335
4335
|
function onunpipe(readable, unpipeInfo) {
|
|
4336
|
-
|
|
4336
|
+
debug2("onunpipe");
|
|
4337
4337
|
if (readable === src) {
|
|
4338
4338
|
if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
|
|
4339
4339
|
unpipeInfo.hasUnpiped = true;
|
|
@@ -4342,14 +4342,14 @@ var require_stream_readable = __commonJS({
|
|
|
4342
4342
|
}
|
|
4343
4343
|
}
|
|
4344
4344
|
function onend() {
|
|
4345
|
-
|
|
4345
|
+
debug2("onend");
|
|
4346
4346
|
dest.end();
|
|
4347
4347
|
}
|
|
4348
4348
|
var ondrain = pipeOnDrain(src);
|
|
4349
4349
|
dest.on("drain", ondrain);
|
|
4350
4350
|
var cleanedUp = false;
|
|
4351
4351
|
function cleanup() {
|
|
4352
|
-
|
|
4352
|
+
debug2("cleanup");
|
|
4353
4353
|
dest.removeListener("close", onclose);
|
|
4354
4354
|
dest.removeListener("finish", onfinish);
|
|
4355
4355
|
dest.removeListener("drain", ondrain);
|
|
@@ -4363,19 +4363,19 @@ var require_stream_readable = __commonJS({
|
|
|
4363
4363
|
}
|
|
4364
4364
|
src.on("data", ondata);
|
|
4365
4365
|
function ondata(chunk) {
|
|
4366
|
-
|
|
4366
|
+
debug2("ondata");
|
|
4367
4367
|
var ret = dest.write(chunk);
|
|
4368
|
-
|
|
4368
|
+
debug2("dest.write", ret);
|
|
4369
4369
|
if (ret === false) {
|
|
4370
4370
|
if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
|
|
4371
|
-
|
|
4371
|
+
debug2("false write response, pause", state.awaitDrain);
|
|
4372
4372
|
state.awaitDrain++;
|
|
4373
4373
|
}
|
|
4374
4374
|
src.pause();
|
|
4375
4375
|
}
|
|
4376
4376
|
}
|
|
4377
4377
|
function onerror(er) {
|
|
4378
|
-
|
|
4378
|
+
debug2("onerror", er);
|
|
4379
4379
|
unpipe();
|
|
4380
4380
|
dest.removeListener("error", onerror);
|
|
4381
4381
|
if (EElistenerCount(dest, "error") === 0) errorOrDestroy(dest, er);
|
|
@@ -4387,18 +4387,18 @@ var require_stream_readable = __commonJS({
|
|
|
4387
4387
|
}
|
|
4388
4388
|
dest.once("close", onclose);
|
|
4389
4389
|
function onfinish() {
|
|
4390
|
-
|
|
4390
|
+
debug2("onfinish");
|
|
4391
4391
|
dest.removeListener("close", onclose);
|
|
4392
4392
|
unpipe();
|
|
4393
4393
|
}
|
|
4394
4394
|
dest.once("finish", onfinish);
|
|
4395
4395
|
function unpipe() {
|
|
4396
|
-
|
|
4396
|
+
debug2("unpipe");
|
|
4397
4397
|
src.unpipe(dest);
|
|
4398
4398
|
}
|
|
4399
4399
|
dest.emit("pipe", src);
|
|
4400
4400
|
if (!state.flowing) {
|
|
4401
|
-
|
|
4401
|
+
debug2("pipe resume");
|
|
4402
4402
|
src.resume();
|
|
4403
4403
|
}
|
|
4404
4404
|
return dest;
|
|
@@ -4406,7 +4406,7 @@ var require_stream_readable = __commonJS({
|
|
|
4406
4406
|
function pipeOnDrain(src) {
|
|
4407
4407
|
return function pipeOnDrainFunctionResult() {
|
|
4408
4408
|
var state = src._readableState;
|
|
4409
|
-
|
|
4409
|
+
debug2("pipeOnDrain", state.awaitDrain);
|
|
4410
4410
|
if (state.awaitDrain) state.awaitDrain--;
|
|
4411
4411
|
if (state.awaitDrain === 0 && EElistenerCount(src, "data")) {
|
|
4412
4412
|
state.flowing = true;
|
|
@@ -4459,7 +4459,7 @@ var require_stream_readable = __commonJS({
|
|
|
4459
4459
|
state.readableListening = state.needReadable = true;
|
|
4460
4460
|
state.flowing = false;
|
|
4461
4461
|
state.emittedReadable = false;
|
|
4462
|
-
|
|
4462
|
+
debug2("on readable", state.length, state.reading);
|
|
4463
4463
|
if (state.length) {
|
|
4464
4464
|
emitReadable(this);
|
|
4465
4465
|
} else if (!state.reading) {
|
|
@@ -4494,13 +4494,13 @@ var require_stream_readable = __commonJS({
|
|
|
4494
4494
|
}
|
|
4495
4495
|
}
|
|
4496
4496
|
function nReadingNextTick(self2) {
|
|
4497
|
-
|
|
4497
|
+
debug2("readable nexttick read 0");
|
|
4498
4498
|
self2.read(0);
|
|
4499
4499
|
}
|
|
4500
4500
|
Readable.prototype.resume = function() {
|
|
4501
4501
|
var state = this._readableState;
|
|
4502
4502
|
if (!state.flowing) {
|
|
4503
|
-
|
|
4503
|
+
debug2("resume");
|
|
4504
4504
|
state.flowing = !state.readableListening;
|
|
4505
4505
|
resume(this, state);
|
|
4506
4506
|
}
|
|
@@ -4514,7 +4514,7 @@ var require_stream_readable = __commonJS({
|
|
|
4514
4514
|
}
|
|
4515
4515
|
}
|
|
4516
4516
|
function resume_(stream, state) {
|
|
4517
|
-
|
|
4517
|
+
debug2("resume", state.reading);
|
|
4518
4518
|
if (!state.reading) {
|
|
4519
4519
|
stream.read(0);
|
|
4520
4520
|
}
|
|
@@ -4524,9 +4524,9 @@ var require_stream_readable = __commonJS({
|
|
|
4524
4524
|
if (state.flowing && !state.reading) stream.read(0);
|
|
4525
4525
|
}
|
|
4526
4526
|
Readable.prototype.pause = function() {
|
|
4527
|
-
|
|
4527
|
+
debug2("call pause flowing=%j", this._readableState.flowing);
|
|
4528
4528
|
if (this._readableState.flowing !== false) {
|
|
4529
|
-
|
|
4529
|
+
debug2("pause");
|
|
4530
4530
|
this._readableState.flowing = false;
|
|
4531
4531
|
this.emit("pause");
|
|
4532
4532
|
}
|
|
@@ -4535,7 +4535,7 @@ var require_stream_readable = __commonJS({
|
|
|
4535
4535
|
};
|
|
4536
4536
|
function flow(stream) {
|
|
4537
4537
|
var state = stream._readableState;
|
|
4538
|
-
|
|
4538
|
+
debug2("flow", state.flowing);
|
|
4539
4539
|
while (state.flowing && stream.read() !== null) ;
|
|
4540
4540
|
}
|
|
4541
4541
|
Readable.prototype.wrap = function(stream) {
|
|
@@ -4543,7 +4543,7 @@ var require_stream_readable = __commonJS({
|
|
|
4543
4543
|
var state = this._readableState;
|
|
4544
4544
|
var paused = false;
|
|
4545
4545
|
stream.on("end", function() {
|
|
4546
|
-
|
|
4546
|
+
debug2("wrapped end");
|
|
4547
4547
|
if (state.decoder && !state.ended) {
|
|
4548
4548
|
var chunk = state.decoder.end();
|
|
4549
4549
|
if (chunk && chunk.length) _this.push(chunk);
|
|
@@ -4551,7 +4551,7 @@ var require_stream_readable = __commonJS({
|
|
|
4551
4551
|
_this.push(null);
|
|
4552
4552
|
});
|
|
4553
4553
|
stream.on("data", function(chunk) {
|
|
4554
|
-
|
|
4554
|
+
debug2("wrapped data");
|
|
4555
4555
|
if (state.decoder) chunk = state.decoder.write(chunk);
|
|
4556
4556
|
if (state.objectMode && (chunk === null || chunk === void 0)) return;
|
|
4557
4557
|
else if (!state.objectMode && (!chunk || !chunk.length)) return;
|
|
@@ -4574,7 +4574,7 @@ var require_stream_readable = __commonJS({
|
|
|
4574
4574
|
stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
|
|
4575
4575
|
}
|
|
4576
4576
|
this._read = function(n2) {
|
|
4577
|
-
|
|
4577
|
+
debug2("wrapped _read", n2);
|
|
4578
4578
|
if (paused) {
|
|
4579
4579
|
paused = false;
|
|
4580
4580
|
stream.resume();
|
|
@@ -4648,14 +4648,14 @@ var require_stream_readable = __commonJS({
|
|
|
4648
4648
|
}
|
|
4649
4649
|
function endReadable(stream) {
|
|
4650
4650
|
var state = stream._readableState;
|
|
4651
|
-
|
|
4651
|
+
debug2("endReadable", state.endEmitted);
|
|
4652
4652
|
if (!state.endEmitted) {
|
|
4653
4653
|
state.ended = true;
|
|
4654
4654
|
process.nextTick(endReadableNT, state, stream);
|
|
4655
4655
|
}
|
|
4656
4656
|
}
|
|
4657
4657
|
function endReadableNT(state, stream) {
|
|
4658
|
-
|
|
4658
|
+
debug2("endReadableNT", state.endEmitted, state.length);
|
|
4659
4659
|
if (!state.endEmitted && state.length === 0) {
|
|
4660
4660
|
state.endEmitted = true;
|
|
4661
4661
|
stream.readable = false;
|
|
@@ -7520,11 +7520,11 @@ var require_stream_readable2 = __commonJS({
|
|
|
7520
7520
|
return Buffer2.isBuffer(obj) || obj instanceof OurUint8Array;
|
|
7521
7521
|
}
|
|
7522
7522
|
var debugUtil = __require("util");
|
|
7523
|
-
var
|
|
7523
|
+
var debug2;
|
|
7524
7524
|
if (debugUtil && debugUtil.debuglog) {
|
|
7525
|
-
|
|
7525
|
+
debug2 = debugUtil.debuglog("stream");
|
|
7526
7526
|
} else {
|
|
7527
|
-
|
|
7527
|
+
debug2 = function debug3() {
|
|
7528
7528
|
};
|
|
7529
7529
|
}
|
|
7530
7530
|
var BufferList = require_buffer_list2();
|
|
@@ -7639,7 +7639,7 @@ var require_stream_readable2 = __commonJS({
|
|
|
7639
7639
|
return readableAddChunk(this, chunk, null, true, false);
|
|
7640
7640
|
};
|
|
7641
7641
|
function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
|
|
7642
|
-
|
|
7642
|
+
debug2("readableAddChunk", chunk);
|
|
7643
7643
|
var state = stream._readableState;
|
|
7644
7644
|
if (chunk === null) {
|
|
7645
7645
|
state.reading = false;
|
|
@@ -7746,13 +7746,13 @@ var require_stream_readable2 = __commonJS({
|
|
|
7746
7746
|
return state.length;
|
|
7747
7747
|
}
|
|
7748
7748
|
Readable.prototype.read = function(n) {
|
|
7749
|
-
|
|
7749
|
+
debug2("read", n);
|
|
7750
7750
|
n = parseInt(n, 10);
|
|
7751
7751
|
var state = this._readableState;
|
|
7752
7752
|
var nOrig = n;
|
|
7753
7753
|
if (n !== 0) state.emittedReadable = false;
|
|
7754
7754
|
if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) {
|
|
7755
|
-
|
|
7755
|
+
debug2("read: emitReadable", state.length, state.ended);
|
|
7756
7756
|
if (state.length === 0 && state.ended) endReadable(this);
|
|
7757
7757
|
else emitReadable(this);
|
|
7758
7758
|
return null;
|
|
@@ -7763,16 +7763,16 @@ var require_stream_readable2 = __commonJS({
|
|
|
7763
7763
|
return null;
|
|
7764
7764
|
}
|
|
7765
7765
|
var doRead = state.needReadable;
|
|
7766
|
-
|
|
7766
|
+
debug2("need readable", doRead);
|
|
7767
7767
|
if (state.length === 0 || state.length - n < state.highWaterMark) {
|
|
7768
7768
|
doRead = true;
|
|
7769
|
-
|
|
7769
|
+
debug2("length less than watermark", doRead);
|
|
7770
7770
|
}
|
|
7771
7771
|
if (state.ended || state.reading) {
|
|
7772
7772
|
doRead = false;
|
|
7773
|
-
|
|
7773
|
+
debug2("reading or ended", doRead);
|
|
7774
7774
|
} else if (doRead) {
|
|
7775
|
-
|
|
7775
|
+
debug2("do read");
|
|
7776
7776
|
state.reading = true;
|
|
7777
7777
|
state.sync = true;
|
|
7778
7778
|
if (state.length === 0) state.needReadable = true;
|
|
@@ -7798,7 +7798,7 @@ var require_stream_readable2 = __commonJS({
|
|
|
7798
7798
|
return ret;
|
|
7799
7799
|
};
|
|
7800
7800
|
function onEofChunk(stream, state) {
|
|
7801
|
-
|
|
7801
|
+
debug2("onEofChunk");
|
|
7802
7802
|
if (state.ended) return;
|
|
7803
7803
|
if (state.decoder) {
|
|
7804
7804
|
var chunk = state.decoder.end();
|
|
@@ -7820,17 +7820,17 @@ var require_stream_readable2 = __commonJS({
|
|
|
7820
7820
|
}
|
|
7821
7821
|
function emitReadable(stream) {
|
|
7822
7822
|
var state = stream._readableState;
|
|
7823
|
-
|
|
7823
|
+
debug2("emitReadable", state.needReadable, state.emittedReadable);
|
|
7824
7824
|
state.needReadable = false;
|
|
7825
7825
|
if (!state.emittedReadable) {
|
|
7826
|
-
|
|
7826
|
+
debug2("emitReadable", state.flowing);
|
|
7827
7827
|
state.emittedReadable = true;
|
|
7828
7828
|
process.nextTick(emitReadable_, stream);
|
|
7829
7829
|
}
|
|
7830
7830
|
}
|
|
7831
7831
|
function emitReadable_(stream) {
|
|
7832
7832
|
var state = stream._readableState;
|
|
7833
|
-
|
|
7833
|
+
debug2("emitReadable_", state.destroyed, state.length, state.ended);
|
|
7834
7834
|
if (!state.destroyed && (state.length || state.ended)) {
|
|
7835
7835
|
stream.emit("readable");
|
|
7836
7836
|
state.emittedReadable = false;
|
|
@@ -7847,7 +7847,7 @@ var require_stream_readable2 = __commonJS({
|
|
|
7847
7847
|
function maybeReadMore_(stream, state) {
|
|
7848
7848
|
while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) {
|
|
7849
7849
|
var len = state.length;
|
|
7850
|
-
|
|
7850
|
+
debug2("maybeReadMore read 0");
|
|
7851
7851
|
stream.read(0);
|
|
7852
7852
|
if (len === state.length)
|
|
7853
7853
|
break;
|
|
@@ -7872,14 +7872,14 @@ var require_stream_readable2 = __commonJS({
|
|
|
7872
7872
|
break;
|
|
7873
7873
|
}
|
|
7874
7874
|
state.pipesCount += 1;
|
|
7875
|
-
|
|
7875
|
+
debug2("pipe count=%d opts=%j", state.pipesCount, pipeOpts);
|
|
7876
7876
|
var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
|
|
7877
7877
|
var endFn = doEnd ? onend : unpipe;
|
|
7878
7878
|
if (state.endEmitted) process.nextTick(endFn);
|
|
7879
7879
|
else src.once("end", endFn);
|
|
7880
7880
|
dest.on("unpipe", onunpipe);
|
|
7881
7881
|
function onunpipe(readable, unpipeInfo) {
|
|
7882
|
-
|
|
7882
|
+
debug2("onunpipe");
|
|
7883
7883
|
if (readable === src) {
|
|
7884
7884
|
if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
|
|
7885
7885
|
unpipeInfo.hasUnpiped = true;
|
|
@@ -7888,14 +7888,14 @@ var require_stream_readable2 = __commonJS({
|
|
|
7888
7888
|
}
|
|
7889
7889
|
}
|
|
7890
7890
|
function onend() {
|
|
7891
|
-
|
|
7891
|
+
debug2("onend");
|
|
7892
7892
|
dest.end();
|
|
7893
7893
|
}
|
|
7894
7894
|
var ondrain = pipeOnDrain(src);
|
|
7895
7895
|
dest.on("drain", ondrain);
|
|
7896
7896
|
var cleanedUp = false;
|
|
7897
7897
|
function cleanup() {
|
|
7898
|
-
|
|
7898
|
+
debug2("cleanup");
|
|
7899
7899
|
dest.removeListener("close", onclose);
|
|
7900
7900
|
dest.removeListener("finish", onfinish);
|
|
7901
7901
|
dest.removeListener("drain", ondrain);
|
|
@@ -7909,19 +7909,19 @@ var require_stream_readable2 = __commonJS({
|
|
|
7909
7909
|
}
|
|
7910
7910
|
src.on("data", ondata);
|
|
7911
7911
|
function ondata(chunk) {
|
|
7912
|
-
|
|
7912
|
+
debug2("ondata");
|
|
7913
7913
|
var ret = dest.write(chunk);
|
|
7914
|
-
|
|
7914
|
+
debug2("dest.write", ret);
|
|
7915
7915
|
if (ret === false) {
|
|
7916
7916
|
if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
|
|
7917
|
-
|
|
7917
|
+
debug2("false write response, pause", state.awaitDrain);
|
|
7918
7918
|
state.awaitDrain++;
|
|
7919
7919
|
}
|
|
7920
7920
|
src.pause();
|
|
7921
7921
|
}
|
|
7922
7922
|
}
|
|
7923
7923
|
function onerror(er) {
|
|
7924
|
-
|
|
7924
|
+
debug2("onerror", er);
|
|
7925
7925
|
unpipe();
|
|
7926
7926
|
dest.removeListener("error", onerror);
|
|
7927
7927
|
if (EElistenerCount(dest, "error") === 0) errorOrDestroy(dest, er);
|
|
@@ -7933,18 +7933,18 @@ var require_stream_readable2 = __commonJS({
|
|
|
7933
7933
|
}
|
|
7934
7934
|
dest.once("close", onclose);
|
|
7935
7935
|
function onfinish() {
|
|
7936
|
-
|
|
7936
|
+
debug2("onfinish");
|
|
7937
7937
|
dest.removeListener("close", onclose);
|
|
7938
7938
|
unpipe();
|
|
7939
7939
|
}
|
|
7940
7940
|
dest.once("finish", onfinish);
|
|
7941
7941
|
function unpipe() {
|
|
7942
|
-
|
|
7942
|
+
debug2("unpipe");
|
|
7943
7943
|
src.unpipe(dest);
|
|
7944
7944
|
}
|
|
7945
7945
|
dest.emit("pipe", src);
|
|
7946
7946
|
if (!state.flowing) {
|
|
7947
|
-
|
|
7947
|
+
debug2("pipe resume");
|
|
7948
7948
|
src.resume();
|
|
7949
7949
|
}
|
|
7950
7950
|
return dest;
|
|
@@ -7952,7 +7952,7 @@ var require_stream_readable2 = __commonJS({
|
|
|
7952
7952
|
function pipeOnDrain(src) {
|
|
7953
7953
|
return function pipeOnDrainFunctionResult() {
|
|
7954
7954
|
var state = src._readableState;
|
|
7955
|
-
|
|
7955
|
+
debug2("pipeOnDrain", state.awaitDrain);
|
|
7956
7956
|
if (state.awaitDrain) state.awaitDrain--;
|
|
7957
7957
|
if (state.awaitDrain === 0 && EElistenerCount(src, "data")) {
|
|
7958
7958
|
state.flowing = true;
|
|
@@ -8005,7 +8005,7 @@ var require_stream_readable2 = __commonJS({
|
|
|
8005
8005
|
state.readableListening = state.needReadable = true;
|
|
8006
8006
|
state.flowing = false;
|
|
8007
8007
|
state.emittedReadable = false;
|
|
8008
|
-
|
|
8008
|
+
debug2("on readable", state.length, state.reading);
|
|
8009
8009
|
if (state.length) {
|
|
8010
8010
|
emitReadable(this);
|
|
8011
8011
|
} else if (!state.reading) {
|
|
@@ -8040,13 +8040,13 @@ var require_stream_readable2 = __commonJS({
|
|
|
8040
8040
|
}
|
|
8041
8041
|
}
|
|
8042
8042
|
function nReadingNextTick(self2) {
|
|
8043
|
-
|
|
8043
|
+
debug2("readable nexttick read 0");
|
|
8044
8044
|
self2.read(0);
|
|
8045
8045
|
}
|
|
8046
8046
|
Readable.prototype.resume = function() {
|
|
8047
8047
|
var state = this._readableState;
|
|
8048
8048
|
if (!state.flowing) {
|
|
8049
|
-
|
|
8049
|
+
debug2("resume");
|
|
8050
8050
|
state.flowing = !state.readableListening;
|
|
8051
8051
|
resume(this, state);
|
|
8052
8052
|
}
|
|
@@ -8060,7 +8060,7 @@ var require_stream_readable2 = __commonJS({
|
|
|
8060
8060
|
}
|
|
8061
8061
|
}
|
|
8062
8062
|
function resume_(stream, state) {
|
|
8063
|
-
|
|
8063
|
+
debug2("resume", state.reading);
|
|
8064
8064
|
if (!state.reading) {
|
|
8065
8065
|
stream.read(0);
|
|
8066
8066
|
}
|
|
@@ -8070,9 +8070,9 @@ var require_stream_readable2 = __commonJS({
|
|
|
8070
8070
|
if (state.flowing && !state.reading) stream.read(0);
|
|
8071
8071
|
}
|
|
8072
8072
|
Readable.prototype.pause = function() {
|
|
8073
|
-
|
|
8073
|
+
debug2("call pause flowing=%j", this._readableState.flowing);
|
|
8074
8074
|
if (this._readableState.flowing !== false) {
|
|
8075
|
-
|
|
8075
|
+
debug2("pause");
|
|
8076
8076
|
this._readableState.flowing = false;
|
|
8077
8077
|
this.emit("pause");
|
|
8078
8078
|
}
|
|
@@ -8081,7 +8081,7 @@ var require_stream_readable2 = __commonJS({
|
|
|
8081
8081
|
};
|
|
8082
8082
|
function flow(stream) {
|
|
8083
8083
|
var state = stream._readableState;
|
|
8084
|
-
|
|
8084
|
+
debug2("flow", state.flowing);
|
|
8085
8085
|
while (state.flowing && stream.read() !== null) ;
|
|
8086
8086
|
}
|
|
8087
8087
|
Readable.prototype.wrap = function(stream) {
|
|
@@ -8089,7 +8089,7 @@ var require_stream_readable2 = __commonJS({
|
|
|
8089
8089
|
var state = this._readableState;
|
|
8090
8090
|
var paused = false;
|
|
8091
8091
|
stream.on("end", function() {
|
|
8092
|
-
|
|
8092
|
+
debug2("wrapped end");
|
|
8093
8093
|
if (state.decoder && !state.ended) {
|
|
8094
8094
|
var chunk = state.decoder.end();
|
|
8095
8095
|
if (chunk && chunk.length) _this.push(chunk);
|
|
@@ -8097,7 +8097,7 @@ var require_stream_readable2 = __commonJS({
|
|
|
8097
8097
|
_this.push(null);
|
|
8098
8098
|
});
|
|
8099
8099
|
stream.on("data", function(chunk) {
|
|
8100
|
-
|
|
8100
|
+
debug2("wrapped data");
|
|
8101
8101
|
if (state.decoder) chunk = state.decoder.write(chunk);
|
|
8102
8102
|
if (state.objectMode && (chunk === null || chunk === void 0)) return;
|
|
8103
8103
|
else if (!state.objectMode && (!chunk || !chunk.length)) return;
|
|
@@ -8120,7 +8120,7 @@ var require_stream_readable2 = __commonJS({
|
|
|
8120
8120
|
stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
|
|
8121
8121
|
}
|
|
8122
8122
|
this._read = function(n2) {
|
|
8123
|
-
|
|
8123
|
+
debug2("wrapped _read", n2);
|
|
8124
8124
|
if (paused) {
|
|
8125
8125
|
paused = false;
|
|
8126
8126
|
stream.resume();
|
|
@@ -8194,14 +8194,14 @@ var require_stream_readable2 = __commonJS({
|
|
|
8194
8194
|
}
|
|
8195
8195
|
function endReadable(stream) {
|
|
8196
8196
|
var state = stream._readableState;
|
|
8197
|
-
|
|
8197
|
+
debug2("endReadable", state.endEmitted);
|
|
8198
8198
|
if (!state.endEmitted) {
|
|
8199
8199
|
state.ended = true;
|
|
8200
8200
|
process.nextTick(endReadableNT, state, stream);
|
|
8201
8201
|
}
|
|
8202
8202
|
}
|
|
8203
8203
|
function endReadableNT(state, stream) {
|
|
8204
|
-
|
|
8204
|
+
debug2("endReadableNT", state.endEmitted, state.length);
|
|
8205
8205
|
if (!state.endEmitted && state.length === 0) {
|
|
8206
8206
|
state.endEmitted = true;
|
|
8207
8207
|
stream.readable = false;
|
|
@@ -10417,7 +10417,7 @@ var require_file = __commonJS({
|
|
|
10417
10417
|
var { MESSAGE } = require_triple_beam();
|
|
10418
10418
|
var { Stream, PassThrough } = require_readable();
|
|
10419
10419
|
var TransportStream = require_winston_transport();
|
|
10420
|
-
var
|
|
10420
|
+
var debug2 = require_node2()("winston:file");
|
|
10421
10421
|
var os = __require("os");
|
|
10422
10422
|
var tailFile = require_tail_file();
|
|
10423
10423
|
module.exports = class File extends TransportStream {
|
|
@@ -10561,7 +10561,7 @@ var require_file = __commonJS({
|
|
|
10561
10561
|
function logged() {
|
|
10562
10562
|
this._size += bytes;
|
|
10563
10563
|
this._pendingSize -= bytes;
|
|
10564
|
-
|
|
10564
|
+
debug2("logged %s %s", this._size, output);
|
|
10565
10565
|
this.emit("logged", info);
|
|
10566
10566
|
if (this._rotate) {
|
|
10567
10567
|
return;
|
|
@@ -10595,7 +10595,7 @@ var require_file = __commonJS({
|
|
|
10595
10595
|
} else {
|
|
10596
10596
|
callback();
|
|
10597
10597
|
}
|
|
10598
|
-
|
|
10598
|
+
debug2("written", written, this._drain);
|
|
10599
10599
|
this.finishIfEnding();
|
|
10600
10600
|
return written;
|
|
10601
10601
|
}
|
|
@@ -10748,7 +10748,7 @@ var require_file = __commonJS({
|
|
|
10748
10748
|
if (err) {
|
|
10749
10749
|
return this.emit("error", err);
|
|
10750
10750
|
}
|
|
10751
|
-
|
|
10751
|
+
debug2("stat done: %s { size: %s }", this.filename, size);
|
|
10752
10752
|
this._size = size;
|
|
10753
10753
|
this._dest = this._createStream(this._stream);
|
|
10754
10754
|
this._opening = false;
|
|
@@ -10769,12 +10769,12 @@ var require_file = __commonJS({
|
|
|
10769
10769
|
const fullpath = path.join(this.dirname, target);
|
|
10770
10770
|
fs.stat(fullpath, (err, stat) => {
|
|
10771
10771
|
if (err && err.code === "ENOENT") {
|
|
10772
|
-
|
|
10772
|
+
debug2("ENOENT\xA0ok", fullpath);
|
|
10773
10773
|
this.filename = target;
|
|
10774
10774
|
return callback(null, 0);
|
|
10775
10775
|
}
|
|
10776
10776
|
if (err) {
|
|
10777
|
-
|
|
10777
|
+
debug2(`err ${err.code} ${fullpath}`);
|
|
10778
10778
|
return callback(err);
|
|
10779
10779
|
}
|
|
10780
10780
|
if (!stat || this._needsNewFile(stat.size)) {
|
|
@@ -10871,9 +10871,9 @@ var require_file = __commonJS({
|
|
|
10871
10871
|
*/
|
|
10872
10872
|
_createStream(source) {
|
|
10873
10873
|
const fullpath = path.join(this.dirname, this.filename);
|
|
10874
|
-
|
|
10875
|
-
const dest = fs.createWriteStream(fullpath, this.options).on("error", (err) =>
|
|
10876
|
-
|
|
10874
|
+
debug2("create stream start", fullpath, this.options);
|
|
10875
|
+
const dest = fs.createWriteStream(fullpath, this.options).on("error", (err) => debug2(err)).on("close", () => debug2("close", dest.path, dest.bytesWritten)).on("open", () => {
|
|
10876
|
+
debug2("file open ok", fullpath);
|
|
10877
10877
|
this.emit("open", fullpath);
|
|
10878
10878
|
source.pipe(dest);
|
|
10879
10879
|
if (this.rotatedWhileOpening) {
|
|
@@ -10885,7 +10885,7 @@ var require_file = __commonJS({
|
|
|
10885
10885
|
source.end();
|
|
10886
10886
|
}
|
|
10887
10887
|
});
|
|
10888
|
-
|
|
10888
|
+
debug2("create stream ok", fullpath);
|
|
10889
10889
|
return dest;
|
|
10890
10890
|
}
|
|
10891
10891
|
/**
|
|
@@ -10894,7 +10894,7 @@ var require_file = __commonJS({
|
|
|
10894
10894
|
* @returns {undefined}
|
|
10895
10895
|
*/
|
|
10896
10896
|
_incFile(callback) {
|
|
10897
|
-
|
|
10897
|
+
debug2("_incFile", this.filename);
|
|
10898
10898
|
const ext = path.extname(this._basename);
|
|
10899
10899
|
const basename = path.basename(this._basename, ext);
|
|
10900
10900
|
const tasks = [];
|
|
@@ -11661,7 +11661,7 @@ var require_exception_handler = __commonJS({
|
|
|
11661
11661
|
"use strict";
|
|
11662
11662
|
var os = __require("os");
|
|
11663
11663
|
var asyncForEach = require_forEach();
|
|
11664
|
-
var
|
|
11664
|
+
var debug2 = require_node2()("winston:exception");
|
|
11665
11665
|
var once = require_one_time();
|
|
11666
11666
|
var stackTrace = require_stack_trace();
|
|
11667
11667
|
var ExceptionStream = require_exception_stream();
|
|
@@ -11807,8 +11807,8 @@ var require_exception_handler = __commonJS({
|
|
|
11807
11807
|
doExit = false;
|
|
11808
11808
|
}
|
|
11809
11809
|
function gracefulExit() {
|
|
11810
|
-
|
|
11811
|
-
|
|
11810
|
+
debug2("doExit", doExit);
|
|
11811
|
+
debug2("process._exiting", process._exiting);
|
|
11812
11812
|
if (doExit && !process._exiting) {
|
|
11813
11813
|
if (timeout) {
|
|
11814
11814
|
clearTimeout(timeout);
|
|
@@ -11824,7 +11824,7 @@ var require_exception_handler = __commonJS({
|
|
|
11824
11824
|
const transport = handler.transport || handler;
|
|
11825
11825
|
function onDone(event) {
|
|
11826
11826
|
return () => {
|
|
11827
|
-
|
|
11827
|
+
debug2(event);
|
|
11828
11828
|
done();
|
|
11829
11829
|
};
|
|
11830
11830
|
}
|
|
@@ -11899,7 +11899,7 @@ var require_rejection_handler = __commonJS({
|
|
|
11899
11899
|
"use strict";
|
|
11900
11900
|
var os = __require("os");
|
|
11901
11901
|
var asyncForEach = require_forEach();
|
|
11902
|
-
var
|
|
11902
|
+
var debug2 = require_node2()("winston:rejection");
|
|
11903
11903
|
var once = require_one_time();
|
|
11904
11904
|
var stackTrace = require_stack_trace();
|
|
11905
11905
|
var RejectionStream = require_rejection_stream();
|
|
@@ -12047,8 +12047,8 @@ var require_rejection_handler = __commonJS({
|
|
|
12047
12047
|
doExit = false;
|
|
12048
12048
|
}
|
|
12049
12049
|
function gracefulExit() {
|
|
12050
|
-
|
|
12051
|
-
|
|
12050
|
+
debug2("doExit", doExit);
|
|
12051
|
+
debug2("process._exiting", process._exiting);
|
|
12052
12052
|
if (doExit && !process._exiting) {
|
|
12053
12053
|
if (timeout) {
|
|
12054
12054
|
clearTimeout(timeout);
|
|
@@ -12066,7 +12066,7 @@ var require_rejection_handler = __commonJS({
|
|
|
12066
12066
|
const transport = handler.transport || handler;
|
|
12067
12067
|
function onDone(event) {
|
|
12068
12068
|
return () => {
|
|
12069
|
-
|
|
12069
|
+
debug2(event);
|
|
12070
12070
|
done();
|
|
12071
12071
|
};
|
|
12072
12072
|
}
|
|
@@ -12684,7 +12684,7 @@ var require_create_logger = __commonJS({
|
|
|
12684
12684
|
var { LEVEL } = require_triple_beam();
|
|
12685
12685
|
var config = require_config2();
|
|
12686
12686
|
var Logger2 = require_logger();
|
|
12687
|
-
var
|
|
12687
|
+
var debug2 = require_node2()("winston:create-logger");
|
|
12688
12688
|
function isLevelEnabledFunctionName(level) {
|
|
12689
12689
|
return "is" + level.charAt(0).toUpperCase() + level.slice(1) + "Enabled";
|
|
12690
12690
|
}
|
|
@@ -12703,7 +12703,7 @@ var require_create_logger = __commonJS({
|
|
|
12703
12703
|
}
|
|
12704
12704
|
const logger = new DerivedLogger(opts);
|
|
12705
12705
|
Object.keys(opts.levels).forEach(function(level) {
|
|
12706
|
-
|
|
12706
|
+
debug2('Define prototype method for "%s"', level);
|
|
12707
12707
|
if (level === "log") {
|
|
12708
12708
|
console.warn('Level "log" not defined: conflicts with the method "log". Use a different level name.');
|
|
12709
12709
|
return;
|
|
@@ -16902,6 +16902,19 @@ function keyToDisplayName(key) {
|
|
|
16902
16902
|
return key.replace(/[-_]/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
16903
16903
|
}
|
|
16904
16904
|
|
|
16905
|
+
// src/_debug.ts
|
|
16906
|
+
function _parseDebugEnv(value) {
|
|
16907
|
+
const v = value.trim().toLowerCase();
|
|
16908
|
+
return v === "1" || v === "true" || v === "yes";
|
|
16909
|
+
}
|
|
16910
|
+
var _DEBUG_ENABLED = _parseDebugEnv(process.env.SMPLKIT_DEBUG ?? "");
|
|
16911
|
+
function debug(subsystem, message) {
|
|
16912
|
+
if (!_DEBUG_ENABLED) return;
|
|
16913
|
+
const ts = (/* @__PURE__ */ new Date()).toISOString();
|
|
16914
|
+
process.stderr.write(`[smplkit:${subsystem}] ${ts} ${message}
|
|
16915
|
+
`);
|
|
16916
|
+
}
|
|
16917
|
+
|
|
16905
16918
|
// src/config/client.ts
|
|
16906
16919
|
var BASE_URL = "https://config.smplkit.com";
|
|
16907
16920
|
function extractItemValues(items) {
|
|
@@ -17288,6 +17301,7 @@ var ConfigClient = class {
|
|
|
17288
17301
|
if (this._getSharedWs) {
|
|
17289
17302
|
const ws = this._getSharedWs();
|
|
17290
17303
|
ws.on("config_changed", this._handleConfigChanged);
|
|
17304
|
+
ws.on("config_deleted", this._handleConfigChanged);
|
|
17291
17305
|
}
|
|
17292
17306
|
}
|
|
17293
17307
|
/** @internal — called by SmplClient for backward compat. */
|
|
@@ -17309,7 +17323,8 @@ var ConfigClient = class {
|
|
|
17309
17323
|
// ------------------------------------------------------------------
|
|
17310
17324
|
// Internal: WebSocket handler
|
|
17311
17325
|
// ------------------------------------------------------------------
|
|
17312
|
-
_handleConfigChanged = (
|
|
17326
|
+
_handleConfigChanged = (data) => {
|
|
17327
|
+
debug("websocket", `config event received: ${JSON.stringify(data)}`);
|
|
17313
17328
|
void this.refresh().catch(() => {
|
|
17314
17329
|
});
|
|
17315
17330
|
};
|
|
@@ -18027,6 +18042,7 @@ var FlagsClient = class {
|
|
|
18027
18042
|
*/
|
|
18028
18043
|
async initialize() {
|
|
18029
18044
|
if (this._initialized) return;
|
|
18045
|
+
debug("lifecycle", "FlagsClient.initialize() called");
|
|
18030
18046
|
this._environment = this._parent?._environment ?? null;
|
|
18031
18047
|
await this._fetchAllFlags();
|
|
18032
18048
|
this._initialized = true;
|
|
@@ -18204,6 +18220,7 @@ var FlagsClient = class {
|
|
|
18204
18220
|
// Internal: event handlers (called by SharedWebSocket)
|
|
18205
18221
|
// ------------------------------------------------------------------
|
|
18206
18222
|
_handleFlagChanged = (data) => {
|
|
18223
|
+
debug("websocket", `flag event received: ${JSON.stringify(data)}`);
|
|
18207
18224
|
const flagId = data.id;
|
|
18208
18225
|
void this._fetchAllFlags().then(() => {
|
|
18209
18226
|
this._cache.clear();
|
|
@@ -18211,6 +18228,7 @@ var FlagsClient = class {
|
|
|
18211
18228
|
});
|
|
18212
18229
|
};
|
|
18213
18230
|
_handleFlagDeleted = (data) => {
|
|
18231
|
+
debug("websocket", `flag deleted event received: ${JSON.stringify(data)}`);
|
|
18214
18232
|
const flagId = data.id;
|
|
18215
18233
|
void this._fetchAllFlags().then(() => {
|
|
18216
18234
|
this._cache.clear();
|
|
@@ -18229,6 +18247,7 @@ var FlagsClient = class {
|
|
|
18229
18247
|
this._flagStore = store;
|
|
18230
18248
|
}
|
|
18231
18249
|
async _fetchFlagsList() {
|
|
18250
|
+
debug("api", "GET /api/v1/flags");
|
|
18232
18251
|
let data;
|
|
18233
18252
|
try {
|
|
18234
18253
|
const result = await this._http.GET("/api/v1/flags", {});
|
|
@@ -18238,7 +18257,9 @@ var FlagsClient = class {
|
|
|
18238
18257
|
wrapFetchError2(err);
|
|
18239
18258
|
}
|
|
18240
18259
|
if (!data) return [];
|
|
18241
|
-
|
|
18260
|
+
const flags = data.data.map((r) => this._resourceToPlainDict(r));
|
|
18261
|
+
debug("api", `GET /api/v1/flags -> ${flags.length} flag(s)`);
|
|
18262
|
+
return flags;
|
|
18242
18263
|
}
|
|
18243
18264
|
// ------------------------------------------------------------------
|
|
18244
18265
|
// Internal: change listeners
|
|
@@ -18803,6 +18824,7 @@ var LoggingClient = class {
|
|
|
18803
18824
|
*/
|
|
18804
18825
|
async start() {
|
|
18805
18826
|
if (this._started) return;
|
|
18827
|
+
debug("lifecycle", "LoggingClient.start() called");
|
|
18806
18828
|
if (!this._explicitAdapters) {
|
|
18807
18829
|
this._adapters = this._autoLoadAdapters();
|
|
18808
18830
|
}
|
|
@@ -18814,11 +18836,13 @@ var LoggingClient = class {
|
|
|
18814
18836
|
} catch {
|
|
18815
18837
|
}
|
|
18816
18838
|
}
|
|
18839
|
+
debug("discovery", `discovered ${discovered.length} logger(s) from adapters`);
|
|
18817
18840
|
for (const adapter of this._adapters) {
|
|
18818
18841
|
try {
|
|
18819
18842
|
adapter.installHook((name, level) => {
|
|
18820
18843
|
this._onAdapterNewLogger(name, level);
|
|
18821
18844
|
});
|
|
18845
|
+
debug("discovery", `hook installed on adapter`);
|
|
18822
18846
|
} catch {
|
|
18823
18847
|
}
|
|
18824
18848
|
}
|
|
@@ -18841,28 +18865,38 @@ var LoggingClient = class {
|
|
|
18841
18865
|
environment: environment ?? void 0
|
|
18842
18866
|
})
|
|
18843
18867
|
);
|
|
18868
|
+
debug("registration", `flushing ${loggers.length} logger(s) to bulk-register endpoint`);
|
|
18844
18869
|
try {
|
|
18845
18870
|
const result = await this._http.POST("/api/v1/loggers/bulk", {
|
|
18846
18871
|
body: { loggers }
|
|
18847
18872
|
});
|
|
18848
18873
|
if (result.error !== void 0)
|
|
18849
18874
|
await checkError3(result.response, "Failed to bulk-register loggers");
|
|
18875
|
+
debug("registration", `bulk-register complete (${loggers.length} logger(s))`);
|
|
18850
18876
|
} catch (err) {
|
|
18851
18877
|
console.warn(
|
|
18852
18878
|
`[smplkit] Failed to bulk-register loggers: ${err instanceof Error ? err.message : String(err)}`
|
|
18853
18879
|
);
|
|
18854
18880
|
}
|
|
18855
18881
|
}
|
|
18882
|
+
debug("resolution", `starting resolution pass (trigger: start())`);
|
|
18856
18883
|
try {
|
|
18857
|
-
const [serverLoggers] = await Promise.all([
|
|
18884
|
+
const [serverLoggers, serverGroups] = await Promise.all([
|
|
18858
18885
|
this.management.list(),
|
|
18859
18886
|
this.management.listGroups()
|
|
18860
18887
|
]);
|
|
18888
|
+
debug(
|
|
18889
|
+
"api",
|
|
18890
|
+
`fetched ${serverLoggers.length} logger(s) and ${serverGroups.length} group(s) from server`
|
|
18891
|
+
);
|
|
18861
18892
|
this._applyLevels(serverLoggers);
|
|
18862
18893
|
} catch {
|
|
18863
18894
|
}
|
|
18864
18895
|
this._wsManager = this._ensureWs();
|
|
18865
18896
|
this._wsManager.on("logger_changed", this._handleLoggerChanged);
|
|
18897
|
+
this._wsManager.on("logger_deleted", this._handleLoggerChanged);
|
|
18898
|
+
this._wsManager.on("group_changed", this._handleGroupChanged);
|
|
18899
|
+
this._wsManager.on("group_deleted", this._handleGroupChanged);
|
|
18866
18900
|
this._started = true;
|
|
18867
18901
|
}
|
|
18868
18902
|
// ------------------------------------------------------------------
|
|
@@ -18893,14 +18927,19 @@ var LoggingClient = class {
|
|
|
18893
18927
|
// ------------------------------------------------------------------
|
|
18894
18928
|
/** @internal */
|
|
18895
18929
|
_close() {
|
|
18930
|
+
debug("lifecycle", "LoggingClient._close() called");
|
|
18896
18931
|
for (const adapter of this._adapters) {
|
|
18897
18932
|
try {
|
|
18898
18933
|
adapter.uninstallHook();
|
|
18934
|
+
debug("adapter", "applying-guard OFF \u2014 adapter hook uninstalled");
|
|
18899
18935
|
} catch {
|
|
18900
18936
|
}
|
|
18901
18937
|
}
|
|
18902
18938
|
if (this._wsManager !== null) {
|
|
18903
18939
|
this._wsManager.off("logger_changed", this._handleLoggerChanged);
|
|
18940
|
+
this._wsManager.off("logger_deleted", this._handleLoggerChanged);
|
|
18941
|
+
this._wsManager.off("group_changed", this._handleGroupChanged);
|
|
18942
|
+
this._wsManager.off("group_deleted", this._handleGroupChanged);
|
|
18904
18943
|
this._wsManager = null;
|
|
18905
18944
|
}
|
|
18906
18945
|
this._started = false;
|
|
@@ -18942,12 +18981,14 @@ var LoggingClient = class {
|
|
|
18942
18981
|
effectiveLevel = envOverride.level;
|
|
18943
18982
|
}
|
|
18944
18983
|
}
|
|
18984
|
+
debug("resolution", `${logger.id} -> ${effectiveLevel}`);
|
|
18945
18985
|
const metrics = this._parent?._metrics;
|
|
18946
18986
|
if (metrics) {
|
|
18947
18987
|
metrics.record("logging.level_changes", 1, "changes", { logger: logger.id });
|
|
18948
18988
|
}
|
|
18949
18989
|
for (const adapter of this._adapters) {
|
|
18950
18990
|
try {
|
|
18991
|
+
debug("adapter", `setLevel(${logger.id}, ${effectiveLevel})`);
|
|
18951
18992
|
adapter.applyLevel(logger.id, effectiveLevel);
|
|
18952
18993
|
} catch {
|
|
18953
18994
|
}
|
|
@@ -18956,6 +18997,7 @@ var LoggingClient = class {
|
|
|
18956
18997
|
}
|
|
18957
18998
|
/** Called by adapter hooks when a new logger is created in the framework. */
|
|
18958
18999
|
_onAdapterNewLogger(_name, _level) {
|
|
19000
|
+
debug("discovery", `new logger intercepted at runtime: ${_name}`);
|
|
18959
19001
|
const logger = this.management.new(_name, { managed: true });
|
|
18960
19002
|
logger.setLevel(_level);
|
|
18961
19003
|
logger.save().catch(() => {
|
|
@@ -18965,6 +19007,7 @@ var LoggingClient = class {
|
|
|
18965
19007
|
// Internal: WebSocket handler
|
|
18966
19008
|
// ------------------------------------------------------------------
|
|
18967
19009
|
_handleLoggerChanged = (data) => {
|
|
19010
|
+
debug("websocket", `logger event received: ${JSON.stringify(data)}`);
|
|
18968
19011
|
const id = data.id;
|
|
18969
19012
|
if (id) {
|
|
18970
19013
|
const level = data.level ?? null;
|
|
@@ -18973,6 +19016,11 @@ var LoggingClient = class {
|
|
|
18973
19016
|
level,
|
|
18974
19017
|
source: "websocket"
|
|
18975
19018
|
};
|
|
19019
|
+
void Promise.all([this.management.list(), this.management.listGroups()]).then(([serverLoggers]) => {
|
|
19020
|
+
debug("resolution", `resolution pass (trigger: websocket event for logger ${id})`);
|
|
19021
|
+
this._applyLevels(serverLoggers);
|
|
19022
|
+
}).catch(() => {
|
|
19023
|
+
});
|
|
18976
19024
|
for (const cb of this._globalListeners) {
|
|
18977
19025
|
try {
|
|
18978
19026
|
cb(event);
|
|
@@ -18990,6 +19038,14 @@ var LoggingClient = class {
|
|
|
18990
19038
|
}
|
|
18991
19039
|
}
|
|
18992
19040
|
};
|
|
19041
|
+
_handleGroupChanged = (data) => {
|
|
19042
|
+
debug("websocket", `group event received: ${JSON.stringify(data)}`);
|
|
19043
|
+
void Promise.all([this.management.list(), this.management.listGroups()]).then(([serverLoggers]) => {
|
|
19044
|
+
debug("resolution", `resolution pass (trigger: group websocket event)`);
|
|
19045
|
+
this._applyLevels(serverLoggers);
|
|
19046
|
+
}).catch(() => {
|
|
19047
|
+
});
|
|
19048
|
+
};
|
|
18993
19049
|
// ------------------------------------------------------------------
|
|
18994
19050
|
// Internal: model conversion
|
|
18995
19051
|
// ------------------------------------------------------------------
|
|
@@ -19061,12 +19117,15 @@ var SharedWebSocket = class {
|
|
|
19061
19117
|
}
|
|
19062
19118
|
_dispatch(eventName, data) {
|
|
19063
19119
|
const callbacks = this._listeners.get(eventName);
|
|
19064
|
-
if (callbacks) {
|
|
19065
|
-
|
|
19066
|
-
|
|
19067
|
-
|
|
19068
|
-
|
|
19069
|
-
|
|
19120
|
+
if (!callbacks || callbacks.length === 0) {
|
|
19121
|
+
debug("websocket", `no handler registered for event: "${eventName}"`);
|
|
19122
|
+
return;
|
|
19123
|
+
}
|
|
19124
|
+
debug("websocket", `routing "${eventName}" to ${callbacks.length} handler(s)`);
|
|
19125
|
+
for (const cb of [...callbacks]) {
|
|
19126
|
+
try {
|
|
19127
|
+
cb(data);
|
|
19128
|
+
} catch {
|
|
19070
19129
|
}
|
|
19071
19130
|
}
|
|
19072
19131
|
}
|
|
@@ -19081,11 +19140,13 @@ var SharedWebSocket = class {
|
|
|
19081
19140
|
// ------------------------------------------------------------------
|
|
19082
19141
|
/** Start the WebSocket connection. */
|
|
19083
19142
|
start() {
|
|
19143
|
+
debug("websocket", "starting WebSocket connection");
|
|
19084
19144
|
this._closed = false;
|
|
19085
19145
|
this._connect();
|
|
19086
19146
|
}
|
|
19087
19147
|
/** Stop the WebSocket connection. */
|
|
19088
19148
|
stop() {
|
|
19149
|
+
debug("websocket", "stopping WebSocket connection");
|
|
19089
19150
|
this._closed = true;
|
|
19090
19151
|
this._connectionStatus = "disconnected";
|
|
19091
19152
|
if (this._reconnectTimer !== null) {
|
|
@@ -19116,6 +19177,8 @@ var SharedWebSocket = class {
|
|
|
19116
19177
|
if (this._closed) return;
|
|
19117
19178
|
this._connectionStatus = "connecting";
|
|
19118
19179
|
const wsUrl = this._buildWsUrl();
|
|
19180
|
+
const safeUrl = wsUrl.split("?")[0];
|
|
19181
|
+
debug("websocket", `connecting to ${safeUrl}`);
|
|
19119
19182
|
try {
|
|
19120
19183
|
const ws = new WebSocket(wsUrl);
|
|
19121
19184
|
this._ws = ws;
|
|
@@ -19129,19 +19192,23 @@ var SharedWebSocket = class {
|
|
|
19129
19192
|
try {
|
|
19130
19193
|
const raw = String(data);
|
|
19131
19194
|
if (raw === "ping") {
|
|
19195
|
+
debug("websocket", "ping received, sending pong");
|
|
19132
19196
|
ws.send("pong");
|
|
19133
19197
|
return;
|
|
19134
19198
|
}
|
|
19199
|
+
debug("websocket", `event received: ${raw}`);
|
|
19135
19200
|
const msg = JSON.parse(raw);
|
|
19136
19201
|
if (msg.type === "connected") {
|
|
19137
19202
|
this._backoffIndex = 0;
|
|
19138
19203
|
this._connectionStatus = "connected";
|
|
19204
|
+
debug("websocket", `connected to ${safeUrl}`);
|
|
19139
19205
|
if (this._metrics) {
|
|
19140
19206
|
this._metrics.recordGauge("platform.websocket_connections", 1, "connections");
|
|
19141
19207
|
}
|
|
19142
19208
|
return;
|
|
19143
19209
|
}
|
|
19144
19210
|
if (msg.type === "error") {
|
|
19211
|
+
debug("websocket", `connection error from server: ${JSON.stringify(msg.message)}`);
|
|
19145
19212
|
return;
|
|
19146
19213
|
}
|
|
19147
19214
|
const eventName = msg.event;
|
|
@@ -19151,7 +19218,8 @@ var SharedWebSocket = class {
|
|
|
19151
19218
|
} catch {
|
|
19152
19219
|
}
|
|
19153
19220
|
});
|
|
19154
|
-
ws.on("close", () => {
|
|
19221
|
+
ws.on("close", (code) => {
|
|
19222
|
+
debug("websocket", `connection closed (code=${code})`);
|
|
19155
19223
|
if (this._metrics) {
|
|
19156
19224
|
this._metrics.recordGauge("platform.websocket_connections", 0, "connections");
|
|
19157
19225
|
}
|
|
@@ -19160,9 +19228,14 @@ var SharedWebSocket = class {
|
|
|
19160
19228
|
this._scheduleReconnect();
|
|
19161
19229
|
}
|
|
19162
19230
|
});
|
|
19163
|
-
ws.on("error", () => {
|
|
19231
|
+
ws.on("error", (err) => {
|
|
19232
|
+
debug("websocket", `WebSocket error: ${err.message}`);
|
|
19164
19233
|
});
|
|
19165
|
-
} catch {
|
|
19234
|
+
} catch (err) {
|
|
19235
|
+
debug(
|
|
19236
|
+
"websocket",
|
|
19237
|
+
`failed to create WebSocket: ${err instanceof Error ? err.message : String(err)}`
|
|
19238
|
+
);
|
|
19166
19239
|
if (!this._closed) {
|
|
19167
19240
|
this._scheduleReconnect();
|
|
19168
19241
|
}
|
|
@@ -19173,6 +19246,7 @@ var SharedWebSocket = class {
|
|
|
19173
19246
|
const delay = BACKOFF_MS[Math.min(this._backoffIndex, BACKOFF_MS.length - 1)];
|
|
19174
19247
|
this._backoffIndex++;
|
|
19175
19248
|
this._connectionStatus = "connecting";
|
|
19249
|
+
debug("websocket", `reconnecting in ${delay}ms (attempt ${this._backoffIndex})`);
|
|
19176
19250
|
this._reconnectTimer = setTimeout(() => {
|
|
19177
19251
|
this._reconnectTimer = null;
|
|
19178
19252
|
this._connect();
|
|
@@ -19407,6 +19481,11 @@ var SmplClient = class {
|
|
|
19407
19481
|
const apiKey = resolveApiKey(options.apiKey, environment);
|
|
19408
19482
|
this._apiKey = apiKey;
|
|
19409
19483
|
this._timeout = options.timeout ?? 3e4;
|
|
19484
|
+
const maskedKey = apiKey.length > 14 ? apiKey.slice(0, 10) + "..." + apiKey.slice(-4) : apiKey.slice(0, Math.min(4, apiKey.length)) + "...";
|
|
19485
|
+
debug(
|
|
19486
|
+
"lifecycle",
|
|
19487
|
+
`SmplClient created (api_key=${maskedKey}, environment=${environment}, service=${service})`
|
|
19488
|
+
);
|
|
19410
19489
|
this._appHttp = createClient4({
|
|
19411
19490
|
baseUrl: APP_BASE_URL3,
|
|
19412
19491
|
headers: {
|
|
@@ -19461,6 +19540,7 @@ var SmplClient = class {
|
|
|
19461
19540
|
}
|
|
19462
19541
|
/** Close the shared WebSocket and release resources. */
|
|
19463
19542
|
close() {
|
|
19543
|
+
debug("lifecycle", "SmplClient.close() called");
|
|
19464
19544
|
if (this._metrics !== null) {
|
|
19465
19545
|
this._metrics.close();
|
|
19466
19546
|
}
|