@adviser/cement 0.2.1 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- package/{base_sys_abstraction-BsaOQtnz.d.cts → base_sys_abstraction-B_h8JSlV.d.cts} +1 -1
- package/{base_sys_abstraction-CQ7PJOct.d.ts → base_sys_abstraction-uF0nL2K3.d.ts} +1 -1
- package/{chunk-ZYFWDQGV.js → chunk-J2IM7FHM.js} +1 -3
- package/{chunk-XBYS4FSO.js → chunk-WZMCPT2R.js} +4 -4
- package/chunk-WZMCPT2R.js.map +1 -0
- package/{chunk-CI63N5CK.js → chunk-X4Z6DNDD.js} +284 -109
- package/chunk-X4Z6DNDD.js.map +1 -0
- package/index.cjs +329 -281
- package/index.cjs.map +1 -1
- package/index.d.cts +22 -18
- package/index.d.ts +22 -18
- package/index.js +56 -176
- package/index.js.map +1 -1
- package/node/index.cjs +220 -106
- package/node/index.cjs.map +1 -1
- package/node/index.d.cts +3 -3
- package/node/index.d.ts +3 -3
- package/node/index.js +4 -4
- package/node/index.js.map +1 -1
- package/package.json +6 -5
- package/{sys_abstraction-BzkoCY1p.d.cts → sys_abstraction-C1-BRiiP.d.cts} +26 -9
- package/{sys_abstraction-BzkoCY1p.d.ts → sys_abstraction-C1-BRiiP.d.ts} +26 -9
- package/utils/index.js +1 -1
- package/web/index.cjs +220 -106
- package/web/index.cjs.map +1 -1
- package/web/index.d.cts +2 -2
- package/web/index.d.ts +2 -2
- package/web/index.js +3 -3
- package/chunk-CI63N5CK.js.map +0 -1
- package/chunk-XBYS4FSO.js.map +0 -1
- /package/{chunk-ZYFWDQGV.js.map → chunk-J2IM7FHM.js.map} +0 -0
package/index.cjs
CHANGED
@@ -38,7 +38,6 @@ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot
|
|
38
38
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
39
39
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
40
40
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
41
|
-
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
42
41
|
var __await = function(promise, isYieldStar) {
|
43
42
|
this[0] = promise;
|
44
43
|
this[1] = isYieldStar;
|
@@ -75,6 +74,7 @@ var __yieldStar = (value) => {
|
|
75
74
|
// src/index.ts
|
76
75
|
var src_exports = {};
|
77
76
|
__export(src_exports, {
|
77
|
+
BrowserEnvActions: () => BrowserEnvActions,
|
78
78
|
EnvImpl: () => EnvImpl,
|
79
79
|
Future: () => Future,
|
80
80
|
IDMode: () => IDMode,
|
@@ -85,6 +85,7 @@ __export(src_exports, {
|
|
85
85
|
Level: () => Level,
|
86
86
|
LevelHandlerImpl: () => LevelHandlerImpl,
|
87
87
|
LogCollector: () => LogCollector,
|
88
|
+
LogValue: () => LogValue,
|
88
89
|
LogWriter: () => LogWriter,
|
89
90
|
LoggerImpl: () => LoggerImpl,
|
90
91
|
MockLogger: () => MockLogger,
|
@@ -101,7 +102,9 @@ __export(src_exports, {
|
|
101
102
|
Time: () => Time,
|
102
103
|
TimeMode: () => TimeMode,
|
103
104
|
TimeUnits: () => TimeUnits,
|
104
|
-
|
105
|
+
envFactory: () => envFactory,
|
106
|
+
logValue: () => logValue,
|
107
|
+
removeSelfRef: () => removeSelfRef
|
105
108
|
});
|
106
109
|
module.exports = __toCommonJS(src_exports);
|
107
110
|
|
@@ -113,6 +116,46 @@ var Level = /* @__PURE__ */ ((Level2) => {
|
|
113
116
|
Level2["ERROR"] = "error";
|
114
117
|
return Level2;
|
115
118
|
})(Level || {});
|
119
|
+
var LogValue = class {
|
120
|
+
constructor(fn) {
|
121
|
+
this.fn = fn;
|
122
|
+
}
|
123
|
+
value() {
|
124
|
+
return this.fn();
|
125
|
+
}
|
126
|
+
toJSON() {
|
127
|
+
return this.value();
|
128
|
+
}
|
129
|
+
};
|
130
|
+
function removeSelfRef() {
|
131
|
+
const cache = /* @__PURE__ */ new Set();
|
132
|
+
return function(key, value) {
|
133
|
+
if (typeof value === "object" && value !== null) {
|
134
|
+
if (cache.has(value)) return "...";
|
135
|
+
cache.add(value);
|
136
|
+
}
|
137
|
+
return value;
|
138
|
+
};
|
139
|
+
}
|
140
|
+
function logValue(val) {
|
141
|
+
switch (typeof val) {
|
142
|
+
case "function":
|
143
|
+
return new LogValue(val);
|
144
|
+
case "string":
|
145
|
+
return new LogValue(() => val.toString());
|
146
|
+
case "number":
|
147
|
+
return new LogValue(() => val);
|
148
|
+
case "boolean":
|
149
|
+
return new LogValue(() => val);
|
150
|
+
case "object":
|
151
|
+
return new LogValue(() => JSON.parse(JSON.stringify(val, removeSelfRef())));
|
152
|
+
default:
|
153
|
+
if (!val) {
|
154
|
+
return new LogValue(() => "--Falsy--");
|
155
|
+
}
|
156
|
+
throw new Error(`Invalid type:${typeof val}`);
|
157
|
+
}
|
158
|
+
}
|
116
159
|
function IsLogger(obj) {
|
117
160
|
return typeof obj === "object" && [
|
118
161
|
"Module",
|
@@ -356,170 +399,339 @@ var WrapperSysAbstraction = class {
|
|
356
399
|
}
|
357
400
|
};
|
358
401
|
|
402
|
+
// src/future.ts
|
403
|
+
var _promise, _resolveFn, _rejectFn;
|
404
|
+
var Future = class {
|
405
|
+
constructor() {
|
406
|
+
__privateAdd(this, _promise);
|
407
|
+
__privateAdd(this, _resolveFn, () => {
|
408
|
+
throw new Error("This Promise is not working as expected.");
|
409
|
+
});
|
410
|
+
__privateAdd(this, _rejectFn, () => {
|
411
|
+
throw new Error("This Promise is not working as expected.");
|
412
|
+
});
|
413
|
+
__privateSet(this, _promise, new Promise((resolve, reject) => {
|
414
|
+
__privateSet(this, _resolveFn, resolve);
|
415
|
+
__privateSet(this, _rejectFn, reject);
|
416
|
+
}));
|
417
|
+
}
|
418
|
+
async asPromise() {
|
419
|
+
return __privateGet(this, _promise);
|
420
|
+
}
|
421
|
+
resolve(value) {
|
422
|
+
__privateGet(this, _resolveFn).call(this, value);
|
423
|
+
}
|
424
|
+
reject(reason) {
|
425
|
+
__privateGet(this, _rejectFn).call(this, reason);
|
426
|
+
}
|
427
|
+
};
|
428
|
+
_promise = new WeakMap();
|
429
|
+
_resolveFn = new WeakMap();
|
430
|
+
_rejectFn = new WeakMap();
|
431
|
+
|
432
|
+
// src/resolve-once.ts
|
433
|
+
var ResolveSeq = class {
|
434
|
+
constructor(ctx) {
|
435
|
+
this._seqFutures = [];
|
436
|
+
this.ctx = ctx;
|
437
|
+
}
|
438
|
+
reset() {
|
439
|
+
}
|
440
|
+
async _step(item) {
|
441
|
+
if (!item) {
|
442
|
+
return;
|
443
|
+
}
|
444
|
+
item.fn(this.ctx).then((value) => item.future.resolve(value)).catch((e) => item.future.reject(e)).finally(() => this._step(this._seqFutures.shift()));
|
445
|
+
}
|
446
|
+
async add(fn) {
|
447
|
+
const future = new Future();
|
448
|
+
this._seqFutures.push({ future, fn });
|
449
|
+
this._step(this._seqFutures.shift());
|
450
|
+
return future.asPromise();
|
451
|
+
}
|
452
|
+
};
|
453
|
+
var ResolveOnce = class {
|
454
|
+
constructor(ctx) {
|
455
|
+
this._onceDone = false;
|
456
|
+
this._onceFutures = [];
|
457
|
+
this._onceOk = false;
|
458
|
+
this._isPromise = false;
|
459
|
+
this.ctx = ctx;
|
460
|
+
}
|
461
|
+
get ready() {
|
462
|
+
return this._onceDone;
|
463
|
+
}
|
464
|
+
reset() {
|
465
|
+
this._onceDone = false;
|
466
|
+
this._onceOk = false;
|
467
|
+
this._onceValue = void 0;
|
468
|
+
this._onceError = void 0;
|
469
|
+
this._onceFutures.length = 0;
|
470
|
+
}
|
471
|
+
// T extends Option<infer U> ? U : T
|
472
|
+
once(fn) {
|
473
|
+
if (this._onceDone) {
|
474
|
+
if (this._onceError) {
|
475
|
+
if (this._isPromise) {
|
476
|
+
return Promise.reject(this._onceError);
|
477
|
+
} else {
|
478
|
+
throw this._onceError;
|
479
|
+
}
|
480
|
+
}
|
481
|
+
if (this._onceOk) {
|
482
|
+
if (this._isPromise) {
|
483
|
+
return Promise.resolve(this._onceValue);
|
484
|
+
} else {
|
485
|
+
return this._onceValue;
|
486
|
+
}
|
487
|
+
}
|
488
|
+
throw new Error("ResolveOnce.once impossible");
|
489
|
+
}
|
490
|
+
const future = new Future();
|
491
|
+
this._onceFutures.push(future);
|
492
|
+
if (this._onceFutures.length === 1) {
|
493
|
+
const okFn = (value) => {
|
494
|
+
this._onceValue = value;
|
495
|
+
this._onceOk = true;
|
496
|
+
this._onceDone = true;
|
497
|
+
if (this._isPromise) {
|
498
|
+
this._onceFutures.forEach((f) => f.resolve(this._onceValue));
|
499
|
+
}
|
500
|
+
this._onceFutures.length = 0;
|
501
|
+
};
|
502
|
+
const catchFn = (e) => {
|
503
|
+
this._onceError = e;
|
504
|
+
this._onceOk = false;
|
505
|
+
this._onceValue = void 0;
|
506
|
+
this._onceDone = true;
|
507
|
+
if (this._isPromise) {
|
508
|
+
this._onceFutures.forEach((f) => f.reject(this._onceError));
|
509
|
+
}
|
510
|
+
this._onceFutures.length = 0;
|
511
|
+
};
|
512
|
+
try {
|
513
|
+
const ret = fn(this.ctx);
|
514
|
+
if (typeof ret.then === "function") {
|
515
|
+
this._isPromise = true;
|
516
|
+
ret.then(okFn).catch(catchFn);
|
517
|
+
} else {
|
518
|
+
okFn(ret);
|
519
|
+
}
|
520
|
+
} catch (e) {
|
521
|
+
catchFn(e);
|
522
|
+
}
|
523
|
+
}
|
524
|
+
if (this._isPromise) {
|
525
|
+
return future.asPromise();
|
526
|
+
} else {
|
527
|
+
return this.once(fn);
|
528
|
+
}
|
529
|
+
}
|
530
|
+
};
|
531
|
+
var Keyed = class {
|
532
|
+
constructor(factory) {
|
533
|
+
this._map = /* @__PURE__ */ new Map();
|
534
|
+
this.factory = factory;
|
535
|
+
}
|
536
|
+
async asyncGet(key) {
|
537
|
+
return this.get(await key());
|
538
|
+
}
|
539
|
+
get(key) {
|
540
|
+
if (typeof key === "function") {
|
541
|
+
key = key();
|
542
|
+
}
|
543
|
+
let keyed = this._map.get(key);
|
544
|
+
if (!keyed) {
|
545
|
+
keyed = this.factory(key);
|
546
|
+
this._map.set(key, keyed);
|
547
|
+
}
|
548
|
+
return keyed;
|
549
|
+
}
|
550
|
+
reset() {
|
551
|
+
this._map.forEach((keyed) => keyed.reset());
|
552
|
+
this._map.clear();
|
553
|
+
}
|
554
|
+
};
|
555
|
+
var KeyedResolvOnce = class extends Keyed {
|
556
|
+
constructor() {
|
557
|
+
super((key) => new ResolveOnce(key));
|
558
|
+
}
|
559
|
+
};
|
560
|
+
var KeyedResolvSeq = class extends Keyed {
|
561
|
+
constructor() {
|
562
|
+
super((key) => new ResolveSeq(key));
|
563
|
+
}
|
564
|
+
};
|
565
|
+
|
359
566
|
// src/sys_env.ts
|
360
|
-
var _node
|
567
|
+
var _node;
|
361
568
|
var NodeEnvActions = class {
|
362
569
|
// eslint-disable-next-line @typescript-eslint/no-useless-constructor, @typescript-eslint/no-unused-vars
|
363
570
|
constructor(opts) {
|
364
571
|
__privateAdd(this, _node, globalThis);
|
365
|
-
|
572
|
+
this._env = this.active() ? __privateGet(this, _node).process.env : {};
|
366
573
|
}
|
367
|
-
|
574
|
+
register(env) {
|
575
|
+
return env;
|
576
|
+
}
|
577
|
+
active() {
|
368
578
|
return typeof __privateGet(this, _node) === "object" && typeof __privateGet(this, _node).process === "object" && typeof __privateGet(this, _node).process.env === "object";
|
369
579
|
}
|
370
580
|
keys() {
|
371
|
-
return Object.keys(
|
581
|
+
return Object.keys(this._env);
|
372
582
|
}
|
373
583
|
get(key) {
|
374
|
-
return
|
584
|
+
return this._env[key];
|
375
585
|
}
|
376
586
|
set(key, value) {
|
377
587
|
if (value) {
|
378
|
-
|
588
|
+
this._env[key] = value;
|
379
589
|
}
|
380
590
|
}
|
381
|
-
|
382
|
-
delete
|
591
|
+
delete(key) {
|
592
|
+
delete this._env[key];
|
383
593
|
}
|
384
594
|
};
|
385
595
|
_node = new WeakMap();
|
386
|
-
|
387
|
-
var _deno, _env2;
|
596
|
+
var _deno;
|
388
597
|
var DenoEnvActions = class {
|
389
|
-
constructor
|
598
|
+
// eslint-disable-next-line @typescript-eslint/no-useless-constructor, @typescript-eslint/no-unused-vars
|
599
|
+
constructor(opts) {
|
390
600
|
__privateAdd(this, _deno, globalThis);
|
391
|
-
__privateAdd(this, _env2);
|
392
|
-
if (env) {
|
393
|
-
__privateSet(this, _env2, env);
|
394
|
-
} else {
|
395
|
-
__privateSet(this, _env2, this.use() ? __privateGet(this, _deno).Deno.env : /* @__PURE__ */ new Map());
|
396
|
-
}
|
397
601
|
}
|
398
|
-
|
602
|
+
get _env() {
|
603
|
+
return __privateGet(this, _deno).Deno.env;
|
604
|
+
}
|
605
|
+
register(env) {
|
606
|
+
return env;
|
607
|
+
}
|
608
|
+
active() {
|
399
609
|
return typeof __privateGet(this, _deno) === "object" && typeof __privateGet(this, _deno).Deno === "object" && typeof __privateGet(this, _deno).Deno.env === "object";
|
400
610
|
}
|
401
611
|
keys() {
|
402
|
-
return Array.from(
|
612
|
+
return Array.from(this._env.keys());
|
403
613
|
}
|
404
614
|
get(key) {
|
405
|
-
return
|
615
|
+
return this._env.get(key);
|
406
616
|
}
|
407
617
|
set(key, value) {
|
408
618
|
if (value) {
|
409
|
-
|
619
|
+
this._env.set(key, value);
|
410
620
|
}
|
411
621
|
}
|
412
|
-
|
413
|
-
|
622
|
+
delete(key) {
|
623
|
+
this._env.delete(key);
|
414
624
|
}
|
415
625
|
};
|
416
626
|
_deno = new WeakMap();
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
627
|
+
var BrowserEnvActions = class {
|
628
|
+
constructor(opts) {
|
629
|
+
this.env = /* @__PURE__ */ new Map();
|
630
|
+
this.opts = opts;
|
631
|
+
}
|
632
|
+
get(key) {
|
633
|
+
return this.env.get(key);
|
634
|
+
}
|
635
|
+
set(key, value) {
|
636
|
+
if (value) {
|
637
|
+
this.env.set(key, value);
|
423
638
|
}
|
424
|
-
const map = /* @__PURE__ */ new Map();
|
425
|
-
return {
|
426
|
-
map,
|
427
|
-
finalize: (bea) => {
|
428
|
-
browser[sym] = bea;
|
429
|
-
return map;
|
430
|
-
}
|
431
|
-
};
|
432
639
|
}
|
433
|
-
|
434
|
-
|
435
|
-
super(opts, map);
|
436
|
-
this._map = finalize(this);
|
640
|
+
delete(key) {
|
641
|
+
this.env.delete(key);
|
437
642
|
}
|
438
|
-
|
643
|
+
keys() {
|
644
|
+
return Array.from(this.env.keys());
|
645
|
+
}
|
646
|
+
active() {
|
439
647
|
return true;
|
440
648
|
}
|
649
|
+
register(env) {
|
650
|
+
const sym = Symbol.for(this.opts.symbol || "CP_ENV");
|
651
|
+
const browser = globalThis;
|
652
|
+
browser[sym] = env;
|
653
|
+
return env;
|
654
|
+
}
|
441
655
|
};
|
656
|
+
var _envFactory = new ResolveOnce();
|
442
657
|
function envFactory(opts = {}) {
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
658
|
+
return _envFactory.once(() => {
|
659
|
+
const found = [new NodeEnvActions(opts), new DenoEnvActions(opts), new BrowserEnvActions(opts)].find((env) => env.active());
|
660
|
+
if (!found) {
|
661
|
+
throw new Error("SysContainer:envFactory: no env available");
|
662
|
+
}
|
663
|
+
const ret = new EnvImpl(found, opts);
|
664
|
+
found.register(ret);
|
665
|
+
return ret;
|
666
|
+
});
|
448
667
|
}
|
449
|
-
var _envImpl, _EnvImpl_instances, updatePresets_fn, applyOnSet_fn, _onSet;
|
450
668
|
var EnvImpl = class {
|
451
|
-
constructor(opts = {}) {
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
669
|
+
constructor(map, opts = {}) {
|
670
|
+
this._onSet = [];
|
671
|
+
this._map = map;
|
672
|
+
this._updatePresets(opts.presetEnv);
|
673
|
+
}
|
674
|
+
_updatePresets(presetEnv) {
|
675
|
+
if (!presetEnv) {
|
676
|
+
return;
|
677
|
+
}
|
678
|
+
for (const [key, value] of presetEnv) {
|
679
|
+
this._map.set(key, value);
|
680
|
+
}
|
681
|
+
}
|
682
|
+
_applyOnSet(onSet, key, value) {
|
683
|
+
onSet.forEach((item) => {
|
684
|
+
let keys = [];
|
685
|
+
if (key) {
|
686
|
+
keys = [key];
|
687
|
+
} else {
|
688
|
+
keys = this._map.keys();
|
689
|
+
}
|
690
|
+
keys.filter((k) => {
|
691
|
+
if (item.filter.size === 0) {
|
692
|
+
return true;
|
693
|
+
}
|
694
|
+
if (item.filter.has(k)) {
|
695
|
+
return true;
|
696
|
+
}
|
697
|
+
return false;
|
698
|
+
}).forEach((k) => {
|
699
|
+
let v;
|
700
|
+
if (!key && !value) {
|
701
|
+
v = this._map.get(k);
|
702
|
+
} else if (key && !value) {
|
703
|
+
v = void 0;
|
704
|
+
} else {
|
705
|
+
v = value;
|
706
|
+
}
|
707
|
+
item.fn(k, v);
|
708
|
+
});
|
709
|
+
});
|
457
710
|
}
|
458
711
|
keys() {
|
459
|
-
return
|
712
|
+
return this._map.keys();
|
460
713
|
}
|
461
714
|
// filter is not set all sets passed
|
462
715
|
onSet(fn, ...filter) {
|
463
716
|
const item = { filter: new Set(filter), fn };
|
464
|
-
|
465
|
-
|
717
|
+
this._onSet.push(item);
|
718
|
+
this._applyOnSet([item]);
|
466
719
|
}
|
467
720
|
get(key) {
|
468
|
-
return
|
721
|
+
return this._map.get(key);
|
469
722
|
}
|
470
723
|
set(key, value) {
|
471
724
|
if (!value) {
|
472
725
|
return;
|
473
726
|
}
|
474
|
-
|
475
|
-
|
727
|
+
this._map.set(key, value);
|
728
|
+
this._applyOnSet(this._onSet, key, value);
|
476
729
|
}
|
477
|
-
|
478
|
-
|
479
|
-
|
730
|
+
delete(key) {
|
731
|
+
this._map.delete(key);
|
732
|
+
this._applyOnSet(this._onSet, key);
|
480
733
|
}
|
481
734
|
};
|
482
|
-
_envImpl = new WeakMap();
|
483
|
-
_EnvImpl_instances = new WeakSet();
|
484
|
-
updatePresets_fn = function(presetEnv) {
|
485
|
-
if (!presetEnv) {
|
486
|
-
return;
|
487
|
-
}
|
488
|
-
for (const [key, value] of presetEnv) {
|
489
|
-
__privateGet(this, _envImpl).set(key, value);
|
490
|
-
}
|
491
|
-
};
|
492
|
-
applyOnSet_fn = function(onSet, key, value) {
|
493
|
-
onSet.forEach((item) => {
|
494
|
-
let keys = [];
|
495
|
-
if (key) {
|
496
|
-
keys = [key];
|
497
|
-
} else {
|
498
|
-
keys = __privateGet(this, _envImpl).keys();
|
499
|
-
}
|
500
|
-
keys.filter((k) => {
|
501
|
-
if (item.filter.size === 0) {
|
502
|
-
return true;
|
503
|
-
}
|
504
|
-
if (item.filter.has(k)) {
|
505
|
-
return true;
|
506
|
-
}
|
507
|
-
return false;
|
508
|
-
}).forEach((k) => {
|
509
|
-
let v;
|
510
|
-
if (!key && !value) {
|
511
|
-
v = __privateGet(this, _envImpl).get(k);
|
512
|
-
} else if (key && !value) {
|
513
|
-
v = void 0;
|
514
|
-
} else {
|
515
|
-
v = value;
|
516
|
-
}
|
517
|
-
item.fn(k, v);
|
518
|
-
});
|
519
|
-
});
|
520
|
-
};
|
521
|
-
_onSet = new WeakMap();
|
522
|
-
var envImpl = new EnvImpl();
|
523
735
|
|
524
736
|
// src/web/web_sys_abstraction.ts
|
525
737
|
var WebFileService = class {
|
@@ -569,7 +781,7 @@ var WebFileService = class {
|
|
569
781
|
};
|
570
782
|
var WebSystemService = class {
|
571
783
|
Env() {
|
572
|
-
return
|
784
|
+
return envFactory();
|
573
785
|
}
|
574
786
|
Args() {
|
575
787
|
throw new Error("Args-Method not implemented.");
|
@@ -596,43 +808,6 @@ function WebSysAbstraction(param) {
|
|
596
808
|
|
597
809
|
// src/logger_impl.ts
|
598
810
|
var encoder = new TextEncoder();
|
599
|
-
var LogValue = class {
|
600
|
-
constructor(fn) {
|
601
|
-
this.fn = fn;
|
602
|
-
}
|
603
|
-
value() {
|
604
|
-
return this.fn();
|
605
|
-
}
|
606
|
-
};
|
607
|
-
function resolveLogValue(val) {
|
608
|
-
const ret = {};
|
609
|
-
Object.keys(val).forEach((key) => {
|
610
|
-
const v = val[key];
|
611
|
-
if (v instanceof LogValue) {
|
612
|
-
ret[key] = v.value();
|
613
|
-
}
|
614
|
-
});
|
615
|
-
return ret;
|
616
|
-
}
|
617
|
-
function logValue(val) {
|
618
|
-
switch (typeof val) {
|
619
|
-
case "function":
|
620
|
-
return new LogValue(val);
|
621
|
-
case "string":
|
622
|
-
return new LogValue(() => val.toString());
|
623
|
-
case "number":
|
624
|
-
return new LogValue(() => val);
|
625
|
-
case "boolean":
|
626
|
-
return new LogValue(() => val);
|
627
|
-
case "object":
|
628
|
-
return new LogValue(() => JSON.stringify(val));
|
629
|
-
default:
|
630
|
-
if (!val) {
|
631
|
-
return new LogValue(() => "--Falsy--");
|
632
|
-
}
|
633
|
-
throw new Error(`Invalid type:${typeof val}`);
|
634
|
-
}
|
635
|
-
}
|
636
811
|
var LevelHandlerImpl = class {
|
637
812
|
constructor() {
|
638
813
|
this._globalLevels = /* @__PURE__ */ new Set(["info" /* INFO */, "error" /* ERROR */, "warn" /* WARN */]);
|
@@ -666,6 +841,9 @@ var LevelHandlerImpl = class {
|
|
666
841
|
}
|
667
842
|
forModules(level, fnAction, ...modules) {
|
668
843
|
for (const m of modules.flat()) {
|
844
|
+
if (typeof m !== "string") {
|
845
|
+
continue;
|
846
|
+
}
|
669
847
|
const parts = m.split(",").map((s) => s.trim()).filter((s) => s.length);
|
670
848
|
for (const p of parts) {
|
671
849
|
fnAction(p);
|
@@ -925,7 +1103,7 @@ var LoggerImpl = class _LoggerImpl {
|
|
925
1103
|
_attributes: attr
|
926
1104
|
});
|
927
1105
|
}
|
928
|
-
return JSON.stringify(
|
1106
|
+
return JSON.stringify(attr, removeSelfRef());
|
929
1107
|
}
|
930
1108
|
Msg(...args) {
|
931
1109
|
const fnError = this._resetAttributes(() => {
|
@@ -933,7 +1111,7 @@ var LoggerImpl = class _LoggerImpl {
|
|
933
1111
|
const doWrite = this._levelHandler.isEnabled((_a = this._attributes["level"]) == null ? void 0 : _a.value(), (_b = this._attributes["module"]) == null ? void 0 : _b.value());
|
934
1112
|
let fnRet = () => this._produceError(__spreadValues({}, this._attributes), ...args);
|
935
1113
|
if (doWrite) {
|
936
|
-
const str =
|
1114
|
+
const str = fnRet();
|
937
1115
|
const encoded = encoder.encode(str + "\n");
|
938
1116
|
this._logWriter.write(encoded);
|
939
1117
|
fnRet = () => str;
|
@@ -1245,142 +1423,9 @@ var None = class extends Option {
|
|
1245
1423
|
throw new Error("None.unwrap");
|
1246
1424
|
}
|
1247
1425
|
};
|
1248
|
-
|
1249
|
-
// src/future.ts
|
1250
|
-
var _promise, _resolveFn, _rejectFn;
|
1251
|
-
var Future = class {
|
1252
|
-
constructor() {
|
1253
|
-
__privateAdd(this, _promise);
|
1254
|
-
__privateAdd(this, _resolveFn, () => {
|
1255
|
-
throw new Error("This Promise is not working as expected.");
|
1256
|
-
});
|
1257
|
-
__privateAdd(this, _rejectFn, () => {
|
1258
|
-
throw new Error("This Promise is not working as expected.");
|
1259
|
-
});
|
1260
|
-
__privateSet(this, _promise, new Promise((resolve, reject) => {
|
1261
|
-
__privateSet(this, _resolveFn, resolve);
|
1262
|
-
__privateSet(this, _rejectFn, reject);
|
1263
|
-
}));
|
1264
|
-
}
|
1265
|
-
async asPromise() {
|
1266
|
-
return __privateGet(this, _promise);
|
1267
|
-
}
|
1268
|
-
resolve(value) {
|
1269
|
-
__privateGet(this, _resolveFn).call(this, value);
|
1270
|
-
}
|
1271
|
-
reject(reason) {
|
1272
|
-
__privateGet(this, _rejectFn).call(this, reason);
|
1273
|
-
}
|
1274
|
-
};
|
1275
|
-
_promise = new WeakMap();
|
1276
|
-
_resolveFn = new WeakMap();
|
1277
|
-
_rejectFn = new WeakMap();
|
1278
|
-
|
1279
|
-
// src/resolve-once.ts
|
1280
|
-
var ResolveSeq = class {
|
1281
|
-
constructor(ctx) {
|
1282
|
-
this._seqFutures = [];
|
1283
|
-
this.ctx = ctx;
|
1284
|
-
}
|
1285
|
-
reset() {
|
1286
|
-
}
|
1287
|
-
async _step(item) {
|
1288
|
-
if (!item) {
|
1289
|
-
return;
|
1290
|
-
}
|
1291
|
-
item.fn(this.ctx).then((value) => item.future.resolve(value)).catch((e) => item.future.reject(e)).finally(() => this._step(this._seqFutures.shift()));
|
1292
|
-
}
|
1293
|
-
async add(fn) {
|
1294
|
-
const future = new Future();
|
1295
|
-
this._seqFutures.push({ future, fn });
|
1296
|
-
this._step(this._seqFutures.shift());
|
1297
|
-
return future.asPromise();
|
1298
|
-
}
|
1299
|
-
};
|
1300
|
-
var ResolveOnce = class {
|
1301
|
-
constructor(ctx) {
|
1302
|
-
this._onceDone = false;
|
1303
|
-
this._onceFutures = [];
|
1304
|
-
this._onceOk = false;
|
1305
|
-
this.ctx = ctx;
|
1306
|
-
}
|
1307
|
-
get ready() {
|
1308
|
-
return this._onceDone;
|
1309
|
-
}
|
1310
|
-
reset() {
|
1311
|
-
this._onceDone = false;
|
1312
|
-
this._onceOk = false;
|
1313
|
-
this._onceValue = void 0;
|
1314
|
-
this._onceError = void 0;
|
1315
|
-
this._onceFutures.length = 0;
|
1316
|
-
}
|
1317
|
-
async once(fn) {
|
1318
|
-
if (this._onceDone) {
|
1319
|
-
if (this._onceError) {
|
1320
|
-
return Promise.reject(this._onceError);
|
1321
|
-
}
|
1322
|
-
if (this._onceOk) {
|
1323
|
-
return Promise.resolve(this._onceValue);
|
1324
|
-
}
|
1325
|
-
throw new Error("ResolveOnce.once impossible");
|
1326
|
-
}
|
1327
|
-
const future = new Future();
|
1328
|
-
this._onceFutures.push(future);
|
1329
|
-
if (this._onceFutures.length === 1) {
|
1330
|
-
fn(this.ctx).then((value) => {
|
1331
|
-
this._onceValue = value;
|
1332
|
-
this._onceOk = true;
|
1333
|
-
this._onceDone = true;
|
1334
|
-
this._onceFutures.forEach((f) => f.resolve(this._onceValue));
|
1335
|
-
this._onceFutures.length = 0;
|
1336
|
-
}).catch((e) => {
|
1337
|
-
this._onceError = e;
|
1338
|
-
this._onceOk = false;
|
1339
|
-
this._onceValue = void 0;
|
1340
|
-
this._onceDone = true;
|
1341
|
-
this._onceFutures.forEach((f) => f.reject(this._onceError));
|
1342
|
-
this._onceFutures.length = 0;
|
1343
|
-
});
|
1344
|
-
}
|
1345
|
-
return future.asPromise();
|
1346
|
-
}
|
1347
|
-
};
|
1348
|
-
var Keyed = class {
|
1349
|
-
constructor(factory) {
|
1350
|
-
this._map = /* @__PURE__ */ new Map();
|
1351
|
-
this.factory = factory;
|
1352
|
-
}
|
1353
|
-
async asyncGet(key) {
|
1354
|
-
return this.get(await key());
|
1355
|
-
}
|
1356
|
-
get(key) {
|
1357
|
-
if (typeof key === "function") {
|
1358
|
-
key = key();
|
1359
|
-
}
|
1360
|
-
let keyed = this._map.get(key);
|
1361
|
-
if (!keyed) {
|
1362
|
-
keyed = this.factory(key);
|
1363
|
-
this._map.set(key, keyed);
|
1364
|
-
}
|
1365
|
-
return keyed;
|
1366
|
-
}
|
1367
|
-
reset() {
|
1368
|
-
this._map.forEach((keyed) => keyed.reset());
|
1369
|
-
this._map.clear();
|
1370
|
-
}
|
1371
|
-
};
|
1372
|
-
var KeyedResolvOnce = class extends Keyed {
|
1373
|
-
constructor() {
|
1374
|
-
super((key) => new ResolveOnce(key));
|
1375
|
-
}
|
1376
|
-
};
|
1377
|
-
var KeyedResolvSeq = class extends Keyed {
|
1378
|
-
constructor() {
|
1379
|
-
super((key) => new ResolveSeq(key));
|
1380
|
-
}
|
1381
|
-
};
|
1382
1426
|
// Annotate the CommonJS export names for ESM import in node:
|
1383
1427
|
0 && (module.exports = {
|
1428
|
+
BrowserEnvActions,
|
1384
1429
|
EnvImpl,
|
1385
1430
|
Future,
|
1386
1431
|
IDMode,
|
@@ -1391,6 +1436,7 @@ var KeyedResolvSeq = class extends Keyed {
|
|
1391
1436
|
Level,
|
1392
1437
|
LevelHandlerImpl,
|
1393
1438
|
LogCollector,
|
1439
|
+
LogValue,
|
1394
1440
|
LogWriter,
|
1395
1441
|
LoggerImpl,
|
1396
1442
|
MockLogger,
|
@@ -1407,6 +1453,8 @@ var KeyedResolvSeq = class extends Keyed {
|
|
1407
1453
|
Time,
|
1408
1454
|
TimeMode,
|
1409
1455
|
TimeUnits,
|
1410
|
-
|
1456
|
+
envFactory,
|
1457
|
+
logValue,
|
1458
|
+
removeSelfRef
|
1411
1459
|
});
|
1412
1460
|
//# sourceMappingURL=index.cjs.map
|