@adviser/cement 0.2.2 → 0.2.4
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 +337 -282
- package/index.cjs.map +1 -1
- package/index.d.cts +22 -18
- package/index.d.ts +22 -18
- package/index.js +64 -177
- 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 : {};
|
573
|
+
}
|
574
|
+
register(env) {
|
575
|
+
return env;
|
366
576
|
}
|
367
|
-
|
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
|
-
|
476
|
-
}
|
477
|
-
del(key) {
|
478
|
-
__privateGet(this, _envImpl).del(key);
|
479
|
-
__privateMethod(this, _EnvImpl_instances, applyOnSet_fn).call(this, __privateGet(this, _onSet), key);
|
480
|
-
}
|
481
|
-
};
|
482
|
-
_envImpl = new WeakMap();
|
483
|
-
_EnvImpl_instances = new WeakSet();
|
484
|
-
updatePresets_fn = function(presetEnv) {
|
485
|
-
if (!presetEnv) {
|
486
|
-
return;
|
727
|
+
this._map.set(key, value);
|
728
|
+
this._applyOnSet(this._onSet, key, value);
|
487
729
|
}
|
488
|
-
|
489
|
-
|
730
|
+
delete(key) {
|
731
|
+
this._map.delete(key);
|
732
|
+
this._applyOnSet(this._onSet, key);
|
490
733
|
}
|
491
734
|
};
|
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 */]);
|
@@ -928,7 +1103,7 @@ var LoggerImpl = class _LoggerImpl {
|
|
928
1103
|
_attributes: attr
|
929
1104
|
});
|
930
1105
|
}
|
931
|
-
return JSON.stringify(
|
1106
|
+
return JSON.stringify(attr, removeSelfRef());
|
932
1107
|
}
|
933
1108
|
Msg(...args) {
|
934
1109
|
const fnError = this._resetAttributes(() => {
|
@@ -936,7 +1111,7 @@ var LoggerImpl = class _LoggerImpl {
|
|
936
1111
|
const doWrite = this._levelHandler.isEnabled((_a = this._attributes["level"]) == null ? void 0 : _a.value(), (_b = this._attributes["module"]) == null ? void 0 : _b.value());
|
937
1112
|
let fnRet = () => this._produceError(__spreadValues({}, this._attributes), ...args);
|
938
1113
|
if (doWrite) {
|
939
|
-
const str =
|
1114
|
+
const str = fnRet();
|
940
1115
|
const encoded = encoder.encode(str + "\n");
|
941
1116
|
this._logWriter.write(encoded);
|
942
1117
|
fnRet = () => str;
|
@@ -1149,7 +1324,17 @@ var Result = class _Result {
|
|
1149
1324
|
return new ResultError(t);
|
1150
1325
|
}
|
1151
1326
|
static Is(t) {
|
1152
|
-
|
1327
|
+
if (!t) {
|
1328
|
+
return false;
|
1329
|
+
}
|
1330
|
+
if (t instanceof _Result) {
|
1331
|
+
return true;
|
1332
|
+
}
|
1333
|
+
const rt = t;
|
1334
|
+
if ([typeof rt.is_ok, typeof rt.is_err, typeof rt.unwrap, typeof rt.unwrap_err].every((x) => x === "function")) {
|
1335
|
+
return true;
|
1336
|
+
}
|
1337
|
+
return false;
|
1153
1338
|
}
|
1154
1339
|
isOk() {
|
1155
1340
|
return this.is_ok();
|
@@ -1248,142 +1433,9 @@ var None = class extends Option {
|
|
1248
1433
|
throw new Error("None.unwrap");
|
1249
1434
|
}
|
1250
1435
|
};
|
1251
|
-
|
1252
|
-
// src/future.ts
|
1253
|
-
var _promise, _resolveFn, _rejectFn;
|
1254
|
-
var Future = class {
|
1255
|
-
constructor() {
|
1256
|
-
__privateAdd(this, _promise);
|
1257
|
-
__privateAdd(this, _resolveFn, () => {
|
1258
|
-
throw new Error("This Promise is not working as expected.");
|
1259
|
-
});
|
1260
|
-
__privateAdd(this, _rejectFn, () => {
|
1261
|
-
throw new Error("This Promise is not working as expected.");
|
1262
|
-
});
|
1263
|
-
__privateSet(this, _promise, new Promise((resolve, reject) => {
|
1264
|
-
__privateSet(this, _resolveFn, resolve);
|
1265
|
-
__privateSet(this, _rejectFn, reject);
|
1266
|
-
}));
|
1267
|
-
}
|
1268
|
-
async asPromise() {
|
1269
|
-
return __privateGet(this, _promise);
|
1270
|
-
}
|
1271
|
-
resolve(value) {
|
1272
|
-
__privateGet(this, _resolveFn).call(this, value);
|
1273
|
-
}
|
1274
|
-
reject(reason) {
|
1275
|
-
__privateGet(this, _rejectFn).call(this, reason);
|
1276
|
-
}
|
1277
|
-
};
|
1278
|
-
_promise = new WeakMap();
|
1279
|
-
_resolveFn = new WeakMap();
|
1280
|
-
_rejectFn = new WeakMap();
|
1281
|
-
|
1282
|
-
// src/resolve-once.ts
|
1283
|
-
var ResolveSeq = class {
|
1284
|
-
constructor(ctx) {
|
1285
|
-
this._seqFutures = [];
|
1286
|
-
this.ctx = ctx;
|
1287
|
-
}
|
1288
|
-
reset() {
|
1289
|
-
}
|
1290
|
-
async _step(item) {
|
1291
|
-
if (!item) {
|
1292
|
-
return;
|
1293
|
-
}
|
1294
|
-
item.fn(this.ctx).then((value) => item.future.resolve(value)).catch((e) => item.future.reject(e)).finally(() => this._step(this._seqFutures.shift()));
|
1295
|
-
}
|
1296
|
-
async add(fn) {
|
1297
|
-
const future = new Future();
|
1298
|
-
this._seqFutures.push({ future, fn });
|
1299
|
-
this._step(this._seqFutures.shift());
|
1300
|
-
return future.asPromise();
|
1301
|
-
}
|
1302
|
-
};
|
1303
|
-
var ResolveOnce = class {
|
1304
|
-
constructor(ctx) {
|
1305
|
-
this._onceDone = false;
|
1306
|
-
this._onceFutures = [];
|
1307
|
-
this._onceOk = false;
|
1308
|
-
this.ctx = ctx;
|
1309
|
-
}
|
1310
|
-
get ready() {
|
1311
|
-
return this._onceDone;
|
1312
|
-
}
|
1313
|
-
reset() {
|
1314
|
-
this._onceDone = false;
|
1315
|
-
this._onceOk = false;
|
1316
|
-
this._onceValue = void 0;
|
1317
|
-
this._onceError = void 0;
|
1318
|
-
this._onceFutures.length = 0;
|
1319
|
-
}
|
1320
|
-
async once(fn) {
|
1321
|
-
if (this._onceDone) {
|
1322
|
-
if (this._onceError) {
|
1323
|
-
return Promise.reject(this._onceError);
|
1324
|
-
}
|
1325
|
-
if (this._onceOk) {
|
1326
|
-
return Promise.resolve(this._onceValue);
|
1327
|
-
}
|
1328
|
-
throw new Error("ResolveOnce.once impossible");
|
1329
|
-
}
|
1330
|
-
const future = new Future();
|
1331
|
-
this._onceFutures.push(future);
|
1332
|
-
if (this._onceFutures.length === 1) {
|
1333
|
-
fn(this.ctx).then((value) => {
|
1334
|
-
this._onceValue = value;
|
1335
|
-
this._onceOk = true;
|
1336
|
-
this._onceDone = true;
|
1337
|
-
this._onceFutures.forEach((f) => f.resolve(this._onceValue));
|
1338
|
-
this._onceFutures.length = 0;
|
1339
|
-
}).catch((e) => {
|
1340
|
-
this._onceError = e;
|
1341
|
-
this._onceOk = false;
|
1342
|
-
this._onceValue = void 0;
|
1343
|
-
this._onceDone = true;
|
1344
|
-
this._onceFutures.forEach((f) => f.reject(this._onceError));
|
1345
|
-
this._onceFutures.length = 0;
|
1346
|
-
});
|
1347
|
-
}
|
1348
|
-
return future.asPromise();
|
1349
|
-
}
|
1350
|
-
};
|
1351
|
-
var Keyed = class {
|
1352
|
-
constructor(factory) {
|
1353
|
-
this._map = /* @__PURE__ */ new Map();
|
1354
|
-
this.factory = factory;
|
1355
|
-
}
|
1356
|
-
async asyncGet(key) {
|
1357
|
-
return this.get(await key());
|
1358
|
-
}
|
1359
|
-
get(key) {
|
1360
|
-
if (typeof key === "function") {
|
1361
|
-
key = key();
|
1362
|
-
}
|
1363
|
-
let keyed = this._map.get(key);
|
1364
|
-
if (!keyed) {
|
1365
|
-
keyed = this.factory(key);
|
1366
|
-
this._map.set(key, keyed);
|
1367
|
-
}
|
1368
|
-
return keyed;
|
1369
|
-
}
|
1370
|
-
reset() {
|
1371
|
-
this._map.forEach((keyed) => keyed.reset());
|
1372
|
-
this._map.clear();
|
1373
|
-
}
|
1374
|
-
};
|
1375
|
-
var KeyedResolvOnce = class extends Keyed {
|
1376
|
-
constructor() {
|
1377
|
-
super((key) => new ResolveOnce(key));
|
1378
|
-
}
|
1379
|
-
};
|
1380
|
-
var KeyedResolvSeq = class extends Keyed {
|
1381
|
-
constructor() {
|
1382
|
-
super((key) => new ResolveSeq(key));
|
1383
|
-
}
|
1384
|
-
};
|
1385
1436
|
// Annotate the CommonJS export names for ESM import in node:
|
1386
1437
|
0 && (module.exports = {
|
1438
|
+
BrowserEnvActions,
|
1387
1439
|
EnvImpl,
|
1388
1440
|
Future,
|
1389
1441
|
IDMode,
|
@@ -1394,6 +1446,7 @@ var KeyedResolvSeq = class extends Keyed {
|
|
1394
1446
|
Level,
|
1395
1447
|
LevelHandlerImpl,
|
1396
1448
|
LogCollector,
|
1449
|
+
LogValue,
|
1397
1450
|
LogWriter,
|
1398
1451
|
LoggerImpl,
|
1399
1452
|
MockLogger,
|
@@ -1410,6 +1463,8 @@ var KeyedResolvSeq = class extends Keyed {
|
|
1410
1463
|
Time,
|
1411
1464
|
TimeMode,
|
1412
1465
|
TimeUnits,
|
1413
|
-
|
1466
|
+
envFactory,
|
1467
|
+
logValue,
|
1468
|
+
removeSelfRef
|
1414
1469
|
});
|
1415
1470
|
//# sourceMappingURL=index.cjs.map
|