@adviser/cement 0.2.17 → 0.2.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. package/{sys_abstraction-CmSCeK7b.d.cts → base-sys-abstraction-BzVP_lX0.d.cts} +77 -1
  2. package/{sys_abstraction-CmSCeK7b.d.ts → base-sys-abstraction-BzVP_lX0.d.ts} +77 -1
  3. package/chunk-AO7BGISE.js +353 -0
  4. package/chunk-AO7BGISE.js.map +1 -0
  5. package/{chunk-J2IM7FHM.js → chunk-I4NUGWZ6.js} +6 -1
  6. package/{chunk-XJF7FQUN.js → chunk-LJRKN3XI.js} +3 -3
  7. package/{chunk-XJF7FQUN.js.map → chunk-LJRKN3XI.js.map} +1 -1
  8. package/{chunk-O4F5AURC.js → chunk-P4FB5FHU.js} +185 -179
  9. package/chunk-P4FB5FHU.js.map +1 -0
  10. package/index-_GuS2IT4.d.cts +93 -0
  11. package/index-_GuS2IT4.d.ts +93 -0
  12. package/index.cjs +362 -102
  13. package/index.cjs.map +1 -1
  14. package/index.d.cts +8 -18
  15. package/index.d.ts +8 -18
  16. package/index.js +33 -98
  17. package/index.js.map +1 -1
  18. package/node/index.cjs +5 -5
  19. package/node/index.cjs.map +1 -1
  20. package/node/index.d.cts +1 -2
  21. package/node/index.d.ts +1 -2
  22. package/node/index.js +5 -5
  23. package/node/index.js.map +1 -1
  24. package/package.json +1 -1
  25. package/utils/index.cjs +98 -2
  26. package/utils/index.cjs.map +1 -1
  27. package/utils/index.d.cts +2 -36
  28. package/utils/index.d.ts +2 -36
  29. package/utils/index.js +21 -221
  30. package/utils/index.js.map +1 -1
  31. package/web/index.cjs +3 -3
  32. package/web/index.cjs.map +1 -1
  33. package/web/index.d.cts +1 -2
  34. package/web/index.d.ts +1 -2
  35. package/web/index.js +3 -3
  36. package/base_sys_abstraction-CJqRmTui.d.ts +0 -21
  37. package/base_sys_abstraction-nsNTl07w.d.cts +0 -21
  38. package/chunk-O4F5AURC.js.map +0 -1
  39. /package/{chunk-J2IM7FHM.js.map → chunk-I4NUGWZ6.js.map} +0 -0
package/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { S as SysAbstraction } from './sys_abstraction-CmSCeK7b.js';
2
- export { B as BrowserEnvActions, D as Duration, e as Env, c as EnvActions, d as EnvFactoryOpts, g as EnvImpl, E as EnvMap, F as FileService, I as IDMode, N as NamedWritableStream, O as OnSetItem, R as RandomMode, a as String2TimeMode, b as SystemService, h as Time, T as TimeMode, i as TimeUnits, V as VoidFunc, f as envFactory } from './sys_abstraction-CmSCeK7b.js';
3
- import { WritableStreamDefaultWriter as WritableStreamDefaultWriter$1 } from 'stream/web';
1
+ import { S as SysAbstraction } from './base-sys-abstraction-BzVP_lX0.js';
2
+ export { r as BaseSysAbstraction, o as BaseSysAbstractionParams, B as BrowserEnvActions, C as ConstTime, D as Duration, e as Env, c as EnvActions, d as EnvFactoryOpts, g as EnvImpl, E as EnvMap, p as ExitHandler, q as ExitService, F as FileService, I as IDMode, n as IdService, N as NamedWritableStream, O as OnSetItem, R as RandomMode, m as RandomService, k as StepTime, a as String2TimeMode, j as SysTime, b as SystemService, h as Time, l as TimeFactory, T as TimeMode, i as TimeUnits, V as VoidFunc, s as WrapperSysAbstraction, W as WrapperSysAbstractionParams, f as envFactory } from './base-sys-abstraction-BzVP_lX0.js';
3
+ export { i as utils } from './index-_GuS2IT4.js';
4
+ import 'vitest';
4
5
 
5
6
  declare abstract class Result<T, E = Error> {
6
7
  static Ok<T>(t: T): Result<T, Error>;
@@ -229,7 +230,7 @@ declare class Future<T> {
229
230
  reject(reason: unknown): void;
230
231
  }
231
232
 
232
- declare class LogWriterCollector implements WritableStreamDefaultWriter$1<Uint8Array> {
233
+ declare class LogWriteStream implements WritableStreamDefaultWriter<Uint8Array> {
233
234
  private readonly _bufferArr;
234
235
  constructor(bufferArr: Uint8Array[]);
235
236
  readonly _resolveClosed: Future<undefined>;
@@ -241,26 +242,15 @@ declare class LogWriterCollector implements WritableStreamDefaultWriter$1<Uint8A
241
242
  releaseLock(): void;
242
243
  write(chunk?: Uint8Array): Promise<void>;
243
244
  }
244
- declare class FanoutWriter implements WritableStreamDefaultWriter$1<Uint8Array> {
245
- readonly _writers: WritableStreamDefaultWriter$1<Uint8Array>[];
246
- readonly ready: Promise<undefined>;
247
- readonly closed: Promise<undefined>;
248
- readonly desiredSize: number | null;
249
- constructor(writers: WritableStreamDefaultWriter$1<Uint8Array>[]);
250
- abort(reason?: any): Promise<void>;
251
- close(): Promise<void>;
252
- releaseLock(): void;
253
- write(chunk?: Uint8Array | undefined): Promise<void>;
254
- }
255
245
  declare class LogCollector implements WritableStream<Uint8Array> {
256
246
  readonly locked: boolean;
257
247
  private _writer?;
258
248
  private readonly _pass?;
259
249
  private readonly _bufferArr;
260
- constructor(pass?: WritableStreamDefaultWriter$1<Uint8Array>);
250
+ constructor(pass?: WritableStreamDefaultWriter<Uint8Array>);
261
251
  abort(reason?: Uint8Array): Promise<void>;
262
252
  close(): Promise<void>;
263
- getWriter(): WritableStreamDefaultWriter$1<Uint8Array>;
253
+ getWriter(): WritableStreamDefaultWriter<Uint8Array>;
264
254
  Logs(): any[];
265
255
  }
266
256
 
@@ -425,4 +415,4 @@ interface CryptoRuntime {
425
415
  }
426
416
  declare function toCryptoRuntime(cryptoOpts?: Partial<CryptoRuntime>): CryptoRuntime;
427
417
 
428
- export { type AsError, BuildURI, type CTAesKeyAlgorithm, type CTAlgorithm, type CTAlgorithmIdentifier, type CTArrayBufferView, type CTBufferSource, type CTCryptoKey, type CTEcKeyImportParams, type CTHmacImportParams, type CTJsonWebKey, type CTKeyFormat, type CTKeyType, type CTKeyUsage, type CTNamedCurve, type CTRsaHashedImportParams, type CoerceURI, type CryptoRuntime, FanoutWriter, type FnSerialized, Future, IsLogger, Keyed, KeyedResolvOnce, KeyedResolvSeq, type Lengthed, Level, type LevelHandler, LevelHandlerImpl, LogCollector, type LogSerializable, LogValue, LogWriterCollector, LogWriterStream, type Logger, LoggerImpl, type LoggerImplParams, type LoggerInterface, MockLogger, type MockLoggerReturn, None, Option, ResolveOnce, ResolveSeq, Result, ResultError, ResultOK, type Runtime, type Serialized, type SizeOrLength, type Sized, Some, SysAbstraction, URI, type WithLogger, type WithoutOption, type WithoutResult, asyncLogValue, isURL, logValue, removeSelfRef, runtimeFn, toCryptoRuntime };
418
+ export { type AsError, BuildURI, type CTAesKeyAlgorithm, type CTAlgorithm, type CTAlgorithmIdentifier, type CTArrayBufferView, type CTBufferSource, type CTCryptoKey, type CTEcKeyImportParams, type CTHmacImportParams, type CTJsonWebKey, type CTKeyFormat, type CTKeyType, type CTKeyUsage, type CTNamedCurve, type CTRsaHashedImportParams, type CoerceURI, type CryptoRuntime, type FnSerialized, Future, IsLogger, Keyed, KeyedResolvOnce, KeyedResolvSeq, type Lengthed, Level, type LevelHandler, LevelHandlerImpl, LogCollector, type LogSerializable, LogValue, LogWriteStream, LogWriterStream, type Logger, LoggerImpl, type LoggerImplParams, type LoggerInterface, MockLogger, type MockLoggerReturn, None, Option, ResolveOnce, ResolveSeq, Result, ResultError, ResultOK, type Runtime, type Serialized, type SizeOrLength, type Sized, Some, SysAbstraction, URI, type WithLogger, type WithoutOption, type WithoutResult, asyncLogValue, isURL, logValue, removeSelfRef, runtimeFn, toCryptoRuntime };
package/index.js CHANGED
@@ -1,27 +1,40 @@
1
+ import {
2
+ ConsoleWriterStream,
3
+ FanoutWriteStream,
4
+ utils_exports
5
+ } from "./chunk-AO7BGISE.js";
1
6
  import {
2
7
  WebSysAbstraction
3
- } from "./chunk-XJF7FQUN.js";
8
+ } from "./chunk-LJRKN3XI.js";
4
9
  import {
10
+ BaseSysAbstraction,
5
11
  BrowserEnvActions,
12
+ ConstTime,
6
13
  EnvImpl,
7
14
  Future,
8
15
  IDMode,
16
+ IdService,
9
17
  Keyed,
10
18
  KeyedResolvOnce,
11
19
  KeyedResolvSeq,
12
20
  RandomMode,
21
+ RandomService,
13
22
  ResolveOnce,
14
23
  ResolveSeq,
24
+ StepTime,
15
25
  String2TimeMode,
26
+ SysTime,
16
27
  Time,
28
+ TimeFactory,
17
29
  TimeMode,
18
30
  TimeUnits,
31
+ WrapperSysAbstraction,
19
32
  envFactory
20
- } from "./chunk-O4F5AURC.js";
33
+ } from "./chunk-P4FB5FHU.js";
21
34
  import {
22
35
  __spreadValues,
23
36
  __yieldStar
24
- } from "./chunk-J2IM7FHM.js";
37
+ } from "./chunk-I4NUGWZ6.js";
25
38
 
26
39
  // src/logger.ts
27
40
  var Level = /* @__PURE__ */ ((Level2) => {
@@ -322,7 +335,7 @@ function runtimeFn() {
322
335
  };
323
336
  }
324
337
 
325
- // src/logger_impl.ts
338
+ // src/logger-impl.ts
326
339
  var encoder = new TextEncoder();
327
340
  var LevelHandlerImpl = class {
328
341
  constructor() {
@@ -466,68 +479,6 @@ function toLogValue(lop) {
466
479
  }
467
480
  return lop;
468
481
  }
469
- var ConsoleWriterStreamDefaultWriter = class {
470
- constructor(stream) {
471
- this.stream = stream;
472
- this.desiredSize = null;
473
- this.decoder = new TextDecoder();
474
- this._stream = stream;
475
- this.ready = Promise.resolve(void 0);
476
- this.closed = Promise.resolve(void 0);
477
- }
478
- // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
479
- abort(reason) {
480
- throw new Error("Method not implemented.");
481
- }
482
- async close() {
483
- }
484
- releaseLock() {
485
- this._stream.locked = false;
486
- this.ready = Promise.resolve(void 0);
487
- this.closed = Promise.resolve(void 0);
488
- }
489
- async write(chunk) {
490
- const str = this.decoder.decode(chunk).trimEnd();
491
- let output = "log";
492
- try {
493
- const decode = JSON.parse(str);
494
- output = decode.level;
495
- } catch (e) {
496
- }
497
- switch (output) {
498
- case "error":
499
- console.error(str);
500
- break;
501
- case "warn":
502
- console.warn(str);
503
- break;
504
- default:
505
- console.log(str);
506
- }
507
- }
508
- };
509
- var ConsoleWriterStream = class {
510
- constructor() {
511
- this.locked = false;
512
- }
513
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
514
- abort(reason) {
515
- throw new Error("Method not implemented.");
516
- }
517
- async close() {
518
- return;
519
- }
520
- getWriter() {
521
- if (this.locked) {
522
- throw new Error("Stream is locked");
523
- }
524
- this.locked = true;
525
- if (!this._writer) {
526
- this._writer = new ConsoleWriterStreamDefaultWriter(this);
527
- }
528
- return this._writer;
529
- }
530
- };
531
482
  var LoggerImpl = class _LoggerImpl {
532
483
  // readonly _id: string = "logger-" + Math.random().toString(36)
533
484
  constructor(params) {
@@ -853,8 +804,8 @@ var WithLoggerBuilder = class {
853
804
  }
854
805
  };
855
806
 
856
- // src/test/log_collector.ts
857
- var LogWriterCollector = class {
807
+ // src/test/log-write-stream.ts
808
+ var LogWriteStream = class {
858
809
  constructor(bufferArr) {
859
810
  this._resolveClosed = new Future();
860
811
  this.closed = this._resolveClosed.asPromise();
@@ -879,30 +830,6 @@ var LogWriterCollector = class {
879
830
  return Promise.resolve(void 0);
880
831
  }
881
832
  };
882
- var FanoutWriter = class {
883
- constructor(writers) {
884
- this.desiredSize = null;
885
- this._writers = writers;
886
- this.ready = Promise.all(this._writers.map((w) => w.ready)).then(() => void 0);
887
- this.closed = Promise.all(this._writers.map((w) => w.closed)).then(() => void 0);
888
- }
889
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
890
- abort(reason) {
891
- return Promise.all(this._writers.map((w) => w.abort(reason))).then(() => {
892
- });
893
- }
894
- close() {
895
- return Promise.all(this._writers.map((w) => w.close())).then(() => {
896
- });
897
- }
898
- releaseLock() {
899
- this._writers.map((w) => w.releaseLock());
900
- }
901
- write(chunk) {
902
- return Promise.all(this._writers.map((w) => w.write(chunk))).then(() => {
903
- });
904
- }
905
- };
906
833
  var LogCollector = class {
907
834
  constructor(pass) {
908
835
  this.locked = false;
@@ -923,11 +850,11 @@ var LogCollector = class {
923
850
  }
924
851
  getWriter() {
925
852
  if (!this._writer) {
926
- const dests = [new LogWriterCollector(this._bufferArr)];
853
+ const dests = [new LogWriteStream(this._bufferArr)];
927
854
  if (this._pass) {
928
855
  dests.push(this._pass);
929
856
  }
930
- this._writer = new FanoutWriter(dests);
857
+ this._writer = new FanoutWriteStream(dests);
931
858
  }
932
859
  return this._writer;
933
860
  }
@@ -952,7 +879,7 @@ var LogCollector = class {
952
879
  }
953
880
  };
954
881
 
955
- // src/test/mock_logger.ts
882
+ // src/test/mock-logger.ts
956
883
  function MockLogger(params) {
957
884
  const lc = new LogCollector(params == null ? void 0 : params.pass);
958
885
  let modNames = ["MockLogger"];
@@ -1119,12 +1046,14 @@ function toCryptoRuntime(cryptoOpts = {}) {
1119
1046
  return runtime;
1120
1047
  }
1121
1048
  export {
1049
+ BaseSysAbstraction,
1122
1050
  BrowserEnvActions,
1123
1051
  BuildURI,
1052
+ ConstTime,
1124
1053
  EnvImpl,
1125
- FanoutWriter,
1126
1054
  Future,
1127
1055
  IDMode,
1056
+ IdService,
1128
1057
  IsLogger,
1129
1058
  Keyed,
1130
1059
  KeyedResolvOnce,
@@ -1133,30 +1062,36 @@ export {
1133
1062
  LevelHandlerImpl,
1134
1063
  LogCollector,
1135
1064
  LogValue,
1136
- LogWriterCollector,
1065
+ LogWriteStream,
1137
1066
  LogWriterStream,
1138
1067
  LoggerImpl,
1139
1068
  MockLogger,
1140
1069
  None,
1141
1070
  Option,
1142
1071
  RandomMode,
1072
+ RandomService,
1143
1073
  ResolveOnce,
1144
1074
  ResolveSeq,
1145
1075
  Result,
1146
1076
  ResultError,
1147
1077
  ResultOK,
1148
1078
  Some,
1079
+ StepTime,
1149
1080
  String2TimeMode,
1081
+ SysTime,
1150
1082
  Time,
1083
+ TimeFactory,
1151
1084
  TimeMode,
1152
1085
  TimeUnits,
1153
1086
  URI,
1087
+ WrapperSysAbstraction,
1154
1088
  asyncLogValue,
1155
1089
  envFactory,
1156
1090
  isURL,
1157
1091
  logValue,
1158
1092
  removeSelfRef,
1159
1093
  runtimeFn,
1160
- toCryptoRuntime
1094
+ toCryptoRuntime,
1095
+ utils_exports as utils
1161
1096
  };
1162
1097
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/logger.ts","../../src/uri.ts","../../src/runtime.ts","../../src/logger_impl.ts","../../src/test/log_collector.ts","../../src/test/mock_logger.ts","../../src/result.ts","../../src/option.ts","../../src/crypto.ts"],"sourcesContent":["import { Result } from \"./result\";\nimport { CoerceURI } from \"./uri\";\n\nexport enum Level {\n WARN = \"warn\",\n DEBUG = \"debug\",\n INFO = \"info\",\n ERROR = \"error\",\n}\n\nexport type Serialized = string | number | boolean;\nexport type FnSerialized = () => Serialized | Serialized[];\n\nexport class LogValue {\n constructor(readonly fn: FnSerialized) {}\n value(): Serialized | Serialized[] {\n return this.fn();\n }\n toJSON(): Serialized | Serialized[] {\n return this.value();\n }\n}\n\nexport type LogSerializable = Record<string, LogValue | Promise<LogValue>>;\n\nexport function removeSelfRef(): (key: unknown, val: unknown) => unknown {\n const cache = new Set();\n return function (key: unknown, value: unknown) {\n if (typeof value === \"object\" && value !== null) {\n // Duplicate reference found, discard key\n if (cache.has(value)) return \"...\";\n cache.add(value);\n }\n return value;\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function asyncLogValue(val: () => Promise<Serialized>): Promise<LogValue> {\n // return Promise.resolve(logValue(val));\n throw new Error(\"Not implemented\");\n}\n\nexport function logValue(val: Serialized | Serialized[] | FnSerialized | LogSerializable | undefined | null): LogValue {\n switch (typeof val) {\n case \"function\":\n return new LogValue(val);\n case \"string\":\n return new LogValue(() => {\n try {\n const ret = JSON.parse(val);\n if (typeof ret === \"object\" && ret !== null) {\n return ret;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (e) {\n // do nothing\n }\n return val.toString();\n });\n case \"number\":\n return new LogValue(() => val);\n case \"boolean\":\n return new LogValue(() => val);\n case \"object\":\n return new LogValue(() => JSON.parse(JSON.stringify(val, removeSelfRef())));\n default:\n if (!val) {\n return new LogValue(() => \"--Falsy--\");\n }\n throw new Error(`Invalid type:${typeof val}`);\n }\n}\n\nexport interface Sized {\n size: number;\n}\nexport interface Lengthed {\n length: number;\n}\nexport type SizeOrLength = Sized | Lengthed;\n\nexport interface LoggerInterface<R> {\n Module(key: string): R;\n // if modules is empty, set for all Levels\n EnableLevel(level: Level, ...modules: string[]): R;\n DisableLevel(level: Level, ...modules: string[]): R;\n\n SetDebug(...modules: (string | string[])[]): R;\n SetExposeStack(enable?: boolean): R;\n\n Ref(key: string, action: { toString: () => string } | FnSerialized): R;\n Result<T>(key: string, res: Result<T>): R;\n // default key url\n Url(url: CoerceURI, key?: string): R;\n // len\n Len(value: unknown, key?: string): R;\n\n Hash(value: unknown, key?: string): R;\n\n Str(key: string, value?: string): R;\n Error(): R;\n Warn(): R;\n Debug(): R;\n Log(): R;\n WithLevel(level: Level): R;\n\n Err(err: unknown): R; // could be Error, or something which coerces to string\n Info(): R;\n Timestamp(): R;\n Any(key: string, value: unknown): R;\n Dur(key: string, nsec: number): R;\n Uint64(key: string, value: number): R;\n Int(key: string, value: number): R;\n Bool(key: string, value: unknown): R;\n}\n\nexport function IsLogger(obj: unknown): obj is Logger {\n return (\n typeof obj === \"object\" &&\n [\n \"Module\",\n \"EnableLevel\",\n \"DisableLevel\",\n \"SetDebug\",\n \"Str\",\n \"Error\",\n \"Warn\",\n \"Debug\",\n \"Log\",\n \"WithLevel\",\n \"Err\",\n \"Info\",\n \"Timestamp\",\n \"Any\",\n \"Dur\",\n \"Uint64\",\n ]\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n .map((fn) => typeof (obj as any)[fn] === \"function\")\n .reduce((a, b) => a && b, true)\n );\n}\n\nexport interface WithLogger extends LoggerInterface<WithLogger> {\n Logger(): Logger;\n}\n\nexport interface AsError {\n AsError(): Error;\n}\n\nexport interface Logger extends LoggerInterface<Logger> {\n With(): WithLogger;\n\n Msg(...args: string[]): AsError;\n Flush(): Promise<void>;\n}\n","type NullOrUndef = null | undefined;\n\nfunction falsy2undef<T>(value: T | NullOrUndef): T | undefined {\n return value === undefined || value === null ? undefined : value;\n}\n\nfunction ensureURLWithDefaultProto(url: string | URL, defaultProtocol: string): URL {\n if (!url) {\n return new URL(`${defaultProtocol}//`);\n }\n if (typeof url === \"string\") {\n try {\n return new URL(url);\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (e) {\n return new URL(`${defaultProtocol}//${url}`);\n }\n } else {\n return url;\n }\n}\n\nexport function isURL(value: unknown): value is URL {\n return (\n value instanceof URL ||\n (!!value &&\n typeof (value as URL).searchParams === \"object\" &&\n typeof (value as URL).searchParams.sort === \"function\" &&\n typeof (value as URL).hash === \"string\")\n );\n}\n\nfunction from<T>(fac: (url: URL) => T, strURLUri: CoerceURI | undefined, defaultProtocol: string): T {\n switch (typeof falsy2undef(strURLUri)) {\n case \"undefined\":\n return fac(new URL(`${defaultProtocol}//`));\n case \"string\":\n return fac(ensureURLWithDefaultProto(strURLUri as string, defaultProtocol));\n case \"object\":\n if (BuildURI.is(strURLUri)) {\n return fac(new URL(strURLUri._url.toString()));\n } else if (URI.is(strURLUri)) {\n return fac(new URL(strURLUri._url.toString()));\n } else if (isURL(strURLUri)) {\n return fac(new URL(strURLUri.toString()));\n }\n throw new Error(`unknown object type: ${strURLUri}`);\n default:\n throw new Error(`Invalid argument: ${typeof strURLUri}`);\n }\n}\n\nexport class BuildURI {\n _url: URL; // pathname needs this\n private constructor(url: URL) {\n this._url = url;\n }\n\n static is(value: unknown): value is BuildURI {\n return (\n value instanceof BuildURI ||\n (!!value && typeof (value as BuildURI).delParam === \"function\" && typeof (value as BuildURI).setParam === \"function\")\n );\n }\n static from(strURLUri?: CoerceURI, defaultProtocol = \"file:\"): BuildURI {\n return from((url) => new BuildURI(url), strURLUri, defaultProtocol);\n }\n\n hostname(h: string) {\n this._url.hostname = h;\n return this;\n }\n\n password(p: string) {\n this._url.password = p;\n return this;\n }\n\n port(p: string) {\n this._url.port = p;\n return this;\n }\n\n username(u: string) {\n this._url.username = u;\n return this;\n }\n\n search(s: string) {\n this._url.search = s;\n return this;\n }\n\n protocol(p: string) {\n if (!p.endsWith(\":\")) {\n p = `${p}:`;\n }\n const mySrc = this._url.toString();\n const myDst = mySrc.replace(new RegExp(`^${this._url.protocol}`), `${p}`);\n this._url = new URL(myDst);\n return this;\n }\n\n pathname(p: string) {\n const myp = this.URI().pathname;\n const mySrc = this._url.toString();\n const myDst = mySrc.replace(new RegExp(`^${this._url.protocol}//${myp}`), `${this._url.protocol}//${p}`);\n this._url = new URL(myDst);\n return this;\n }\n\n hash(h: string) {\n this._url.hash = h;\n return this;\n }\n\n host(h: string) {\n this._url.host = h;\n return this;\n }\n\n delParam(key: string) {\n this._url.searchParams.delete(key);\n return this;\n }\n\n defParam(key: string, str: string) {\n if (!this._url.searchParams.has(key)) {\n this._url.searchParams.set(key, str);\n }\n return this;\n }\n\n setParam(key: string, str: string) {\n this._url.searchParams.set(key, str);\n return this;\n }\n\n toString(): string {\n this._url.searchParams.sort();\n return this._url.toString();\n }\n\n URI(): URI {\n return URI.from(this._url);\n }\n}\n\nexport type CoerceURI = string | URL | URI | BuildURI | NullOrUndef;\n\n// non mutable URL Implementation\nexport class URI {\n // if no protocol is provided, default to file:\n static merge(into: CoerceURI, from: CoerceURI, defaultProtocol = \"file:\"): URI {\n const intoUrl = BuildURI.from(into, defaultProtocol);\n const fromUrl = URI.from(from, defaultProtocol);\n intoUrl.protocol(fromUrl.protocol);\n const fPath = fromUrl.pathname;\n if (!(fPath.length === 0 || fPath === \"/\" || fPath === \"./\")) {\n intoUrl.pathname(fromUrl.pathname);\n }\n for (const [key, value] of fromUrl.getParams) {\n intoUrl.setParam(key, value);\n }\n return intoUrl.URI();\n }\n\n static is(value: unknown): value is URI {\n return (\n value instanceof URI ||\n (!!value &&\n typeof (value as URI).asURL === \"function\" &&\n typeof (value as URI).getParam === \"function\" &&\n typeof (value as URI).hasParam === \"function\")\n );\n }\n\n // if no protocol is provided, default to file:\n static from(strURLUri?: CoerceURI, defaultProtocol = \"file:\"): URI {\n return from((url) => new URI(url), strURLUri, defaultProtocol);\n }\n\n readonly _url: URL;\n private constructor(url: URL) {\n this._url = url;\n }\n\n build(): BuildURI {\n return BuildURI.from(this.asURL());\n }\n\n get hostname(): string {\n return this._url.hostname;\n }\n\n get password(): string {\n return this._url.password;\n }\n\n get port(): string {\n return this._url.port;\n }\n\n get username(): string {\n return this._url.username;\n }\n\n get search(): string {\n return this._url.search;\n }\n\n get protocol(): string {\n return this._url.protocol;\n }\n\n get pathname(): string {\n return this._url\n .toString()\n .replace(/^.*:\\/\\//, \"\")\n .replace(/\\?.*$/, \"\");\n }\n\n get hash(): string {\n return this._url.hash;\n }\n\n get host(): string {\n return this._url.host;\n }\n\n get getParams(): Iterable<[string, string]> {\n return this._url.searchParams.entries();\n }\n\n hasParam(key: string): boolean {\n return this._url.searchParams.has(key);\n }\n getParam(key: string): string | undefined {\n return falsy2undef(this._url.searchParams.get(key));\n }\n\n clone(): URI {\n return new URI(this.asURL());\n }\n\n asURL(): URL {\n const url = new URL(this._url.toString());\n url.searchParams.sort();\n return url;\n }\n\n toString(): string {\n this._url.searchParams.sort();\n return this._url.toString();\n }\n}\n","export interface Runtime {\n isNodeIsh: boolean;\n isBrowser: boolean;\n isDeno: boolean;\n isReactNative: boolean;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction isSet(value: string, ref: any = globalThis): boolean {\n const [head, ...tail] = value.split(\".\");\n if ([\"object\", \"function\"].includes(typeof ref) && ref && [\"object\", \"function\"].includes(typeof ref[head]) && ref[head]) {\n if (tail.length <= 1) {\n return true;\n }\n return isSet(tail.join(\".\"), ref[head]);\n }\n return false;\n}\n\nexport function runtimeFn(): Runtime {\n const isReactNative = isSet(\"navigator.product\") && globalThis.navigator.product === \"ReactNative\";\n const isNodeIsh = isSet(\"process.versions.node\") && !isReactNative;\n const isDeno = isSet(\"Deno\") && !isReactNative;\n return {\n isNodeIsh,\n isBrowser: !(isNodeIsh || isDeno) && !isReactNative,\n isDeno,\n isReactNative,\n };\n}\n","// import { v4 } from \"uuid\";\nimport {\n AsError,\n FnSerialized,\n LogSerializable,\n Level,\n Logger,\n logValue,\n Serialized,\n WithLogger,\n removeSelfRef,\n Sized,\n Lengthed,\n LogValue,\n asyncLogValue,\n} from \"./logger\";\nimport { WebSysAbstraction } from \"./web/web_sys_abstraction\";\nimport { SysAbstraction } from \"./sys_abstraction\";\nimport { Result } from \"./result\";\nimport { CoerceURI, URI } from \"./uri\";\nimport { runtimeFn } from \"./runtime\";\n\nconst encoder = new TextEncoder();\n\n// function resolveLogValue(val: LogSerializable): Record<string, Serialized> {\n// const ret: Record<string, Serialized> = {};\n// Object.keys(val).forEach((key) => {\n// const v = val[key];\n// if (v instanceof LogValue) {\n// ret[key] = v.value();\n// }\n// });\n// return ret;\n// }\n\nexport interface LevelHandler {\n enableLevel(level: Level, ...modules: string[]): void;\n disableLevel(level: Level, ...modules: string[]): void;\n setExposeStack(enable?: boolean): void;\n isStackExposed: boolean;\n setDebug(...modules: (string | string[])[]): void;\n isEnabled(ilevel: unknown, module: unknown): boolean;\n}\n\nexport class LevelHandlerImpl implements LevelHandler {\n readonly _globalLevels = new Set<Level>([Level.INFO, Level.ERROR, Level.WARN]);\n readonly _modules = new Map<string, Set<Level>>();\n isStackExposed = false;\n enableLevel(level: Level, ...modules: string[]): void {\n if (modules.length == 0) {\n this._globalLevels.add(level);\n return;\n }\n this.forModules(\n level,\n (p) => {\n this._modules.set(p, new Set([...this._globalLevels, level]));\n },\n ...modules,\n );\n }\n disableLevel(level: Level, ...modules: string[]): void {\n if (modules.length == 0) {\n this._globalLevels.delete(level);\n return;\n }\n this.forModules(\n level,\n (p) => {\n this._modules.delete(p);\n },\n ...modules,\n );\n }\n\n setExposeStack(enable?: boolean): void {\n this.isStackExposed = !!enable;\n }\n\n forModules(level: Level, fnAction: (p: string) => void, ...modules: (string | string[])[]): void {\n for (const m of modules.flat()) {\n if (typeof m !== \"string\") {\n continue;\n }\n const parts = m\n .split(\",\")\n .map((s) => s.trim())\n .filter((s) => s.length);\n for (const p of parts) {\n fnAction(p);\n }\n }\n }\n setDebug(...modules: (string | string[])[]): void {\n this.forModules(\n Level.DEBUG,\n (p) => {\n this._modules.set(p, new Set([...this._globalLevels, Level.DEBUG]));\n },\n ...modules,\n );\n }\n isEnabled(ilevel: unknown, module: unknown): boolean {\n const level = ilevel as Level; // what if it's not a level?\n if (typeof module === \"string\") {\n const levels = this._modules.get(module);\n if (levels && levels.has(level)) {\n return true;\n }\n }\n const wlevel = this._modules.get(\"*\");\n if (wlevel && typeof level === \"string\") {\n if (wlevel.has(level)) {\n return true;\n }\n }\n if (typeof level !== \"string\") {\n // this is a plain log\n return true;\n }\n return this._globalLevels.has(level);\n }\n}\n\nconst levelSingleton = new LevelHandlerImpl();\n\n// globalThis[Symbol(\"levelSingleton\")] = new LevelHandlerImpl()\n\nexport class LogWriterStream {\n readonly _out: WritableStream<Uint8Array>;\n readonly _toFlush: (() => Promise<void>)[] = [];\n\n constructor(out: WritableStream<Uint8Array>) {\n this._out = out;\n }\n\n write(encoded: Uint8Array) {\n const my = async () => {\n // const val = Math.random();\n // console.log(\">>>My:\", val)\n try {\n const writer = this._out.getWriter();\n await writer.ready;\n await writer.write(encoded);\n await writer.releaseLock();\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error(\"Chunk error:\", err);\n }\n // console.log(\"<<<My:\", val)\n };\n this._toFlush.push(my);\n this._flush();\n }\n\n _flushIsRunning = false;\n _flushDoneFns = Array<() => void>();\n _flush(toFlush: (() => Promise<void>)[] | undefined = undefined, done?: () => void): void {\n if (done) {\n this._flushDoneFns.push(done);\n }\n\n if (this._toFlush.length == 0) {\n // console.log(\"Flush is stopped\", this._toFlush.length)\n this._flushIsRunning = false;\n this._flushDoneFns.forEach((fn) => fn());\n this._flushDoneFns = [];\n return;\n }\n\n if (!toFlush && this._toFlush.length == 1 && !this._flushIsRunning) {\n this._flushIsRunning = true;\n // console.log(\"Flush is started\", this._toFlush.length)\n } else if (!toFlush) {\n // console.log(\"flush queue check but is running\", this._toFlush.length)\n return;\n }\n\n // console.log(\">>>Msg:\", this._toFlush.length)\n const my = this._toFlush.shift();\n my?.().finally(() => {\n // console.log(\"<<<Msg:\", this._toFlush.length)\n this._flush(this._toFlush);\n });\n }\n}\n\nfunction getLen(value: unknown): LogValue {\n if (Array.isArray(value)) {\n return logValue(() => value.length);\n } else if (typeof value === \"string\") {\n return logValue(() => value.length);\n } else if (typeof value === \"object\" && value !== null) {\n if (typeof (value as Sized).size === \"number\") {\n return logValue(() => (value as Sized).size);\n } else if (typeof (value as Lengthed).length === \"number\") {\n return logValue(() => (value as Lengthed).length);\n }\n return logValue(() => Object.keys(value).length);\n }\n return logValue(() => -1);\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction hash(value: unknown): string {\n // const hasher = createHash(\"sha256\");\n // hasher.update(JSON.stringify(value, removeSelfRef()));\n // return hasher.digest(\"hex\");\n return \"not implemented\";\n}\n\nfunction toLogValue(lop: LogValue | Promise<LogValue>): LogValue | undefined {\n if (lop && typeof (lop as Promise<LogValue>).then === \"function\") {\n throw new Error(\"async logValue Not implemented\");\n }\n return lop as LogValue;\n}\n\nexport interface LoggerImplParams {\n readonly out?: WritableStream<Uint8Array>;\n readonly logWriter?: LogWriterStream;\n readonly sys?: SysAbstraction;\n readonly withAttributes?: LogSerializable;\n readonly levelHandler?: LevelHandler;\n}\n\nclass ConsoleWriterStreamDefaultWriter implements WritableStreamDefaultWriter<Uint8Array> {\n readonly desiredSize: number | null = null;\n readonly decoder = new TextDecoder();\n\n closed: Promise<undefined>;\n ready: Promise<undefined>;\n readonly _stream: ConsoleWriterStream;\n\n constructor(private stream: ConsoleWriterStream) {\n this._stream = stream;\n this.ready = Promise.resolve(undefined);\n this.closed = Promise.resolve(undefined);\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any\n abort(reason?: any): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n async close(): Promise<void> {\n // noop\n }\n releaseLock(): void {\n this._stream.locked = false;\n this.ready = Promise.resolve(undefined);\n this.closed = Promise.resolve(undefined);\n }\n async write(chunk?: Uint8Array | undefined): Promise<void> {\n const str = this.decoder.decode(chunk).trimEnd();\n let output = \"log\";\n try {\n const decode = JSON.parse(str);\n output = decode.level;\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (e) {\n /* noop */\n }\n switch (output) {\n case \"error\":\n // eslint-disable-next-line no-console\n console.error(str);\n break;\n case \"warn\":\n // eslint-disable-next-line no-console\n console.warn(str);\n break;\n default:\n // eslint-disable-next-line no-console\n console.log(str);\n }\n }\n}\n\nclass ConsoleWriterStream implements WritableStream<Uint8Array> {\n locked = false;\n _writer?: WritableStreamDefaultWriter<Uint8Array>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars\n abort(reason?: any): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n async close(): Promise<void> {\n return;\n }\n getWriter(): WritableStreamDefaultWriter<Uint8Array> {\n if (this.locked) {\n throw new Error(\"Stream is locked\");\n }\n this.locked = true;\n if (!this._writer) {\n this._writer = new ConsoleWriterStreamDefaultWriter(this);\n }\n return this._writer;\n }\n}\n\nexport class LoggerImpl implements Logger {\n readonly _sys: SysAbstraction;\n readonly _attributes: LogSerializable = {};\n readonly _withAttributes: LogSerializable;\n readonly _logWriter: LogWriterStream;\n readonly _levelHandler: LevelHandler;\n // readonly _id: string = \"logger-\" + Math.random().toString(36)\n\n constructor(params?: LoggerImplParams) {\n if (!params) {\n params = {};\n }\n if (!params.sys) {\n this._sys = WebSysAbstraction();\n } else {\n this._sys = params.sys;\n }\n if (params.logWriter) {\n this._logWriter = params.logWriter;\n } else {\n if (!params.out) {\n const rt = runtimeFn();\n let stream: WritableStream<Uint8Array>;\n if (rt.isBrowser) {\n stream = new ConsoleWriterStream();\n } else {\n if (rt.isNodeIsh || rt.isReactNative) {\n stream = this._sys.Stdout();\n } else {\n throw new Error(\"No output defined for runtime\");\n }\n }\n this._logWriter = new LogWriterStream(stream);\n } else {\n this._logWriter = new LogWriterStream(params.out);\n }\n }\n if (!params.withAttributes) {\n this._withAttributes = {};\n } else {\n this._withAttributes = { ...params.withAttributes };\n }\n this._attributes = { ...this._withAttributes };\n if (params.levelHandler) {\n this._levelHandler = params.levelHandler;\n } else {\n this._levelHandler = levelSingleton;\n }\n // console.log(\"LoggerImpl\", this._id, this._attributes, this._withAttributes)\n }\n\n SetExposeStack(enable?: boolean): Logger {\n this._levelHandler.setExposeStack(enable);\n return this;\n }\n\n EnableLevel(level: Level, ...modules: string[]): Logger {\n this._levelHandler.enableLevel(level, ...modules);\n return this;\n }\n DisableLevel(level: Level, ...modules: string[]): Logger {\n this._levelHandler.disableLevel(level, ...modules);\n return this;\n }\n\n Module(key: string): Logger {\n this._attributes[\"module\"] = logValue(key);\n this._withAttributes[\"module\"] = logValue(key);\n return this;\n }\n // if the string is \"*\" it will enable for all modules\n SetDebug(...modules: (string | string[])[]): Logger {\n this._levelHandler.setDebug(...modules);\n return this;\n }\n\n Timestamp(): Logger {\n // this is called with .call from _produceError where this\n // this is crafted to have _sys and _attributes\n // CAUTION so done use other ref from this\n this._attributes[\"ts\"] = logValue(this._sys.Time().Now().toISOString());\n return this;\n }\n Warn(): Logger {\n this._attributes[\"level\"] = logValue(Level.WARN);\n return this;\n }\n Log(): Logger {\n return this;\n }\n Debug(): Logger {\n this._attributes[\"level\"] = logValue(Level.DEBUG);\n return this;\n }\n Error(): Logger {\n this._attributes[\"level\"] = logValue(Level.ERROR);\n return this;\n }\n Info(): Logger {\n this._attributes[\"level\"] = logValue(Level.INFO);\n return this;\n }\n Err(err: unknown): Logger {\n if (err instanceof Error) {\n this._attributes[\"error\"] = logValue(err.message);\n if (this._levelHandler.isStackExposed) {\n this._attributes[\"stack\"] = logValue(err.stack?.split(\"\\n\").map((s) => s.trim()));\n }\n } else {\n this._attributes[\"error\"] = logValue(\"\" + err);\n }\n return this;\n }\n WithLevel(l: Level): Logger {\n this._attributes[\"level\"] = logValue(l);\n return this;\n }\n\n Ref(key: string, action: { toString: () => string } | FnSerialized): Logger {\n if (typeof action === \"function\") {\n this._attributes[key] = logValue(action as FnSerialized);\n } else if (typeof action.toString === \"function\") {\n this._attributes[key] = logValue(() => action.toString());\n } else {\n this._attributes[key] = logValue(\"INVALID REF\");\n }\n return this;\n }\n Bool(key: string, value: unknown): Logger {\n this._attributes[key] = logValue(!!value);\n return this;\n }\n Result<T>(key: string, res: Result<T, Error>): Logger {\n if (res.isOk()) {\n this._attributes[key] = logValue(res.Ok() as Serialized);\n } else {\n this.Err(res.Err());\n }\n return this;\n }\n\n Len(value: unknown, key = \"len\"): Logger {\n this._attributes[key] = getLen(value);\n return this;\n }\n\n Hash(value: unknown, key = \"hash\"): Logger {\n this._attributes[key] = asyncLogValue(async () => `${getLen(value).value()}:${await hash(value)}`);\n return this;\n }\n\n Url(url: CoerceURI, key = \"url\"): Logger {\n this.Ref(key, () => URI.from(url).toString());\n return this;\n }\n\n Str(key: string, value?: string): Logger {\n this._attributes[key] = logValue(value);\n return this;\n }\n\n Any(key: string, value?: string | number | boolean | LogSerializable): Logger {\n this._attributes[key] = logValue(value);\n return this;\n }\n Dur(key: string, nsec: number): Logger {\n this._attributes[key] = logValue(`${nsec}ms`);\n // new Intl.DurationFormat(\"en\", { style: \"narrow\" }).format(nsec);\n return this;\n }\n Uint64(key: string, value: number): Logger {\n this._attributes[key] = logValue(value);\n return this;\n }\n Int(key: string, value: number): Logger {\n return this.Uint64(key, value);\n }\n\n async Flush(): Promise<void> {\n return new Promise((resolve) => {\n this._logWriter._flush(undefined, resolve);\n });\n }\n\n With(): WithLogger {\n // console.log(\"WithLoggerBuilder.With\", this._id, this._attributes, this._withAttributes);\n return new WithLoggerBuilder(\n new LoggerImpl({\n logWriter: this._logWriter,\n sys: this._sys,\n levelHandler: this._levelHandler,\n withAttributes: {\n module: this._attributes[\"module\"],\n ...this._withAttributes,\n },\n }),\n );\n }\n\n _resetAttributes(fn: () => () => string): () => string {\n const ret = fn();\n Object.keys(this._attributes).forEach((key) => {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._attributes[key];\n });\n Object.assign(this._attributes, this._withAttributes);\n return ret;\n }\n _produceError(attr: LogSerializable, ...args: string[]): string {\n attr[\"msg\"] = logValue(args.join(\" \"));\n const msg = attr[\"msg\"].value();\n if (typeof msg === \"string\" && !msg.trim().length) {\n delete attr[\"msg\"];\n }\n if (toLogValue(attr[\"ts\"])?.value() === \"ETERNITY\") {\n // hacky but it works\n this.Timestamp.call({\n _sys: this._sys,\n _attributes: attr,\n });\n }\n return JSON.stringify(attr, removeSelfRef());\n }\n\n Msg(...args: string[]): AsError {\n const fnError = this._resetAttributes(() => {\n const doWrite = this._levelHandler.isEnabled(\n toLogValue(this._attributes[\"level\"])?.value(),\n toLogValue(this._attributes[\"module\"])?.value(),\n );\n let fnRet = () => this._produceError({ ...this._attributes }, ...args);\n if (doWrite) {\n const str = fnRet();\n const encoded = encoder.encode(str + \"\\n\");\n this._logWriter.write(encoded);\n fnRet = () => str;\n }\n return fnRet;\n });\n return {\n AsError: () => new Error(fnError()),\n };\n }\n}\n\nclass WithLoggerBuilder implements WithLogger {\n readonly _li: LoggerImpl;\n constructor(li: LoggerImpl) {\n this._li = li;\n }\n\n Logger(): Logger {\n Object.assign(this._li._withAttributes, this._li._attributes);\n return this._li;\n }\n\n SetExposeStack(enable?: boolean): WithLogger {\n this._li._levelHandler.setExposeStack(enable);\n return this;\n }\n\n EnableLevel(level: Level, ...modules: string[]): WithLogger {\n this._li._levelHandler.enableLevel(level, ...modules);\n return this;\n }\n DisableLevel(level: Level, ...modules: string[]): WithLogger {\n this._li._levelHandler.enableLevel(level, ...modules);\n return this;\n }\n\n Module(key: string): WithLogger {\n this._li.Module(key);\n return this;\n }\n SetDebug(...modules: (string | string[])[]): WithLogger {\n this._li.SetDebug(...modules);\n return this;\n }\n\n Str(key: string, value?: string): WithLogger {\n this._li.Str(key, value);\n return this;\n }\n\n Len(value: unknown, key?: string): WithLogger {\n this._li.Len(value, key);\n return this;\n }\n\n Hash(value: unknown, key?: string): WithLogger {\n this._li.Hash(value, key);\n return this;\n }\n\n Ref(key: string, action: Serialized | FnSerialized): WithLogger {\n this._li.Ref(key, action);\n return this;\n }\n Bool(key: string, value: unknown): WithLogger {\n this._li.Bool(key, value);\n return this;\n }\n Result<T>(key: string, res: Result<T, Error>): WithLogger {\n this._li.Result(key, res);\n return this;\n }\n Url(url: URL, key?: string): WithLogger {\n this._li.Url(url, key);\n return this;\n }\n Int(key: string, value: number): WithLogger {\n this._li.Int(key, value);\n return this;\n }\n\n Log(): WithLogger {\n this._li.Log();\n return this;\n }\n\n WithLevel(level: Level): WithLogger {\n this._li.WithLevel(level);\n return this;\n }\n\n Error(): WithLogger {\n this._li.Error();\n return this;\n }\n Warn(): WithLogger {\n this._li.Error();\n return this;\n }\n Debug(): WithLogger {\n this._li.Debug();\n return this;\n }\n Err(err: unknown): WithLogger {\n this._li.Err(err);\n return this;\n }\n Info(): WithLogger {\n this._li.Info();\n return this;\n }\n Timestamp(): WithLogger {\n this._li._attributes[\"ts\"] = logValue(\"ETERNITY\");\n return this;\n }\n Any(key: string, value: LogSerializable): WithLogger {\n this._li.Any(key, value);\n return this;\n }\n Dur(key: string, nsec: number): WithLogger {\n this._li.Dur(key, nsec);\n return this;\n }\n Uint64(key: string, value: number): WithLogger {\n this._li.Uint64(key, value);\n return this;\n }\n}\n","import { WritableStreamDefaultWriter } from \"stream/web\";\nimport { Future } from \"../future\";\n\nexport class LogWriterCollector implements WritableStreamDefaultWriter<Uint8Array> {\n private readonly _bufferArr: Uint8Array[];\n\n constructor(bufferArr: Uint8Array[]) {\n this._bufferArr = bufferArr;\n }\n\n readonly _resolveClosed = new Future<undefined>();\n readonly closed: Promise<undefined> = this._resolveClosed.asPromise();\n readonly desiredSize: number | null = null;\n readonly ready: Promise<undefined> = Promise.resolve(undefined);\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any\n abort(reason?: any): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n async close(): Promise<void> {\n await this.closed;\n return Promise.resolve(undefined);\n }\n releaseLock(): void {\n // do nothing\n }\n async write(chunk?: Uint8Array): Promise<void> {\n if (chunk) {\n this._bufferArr.push(chunk);\n }\n return Promise.resolve(undefined);\n }\n}\n\nexport class FanoutWriter implements WritableStreamDefaultWriter<Uint8Array> {\n readonly _writers: WritableStreamDefaultWriter<Uint8Array>[];\n readonly ready: Promise<undefined>;\n readonly closed: Promise<undefined>;\n readonly desiredSize: number | null = null;\n constructor(writers: WritableStreamDefaultWriter<Uint8Array>[]) {\n this._writers = writers;\n this.ready = Promise.all(this._writers.map((w) => w.ready)).then(() => undefined);\n this.closed = Promise.all(this._writers.map((w) => w.closed)).then(() => undefined);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n abort(reason?: any): Promise<void> {\n return Promise.all(this._writers.map((w) => w.abort(reason))).then(() => {\n /* do nothing */\n });\n }\n close(): Promise<void> {\n return Promise.all(this._writers.map((w) => w.close())).then(() => {\n /* do nothing */\n });\n }\n releaseLock(): void {\n this._writers.map((w) => w.releaseLock());\n }\n\n write(chunk?: Uint8Array | undefined): Promise<void> {\n return Promise.all(this._writers.map((w) => w.write(chunk))).then(() => {\n /* do nothing */\n });\n }\n}\n\nexport class LogCollector implements WritableStream<Uint8Array> {\n readonly locked: boolean = false;\n private _writer?: FanoutWriter;\n private readonly _pass?: WritableStreamDefaultWriter<Uint8Array>;\n private readonly _bufferArr: Uint8Array[] = [];\n\n constructor(pass?: WritableStreamDefaultWriter<Uint8Array>) {\n this._pass = pass;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abort(reason?: Uint8Array): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n async close(): Promise<void> {\n if (this._writer) {\n const ret = await this._writer.close();\n this._writer = undefined;\n return ret;\n }\n return Promise.resolve(undefined);\n }\n\n getWriter(): WritableStreamDefaultWriter<Uint8Array> {\n if (!this._writer) {\n const dests: WritableStreamDefaultWriter[] = [new LogWriterCollector(this._bufferArr)];\n if (this._pass) {\n dests.push(this._pass);\n }\n this._writer = new FanoutWriter(dests);\n }\n return this._writer;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Logs(): any[] {\n if (!this._writer) {\n return [];\n }\n const jsonNlStr = new TextDecoder().decode(\n new Uint8Array(\n (function* (res: Uint8Array[]) {\n for (const x of res) {\n yield* x;\n }\n })(this._bufferArr),\n ),\n );\n const splitStr = jsonNlStr.split(\"\\n\");\n const filterStr = splitStr.filter((a) => a.length);\n const mapStr = filterStr.map((a) => JSON.parse(a));\n return mapStr;\n }\n}\n","import { Logger } from \"../logger\";\nimport { LevelHandlerImpl, LoggerImpl } from \"../logger_impl\";\nimport { SysAbstraction } from \"../sys_abstraction\";\nimport { LogCollector } from \"./log_collector\";\n\nexport interface MockLoggerReturn {\n readonly logger: Logger;\n readonly logCollector: LogCollector;\n}\n\nexport function MockLogger(params?: {\n readonly sys?: SysAbstraction;\n readonly pass?: WritableStreamDefaultWriter<Uint8Array>;\n moduleName?: string | string[];\n readonly disableDebug?: boolean;\n}): MockLoggerReturn {\n const lc = new LogCollector(params?.pass);\n let modNames = [\"MockLogger\"];\n if (typeof params?.moduleName === \"string\") {\n modNames = [params?.moduleName];\n } else if (Array.isArray(params?.moduleName)) {\n modNames = [...params.moduleName, ...modNames];\n }\n const logger = new LoggerImpl({\n out: lc,\n sys: params?.sys,\n levelHandler: new LevelHandlerImpl(),\n })\n .With()\n .Module(modNames[0])\n .Logger();\n if (!params?.disableDebug) {\n logger.SetDebug(...modNames);\n }\n return {\n logCollector: lc,\n logger,\n };\n}\n","export abstract class Result<T, E = Error> {\n static Ok<T>(t: T): Result<T, Error> {\n return new ResultOK(t);\n }\n static Err<T extends Error = Error>(t: T | string): Result<never, T> {\n if (typeof t === \"string\") {\n return new ResultError(new Error(t) as T);\n }\n return new ResultError(t);\n }\n static Is<T>(t: unknown): t is Result<T> {\n if (!t) {\n return false;\n }\n if (t instanceof Result) {\n return true;\n }\n const rt = t as Result<T>;\n if ([typeof rt.is_ok, typeof rt.is_err, typeof rt.unwrap, typeof rt.unwrap_err].every((x) => x === \"function\")) {\n return true;\n }\n return false;\n }\n\n isOk(): boolean {\n return this.is_ok();\n }\n isErr(): boolean {\n return this.is_err();\n }\n\n Ok(): T {\n return this.unwrap();\n }\n Err(): E {\n return this.unwrap_err();\n }\n\n abstract is_ok(): boolean;\n abstract is_err(): boolean;\n abstract unwrap(): T;\n abstract unwrap_err(): E;\n}\n\nexport class ResultOK<T> extends Result<T, Error> {\n private _t: T;\n constructor(t: T) {\n super();\n this._t = t;\n }\n is_ok(): boolean {\n return true;\n }\n is_err(): boolean {\n return false;\n }\n unwrap_err(): Error {\n throw new Error(\"Result is Ok\");\n }\n unwrap(): T {\n return this._t;\n }\n}\n\nexport class ResultError<T extends Error> extends Result<never, T> {\n private _error: T;\n constructor(t: T) {\n super();\n this._error = t;\n }\n is_ok(): boolean {\n return false;\n }\n is_err(): boolean {\n return true;\n }\n unwrap(): never {\n throw new Error(`Result is Err: ${this._error}`);\n }\n unwrap_err(): T {\n return this._error;\n }\n}\n\nexport type WithoutResult<T> = T extends Result<infer U> ? U : T;\n\n/*\n\ntype FinalizedResult<T> = {\n result: T;\n scopeResult?: Result<void>;\n finally: () => Promise<void>;\n}\n\ntype exection2ResultParam<T> = {\n init: () => Promise<T>;\n inScope?: (t: T) => Promise<void>;\n cleanup: (t: T) => Promise<void>;\n\n}\n\nasync function expection2Result<T>({fn, inScope, cleanup}: exection2ResultParam<T>): Promise<Result<FinalizedResult<T>>> {\n try {\n const res = await fn();\n if (inScope) {\n try {\n await inScope?.(res)\n } catch (err) {\n return Result.Err(err as Error)\n }\n await cleanup(res)\n return Result.Ok({\n result: res,\n finally: async () => { }\n })\n }\n return Result.Ok({\n result: res ,\n finally: async () => {\n return cleanup(res)\n }\n })\n } catch (err) {\n return Result.Err(err as Error)\n }\n}\n*/\n\n// await expection2Result({\n// init: openDB,\n// inScope: (res) => {\n// res.query()\n// },\n// cleanup: async (y) => {\n// await y.close()\n// }\n// })\n// async function openDB() {\n// try {\n// const opendb = await openDB()\n// return Result.Ok({\n// openDB,\n// finally: async () => {\n// await opendb.close()\n// }})\n// } catch (err) {\n// return Result.Err(err)\n// }\n// }\n// }\n","export abstract class Option<T> {\n static Some<T>(t: T): Option<T> {\n return new Some(t);\n }\n\n static None<T>(): Option<T> {\n return new None();\n }\n\n static Is<T>(t: unknown): t is Option<T> {\n return t instanceof Option;\n }\n\n IsNone(): boolean {\n return this.is_none();\n }\n\n IsSome(): boolean {\n return this.is_some();\n }\n Unwrap(): T {\n return this.unwrap();\n }\n\n abstract is_none(): boolean;\n abstract is_some(): boolean;\n abstract unwrap(): T;\n}\n\nexport class Some<T> extends Option<T> {\n private _t: T;\n constructor(_t: T) {\n super();\n this._t = _t;\n }\n\n is_none(): boolean {\n return false;\n }\n is_some(): boolean {\n return true;\n }\n unwrap(): T {\n return this._t;\n }\n}\n\nexport class None<T> extends Option<T> {\n is_none(): boolean {\n return true;\n }\n is_some(): boolean {\n return false;\n }\n unwrap(): T {\n throw new Error(\"None.unwrap\");\n }\n}\n\nexport type WithoutOption<T> = T extends Option<infer U> ? U : T;\n","export interface CTJsonWebKey {\n alg?: string;\n crv?: string;\n d?: string;\n dp?: string;\n dq?: string;\n e?: string;\n ext?: boolean;\n k?: string;\n key_ops?: string[];\n kty?: string;\n n?: string;\n oth?: RsaOtherPrimesInfo[];\n p?: string;\n q?: string;\n qi?: string;\n use?: string;\n x?: string;\n y?: string;\n}\n\nexport type CTKeyFormat = \"jwk\" | \"pkcs8\" | \"raw\" | \"spki\";\nexport type CTKeyUsage = \"decrypt\" | \"deriveBits\" | \"deriveKey\" | \"encrypt\" | \"sign\" | \"unwrapKey\" | \"verify\" | \"wrapKey\";\n\nexport interface CTAlgorithm {\n name: string;\n}\nexport type CTAlgorithmIdentifier = CTAlgorithm | string;\n\nexport interface CTRsaHashedImportParams extends CTAlgorithm {\n hash: CTAlgorithmIdentifier;\n}\n\nexport type CTNamedCurve = string;\nexport interface CTEcKeyImportParams extends CTAlgorithm {\n namedCurve: CTNamedCurve;\n}\n\nexport interface CTHmacImportParams extends CTAlgorithm {\n hash: CTAlgorithmIdentifier;\n length?: number;\n}\n\nexport interface CTAesKeyAlgorithm extends CTAlgorithm {\n length: number;\n}\n\nexport type CTKeyType = \"private\" | \"public\" | \"secret\";\n\nexport interface CTCryptoKey {\n /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/algorithm) */\n readonly algorithm: CTAlgorithm;\n /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/extractable) */\n readonly extractable: boolean;\n /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/type) */\n readonly type: CTKeyType;\n /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/usages) */\n readonly usages: CTKeyUsage[];\n}\n\ninterface CTArrayBufferTypes {\n ArrayBuffer: ArrayBuffer;\n}\ntype CTArrayBufferLike = CTArrayBufferTypes[keyof CTArrayBufferTypes];\n\nexport interface CTArrayBufferView {\n /**\n * The ArrayBuffer instance referenced by the array.\n */\n buffer: CTArrayBufferLike;\n\n /**\n * The length in bytes of the array.\n */\n byteLength: number;\n\n /**\n * The offset in bytes of the array.\n */\n byteOffset: number;\n}\n\nexport type CTBufferSource = CTArrayBufferView | ArrayBuffer;\n\nexport interface CryptoRuntime {\n importKey(\n format: CTKeyFormat,\n keyData: CTJsonWebKey | CTBufferSource,\n algorithm: CTAlgorithmIdentifier | CTRsaHashedImportParams | CTEcKeyImportParams | CTHmacImportParams | CTAesKeyAlgorithm,\n extractable: boolean,\n keyUsages: CTKeyUsage[],\n ): Promise<CTCryptoKey>;\n\n //(format: \"raw\", key: ArrayBuffer, algo: string, extractable: boolean, usages: string[]) => Promise<CryptoKey>;\n decrypt(algo: { name: string; iv: Uint8Array; tagLength: number }, key: CTCryptoKey, data: Uint8Array): Promise<ArrayBuffer>;\n encrypt(algo: { name: string; iv: Uint8Array; tagLength: number }, key: CTCryptoKey, data: Uint8Array): Promise<ArrayBuffer>;\n digestSHA256(data: Uint8Array): Promise<ArrayBuffer>;\n randomBytes(size: number): Uint8Array;\n}\n\nfunction randomBytes(size: number) {\n const bytes = new Uint8Array(size);\n if (size > 0) {\n crypto.getRandomValues(bytes);\n }\n return bytes;\n}\n\nfunction digestSHA256(data: Uint8Array): Promise<ArrayBuffer> {\n return Promise.resolve(crypto.subtle.digest(\"SHA-256\", data));\n}\n\nexport function toCryptoRuntime(cryptoOpts: Partial<CryptoRuntime> = {}): CryptoRuntime {\n const runtime = {\n importKey: cryptoOpts.importKey || crypto.subtle.importKey.bind(crypto.subtle),\n encrypt: cryptoOpts.encrypt || crypto.subtle.encrypt.bind(crypto.subtle),\n decrypt: cryptoOpts.decrypt || crypto.subtle.decrypt.bind(crypto.subtle),\n randomBytes: cryptoOpts.randomBytes || randomBytes,\n digestSHA256: cryptoOpts.digestSHA256 || digestSHA256,\n };\n // console.log(\"cryptoOpts\", cryptoOpts, opts)\n return runtime;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,IAAK,QAAL,kBAAKA,WAAL;AACL,EAAAA,OAAA,UAAO;AACP,EAAAA,OAAA,WAAQ;AACR,EAAAA,OAAA,UAAO;AACP,EAAAA,OAAA,WAAQ;AAJE,SAAAA;AAAA,GAAA;AAUL,IAAM,WAAN,MAAe;AAAA,EACpB,YAAqB,IAAkB;AAAlB;AAAA,EAAmB;AAAA,EACxC,QAAmC;AACjC,WAAO,KAAK,GAAG;AAAA,EACjB;AAAA,EACA,SAAoC;AAClC,WAAO,KAAK,MAAM;AAAA,EACpB;AACF;AAIO,SAAS,gBAAyD;AACvE,QAAM,QAAQ,oBAAI,IAAI;AACtB,SAAO,SAAU,KAAc,OAAgB;AAC7C,Q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AN,cAAsB,OAAU;AAAA,EACrC,UAAmB;AACjB,WAAO;AAAA,EACT;AAAA,EACA,UAAmB;AACjB,WAAO;AAAA,EACT;AAAA,EACA,SAAY;AACV,UAAM,IAAI,MAAM,aAAa;AAAA,EAC/B;AACF;;;AC2CA,SAAS,YAAY,MAAc;AACjC,QAAM,QAAQ,IAAI,WAAW,IAAI;AACjC,MAAI,OAAO,GAAG;AACZ,WAAO,gBAAgB,KAAK;AAAA,EAC9B;AACA,SAAO;AACT;AAEA,SAAS,aAAa,MAAwC;AAC5D,SAAO,QAAQ,QAAQ,OAAO,OAAO,OAAO,WAAW,IAAI,CAAC;AAC9D;AAEO,SAAS,gBAAgB,aAAqC,CAAC,GAAkB;AACtF,QAAM,UAAU;AAAA,IACd,WAAW,WAAW,aAAa,OAAO,OAAO,UAAU,KAAK,OAAO,MAAM;AAAA,IAC7E,SAAS,WAAW,WAAW,OAAO,OAAO,QAAQ,KAAK,OAAO,MAAM;AAAA,IACvE,SAAS,WAAW,WAAW,OAAO,OAAO,QAAQ,KAAK,OAAO,MAAM;AAAA,IACvE,aAAa,WAAW,eAAe;AAAA,IACvC,cAAc,WAAW,gBAAgB;AAAA,EAC3C;AAEA,SAAO;AACT;","names":["Level","from"]}
1
+ {"version":3,"sources":["../../src/logger.ts","../../src/uri.ts","../../src/runtime.ts","../../src/logger-impl.ts","../../src/test/log-write-stream.ts","../../src/test/mock-logger.ts","../../src/result.ts","../../src/option.ts","../../src/crypto.ts"],"sourcesContent":["import { Result } from \"./result\";\nimport { CoerceURI } from \"./uri\";\n\nexport enum Level {\n WARN = \"warn\",\n DEBUG = \"debug\",\n INFO = \"info\",\n ERROR = \"error\",\n}\n\nexport type Serialized = string | number | boolean;\nexport type FnSerialized = () => Serialized | Serialized[];\n\nexport class LogValue {\n constructor(readonly fn: FnSerialized) {}\n value(): Serialized | Serialized[] {\n return this.fn();\n }\n toJSON(): Serialized | Serialized[] {\n return this.value();\n }\n}\n\nexport type LogSerializable = Record<string, LogValue | Promise<LogValue>>;\n\nexport function removeSelfRef(): (key: unknown, val: unknown) => unknown {\n const cache = new Set();\n return function (key: unknown, value: unknown) {\n if (typeof value === \"object\" && value !== null) {\n // Duplicate reference found, discard key\n if (cache.has(value)) return \"...\";\n cache.add(value);\n }\n return value;\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function asyncLogValue(val: () => Promise<Serialized>): Promise<LogValue> {\n // return Promise.resolve(logValue(val));\n throw new Error(\"Not implemented\");\n}\n\nexport function logValue(val: Serialized | Serialized[] | FnSerialized | LogSerializable | undefined | null): LogValue {\n switch (typeof val) {\n case \"function\":\n return new LogValue(val);\n case \"string\":\n return new LogValue(() => {\n try {\n const ret = JSON.parse(val);\n if (typeof ret === \"object\" && ret !== null) {\n return ret;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (e) {\n // do nothing\n }\n return val.toString();\n });\n case \"number\":\n return new LogValue(() => val);\n case \"boolean\":\n return new LogValue(() => val);\n case \"object\":\n return new LogValue(() => JSON.parse(JSON.stringify(val, removeSelfRef())));\n default:\n if (!val) {\n return new LogValue(() => \"--Falsy--\");\n }\n throw new Error(`Invalid type:${typeof val}`);\n }\n}\n\nexport interface Sized {\n size: number;\n}\nexport interface Lengthed {\n length: number;\n}\nexport type SizeOrLength = Sized | Lengthed;\n\nexport interface LoggerInterface<R> {\n Module(key: string): R;\n // if modules is empty, set for all Levels\n EnableLevel(level: Level, ...modules: string[]): R;\n DisableLevel(level: Level, ...modules: string[]): R;\n\n SetDebug(...modules: (string | string[])[]): R;\n SetExposeStack(enable?: boolean): R;\n\n Ref(key: string, action: { toString: () => string } | FnSerialized): R;\n Result<T>(key: string, res: Result<T>): R;\n // default key url\n Url(url: CoerceURI, key?: string): R;\n // len\n Len(value: unknown, key?: string): R;\n\n Hash(value: unknown, key?: string): R;\n\n Str(key: string, value?: string): R;\n Error(): R;\n Warn(): R;\n Debug(): R;\n Log(): R;\n WithLevel(level: Level): R;\n\n Err(err: unknown): R; // could be Error, or something which coerces to string\n Info(): R;\n Timestamp(): R;\n Any(key: string, value: unknown): R;\n Dur(key: string, nsec: number): R;\n Uint64(key: string, value: number): R;\n Int(key: string, value: number): R;\n Bool(key: string, value: unknown): R;\n}\n\nexport function IsLogger(obj: unknown): obj is Logger {\n return (\n typeof obj === \"object\" &&\n [\n \"Module\",\n \"EnableLevel\",\n \"DisableLevel\",\n \"SetDebug\",\n \"Str\",\n \"Error\",\n \"Warn\",\n \"Debug\",\n \"Log\",\n \"WithLevel\",\n \"Err\",\n \"Info\",\n \"Timestamp\",\n \"Any\",\n \"Dur\",\n \"Uint64\",\n ]\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n .map((fn) => typeof (obj as any)[fn] === \"function\")\n .reduce((a, b) => a && b, true)\n );\n}\n\nexport interface WithLogger extends LoggerInterface<WithLogger> {\n Logger(): Logger;\n}\n\nexport interface AsError {\n AsError(): Error;\n}\n\nexport interface Logger extends LoggerInterface<Logger> {\n With(): WithLogger;\n\n Msg(...args: string[]): AsError;\n Flush(): Promise<void>;\n}\n","type NullOrUndef = null | undefined;\n\nfunction falsy2undef<T>(value: T | NullOrUndef): T | undefined {\n return value === undefined || value === null ? undefined : value;\n}\n\nfunction ensureURLWithDefaultProto(url: string | URL, defaultProtocol: string): URL {\n if (!url) {\n return new URL(`${defaultProtocol}//`);\n }\n if (typeof url === \"string\") {\n try {\n return new URL(url);\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (e) {\n return new URL(`${defaultProtocol}//${url}`);\n }\n } else {\n return url;\n }\n}\n\nexport function isURL(value: unknown): value is URL {\n return (\n value instanceof URL ||\n (!!value &&\n typeof (value as URL).searchParams === \"object\" &&\n typeof (value as URL).searchParams.sort === \"function\" &&\n typeof (value as URL).hash === \"string\")\n );\n}\n\nfunction from<T>(fac: (url: URL) => T, strURLUri: CoerceURI | undefined, defaultProtocol: string): T {\n switch (typeof falsy2undef(strURLUri)) {\n case \"undefined\":\n return fac(new URL(`${defaultProtocol}//`));\n case \"string\":\n return fac(ensureURLWithDefaultProto(strURLUri as string, defaultProtocol));\n case \"object\":\n if (BuildURI.is(strURLUri)) {\n return fac(new URL(strURLUri._url.toString()));\n } else if (URI.is(strURLUri)) {\n return fac(new URL(strURLUri._url.toString()));\n } else if (isURL(strURLUri)) {\n return fac(new URL(strURLUri.toString()));\n }\n throw new Error(`unknown object type: ${strURLUri}`);\n default:\n throw new Error(`Invalid argument: ${typeof strURLUri}`);\n }\n}\n\nexport class BuildURI {\n _url: URL; // pathname needs this\n private constructor(url: URL) {\n this._url = url;\n }\n\n static is(value: unknown): value is BuildURI {\n return (\n value instanceof BuildURI ||\n (!!value && typeof (value as BuildURI).delParam === \"function\" && typeof (value as BuildURI).setParam === \"function\")\n );\n }\n static from(strURLUri?: CoerceURI, defaultProtocol = \"file:\"): BuildURI {\n return from((url) => new BuildURI(url), strURLUri, defaultProtocol);\n }\n\n hostname(h: string) {\n this._url.hostname = h;\n return this;\n }\n\n password(p: string) {\n this._url.password = p;\n return this;\n }\n\n port(p: string) {\n this._url.port = p;\n return this;\n }\n\n username(u: string) {\n this._url.username = u;\n return this;\n }\n\n search(s: string) {\n this._url.search = s;\n return this;\n }\n\n protocol(p: string) {\n if (!p.endsWith(\":\")) {\n p = `${p}:`;\n }\n const mySrc = this._url.toString();\n const myDst = mySrc.replace(new RegExp(`^${this._url.protocol}`), `${p}`);\n this._url = new URL(myDst);\n return this;\n }\n\n pathname(p: string) {\n const myp = this.URI().pathname;\n const mySrc = this._url.toString();\n const myDst = mySrc.replace(new RegExp(`^${this._url.protocol}//${myp}`), `${this._url.protocol}//${p}`);\n this._url = new URL(myDst);\n return this;\n }\n\n hash(h: string) {\n this._url.hash = h;\n return this;\n }\n\n host(h: string) {\n this._url.host = h;\n return this;\n }\n\n delParam(key: string) {\n this._url.searchParams.delete(key);\n return this;\n }\n\n defParam(key: string, str: string) {\n if (!this._url.searchParams.has(key)) {\n this._url.searchParams.set(key, str);\n }\n return this;\n }\n\n setParam(key: string, str: string) {\n this._url.searchParams.set(key, str);\n return this;\n }\n\n toString(): string {\n this._url.searchParams.sort();\n return this._url.toString();\n }\n\n URI(): URI {\n return URI.from(this._url);\n }\n}\n\nexport type CoerceURI = string | URL | URI | BuildURI | NullOrUndef;\n\n// non mutable URL Implementation\nexport class URI {\n // if no protocol is provided, default to file:\n static merge(into: CoerceURI, from: CoerceURI, defaultProtocol = \"file:\"): URI {\n const intoUrl = BuildURI.from(into, defaultProtocol);\n const fromUrl = URI.from(from, defaultProtocol);\n intoUrl.protocol(fromUrl.protocol);\n const fPath = fromUrl.pathname;\n if (!(fPath.length === 0 || fPath === \"/\" || fPath === \"./\")) {\n intoUrl.pathname(fromUrl.pathname);\n }\n for (const [key, value] of fromUrl.getParams) {\n intoUrl.setParam(key, value);\n }\n return intoUrl.URI();\n }\n\n static is(value: unknown): value is URI {\n return (\n value instanceof URI ||\n (!!value &&\n typeof (value as URI).asURL === \"function\" &&\n typeof (value as URI).getParam === \"function\" &&\n typeof (value as URI).hasParam === \"function\")\n );\n }\n\n // if no protocol is provided, default to file:\n static from(strURLUri?: CoerceURI, defaultProtocol = \"file:\"): URI {\n return from((url) => new URI(url), strURLUri, defaultProtocol);\n }\n\n readonly _url: URL;\n private constructor(url: URL) {\n this._url = url;\n }\n\n build(): BuildURI {\n return BuildURI.from(this.asURL());\n }\n\n get hostname(): string {\n return this._url.hostname;\n }\n\n get password(): string {\n return this._url.password;\n }\n\n get port(): string {\n return this._url.port;\n }\n\n get username(): string {\n return this._url.username;\n }\n\n get search(): string {\n return this._url.search;\n }\n\n get protocol(): string {\n return this._url.protocol;\n }\n\n get pathname(): string {\n return this._url\n .toString()\n .replace(/^.*:\\/\\//, \"\")\n .replace(/\\?.*$/, \"\");\n }\n\n get hash(): string {\n return this._url.hash;\n }\n\n get host(): string {\n return this._url.host;\n }\n\n get getParams(): Iterable<[string, string]> {\n return this._url.searchParams.entries();\n }\n\n hasParam(key: string): boolean {\n return this._url.searchParams.has(key);\n }\n getParam(key: string): string | undefined {\n return falsy2undef(this._url.searchParams.get(key));\n }\n\n clone(): URI {\n return new URI(this.asURL());\n }\n\n asURL(): URL {\n const url = new URL(this._url.toString());\n url.searchParams.sort();\n return url;\n }\n\n toString(): string {\n this._url.searchParams.sort();\n return this._url.toString();\n }\n}\n","export interface Runtime {\n isNodeIsh: boolean;\n isBrowser: boolean;\n isDeno: boolean;\n isReactNative: boolean;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction isSet(value: string, ref: any = globalThis): boolean {\n const [head, ...tail] = value.split(\".\");\n if ([\"object\", \"function\"].includes(typeof ref) && ref && [\"object\", \"function\"].includes(typeof ref[head]) && ref[head]) {\n if (tail.length <= 1) {\n return true;\n }\n return isSet(tail.join(\".\"), ref[head]);\n }\n return false;\n}\n\nexport function runtimeFn(): Runtime {\n const isReactNative = isSet(\"navigator.product\") && globalThis.navigator.product === \"ReactNative\";\n const isNodeIsh = isSet(\"process.versions.node\") && !isReactNative;\n const isDeno = isSet(\"Deno\") && !isReactNative;\n return {\n isNodeIsh,\n isBrowser: !(isNodeIsh || isDeno) && !isReactNative,\n isDeno,\n isReactNative,\n };\n}\n","// import { v4 } from \"uuid\";\nimport {\n AsError,\n FnSerialized,\n LogSerializable,\n Level,\n Logger,\n logValue,\n Serialized,\n WithLogger,\n removeSelfRef,\n Sized,\n Lengthed,\n LogValue,\n asyncLogValue,\n} from \"./logger\";\nimport { WebSysAbstraction } from \"./web/web-sys-abstraction\";\nimport { SysAbstraction } from \"./sys-abstraction\";\nimport { Result } from \"./result\";\nimport { CoerceURI, URI } from \"./uri\";\nimport { runtimeFn } from \"./runtime\";\nimport { ConsoleWriterStream } from \"./utils/console-write-stream\";\n\nconst encoder = new TextEncoder();\n\nexport interface LevelHandler {\n enableLevel(level: Level, ...modules: string[]): void;\n disableLevel(level: Level, ...modules: string[]): void;\n setExposeStack(enable?: boolean): void;\n isStackExposed: boolean;\n setDebug(...modules: (string | string[])[]): void;\n isEnabled(ilevel: unknown, module: unknown): boolean;\n}\n\nexport class LevelHandlerImpl implements LevelHandler {\n readonly _globalLevels = new Set<Level>([Level.INFO, Level.ERROR, Level.WARN]);\n readonly _modules = new Map<string, Set<Level>>();\n isStackExposed = false;\n enableLevel(level: Level, ...modules: string[]): void {\n if (modules.length == 0) {\n this._globalLevels.add(level);\n return;\n }\n this.forModules(\n level,\n (p) => {\n this._modules.set(p, new Set([...this._globalLevels, level]));\n },\n ...modules,\n );\n }\n disableLevel(level: Level, ...modules: string[]): void {\n if (modules.length == 0) {\n this._globalLevels.delete(level);\n return;\n }\n this.forModules(\n level,\n (p) => {\n this._modules.delete(p);\n },\n ...modules,\n );\n }\n\n setExposeStack(enable?: boolean): void {\n this.isStackExposed = !!enable;\n }\n\n forModules(level: Level, fnAction: (p: string) => void, ...modules: (string | string[])[]): void {\n for (const m of modules.flat()) {\n if (typeof m !== \"string\") {\n continue;\n }\n const parts = m\n .split(\",\")\n .map((s) => s.trim())\n .filter((s) => s.length);\n for (const p of parts) {\n fnAction(p);\n }\n }\n }\n setDebug(...modules: (string | string[])[]): void {\n this.forModules(\n Level.DEBUG,\n (p) => {\n this._modules.set(p, new Set([...this._globalLevels, Level.DEBUG]));\n },\n ...modules,\n );\n }\n isEnabled(ilevel: unknown, module: unknown): boolean {\n const level = ilevel as Level; // what if it's not a level?\n if (typeof module === \"string\") {\n const levels = this._modules.get(module);\n if (levels && levels.has(level)) {\n return true;\n }\n }\n const wlevel = this._modules.get(\"*\");\n if (wlevel && typeof level === \"string\") {\n if (wlevel.has(level)) {\n return true;\n }\n }\n if (typeof level !== \"string\") {\n // this is a plain log\n return true;\n }\n return this._globalLevels.has(level);\n }\n}\n\nconst levelSingleton = new LevelHandlerImpl();\n\nexport class LogWriterStream {\n readonly _out: WritableStream<Uint8Array>;\n readonly _toFlush: (() => Promise<void>)[] = [];\n\n constructor(out: WritableStream<Uint8Array>) {\n this._out = out;\n }\n\n write(encoded: Uint8Array) {\n const my = async () => {\n // const val = Math.random();\n // console.log(\">>>My:\", val)\n try {\n const writer = this._out.getWriter();\n await writer.ready;\n await writer.write(encoded);\n await writer.releaseLock();\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error(\"Chunk error:\", err);\n }\n // console.log(\"<<<My:\", val)\n };\n this._toFlush.push(my);\n this._flush();\n }\n\n _flushIsRunning = false;\n _flushDoneFns = Array<() => void>();\n _flush(toFlush: (() => Promise<void>)[] | undefined = undefined, done?: () => void): void {\n if (done) {\n this._flushDoneFns.push(done);\n }\n\n if (this._toFlush.length == 0) {\n // console.log(\"Flush is stopped\", this._toFlush.length)\n this._flushIsRunning = false;\n this._flushDoneFns.forEach((fn) => fn());\n this._flushDoneFns = [];\n return;\n }\n\n if (!toFlush && this._toFlush.length == 1 && !this._flushIsRunning) {\n this._flushIsRunning = true;\n // console.log(\"Flush is started\", this._toFlush.length)\n } else if (!toFlush) {\n // console.log(\"flush queue check but is running\", this._toFlush.length)\n return;\n }\n\n // console.log(\">>>Msg:\", this._toFlush.length)\n const my = this._toFlush.shift();\n my?.().finally(() => {\n // console.log(\"<<<Msg:\", this._toFlush.length)\n this._flush(this._toFlush);\n });\n }\n}\n\nfunction getLen(value: unknown): LogValue {\n if (Array.isArray(value)) {\n return logValue(() => value.length);\n } else if (typeof value === \"string\") {\n return logValue(() => value.length);\n } else if (typeof value === \"object\" && value !== null) {\n if (typeof (value as Sized).size === \"number\") {\n return logValue(() => (value as Sized).size);\n } else if (typeof (value as Lengthed).length === \"number\") {\n return logValue(() => (value as Lengthed).length);\n }\n return logValue(() => Object.keys(value).length);\n }\n return logValue(() => -1);\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction hash(value: unknown): string {\n // const hasher = createHash(\"sha256\");\n // hasher.update(JSON.stringify(value, removeSelfRef()));\n // return hasher.digest(\"hex\");\n return \"not implemented\";\n}\n\nfunction toLogValue(lop: LogValue | Promise<LogValue>): LogValue | undefined {\n if (lop && typeof (lop as Promise<LogValue>).then === \"function\") {\n throw new Error(\"async logValue Not implemented\");\n }\n return lop as LogValue;\n}\n\nexport interface LoggerImplParams {\n readonly out?: WritableStream<Uint8Array>;\n readonly logWriter?: LogWriterStream;\n readonly sys?: SysAbstraction;\n readonly withAttributes?: LogSerializable;\n readonly levelHandler?: LevelHandler;\n}\n\nexport class LoggerImpl implements Logger {\n readonly _sys: SysAbstraction;\n readonly _attributes: LogSerializable = {};\n readonly _withAttributes: LogSerializable;\n readonly _logWriter: LogWriterStream;\n readonly _levelHandler: LevelHandler;\n // readonly _id: string = \"logger-\" + Math.random().toString(36)\n\n constructor(params?: LoggerImplParams) {\n if (!params) {\n params = {};\n }\n if (!params.sys) {\n this._sys = WebSysAbstraction();\n } else {\n this._sys = params.sys;\n }\n if (params.logWriter) {\n this._logWriter = params.logWriter;\n } else {\n if (!params.out) {\n const rt = runtimeFn();\n let stream: WritableStream<Uint8Array>;\n if (rt.isBrowser) {\n stream = new ConsoleWriterStream();\n } else {\n if (rt.isNodeIsh || rt.isReactNative) {\n stream = this._sys.Stdout();\n } else {\n throw new Error(\"No output defined for runtime\");\n }\n }\n this._logWriter = new LogWriterStream(stream);\n } else {\n this._logWriter = new LogWriterStream(params.out);\n }\n }\n if (!params.withAttributes) {\n this._withAttributes = {};\n } else {\n this._withAttributes = { ...params.withAttributes };\n }\n this._attributes = { ...this._withAttributes };\n if (params.levelHandler) {\n this._levelHandler = params.levelHandler;\n } else {\n this._levelHandler = levelSingleton;\n }\n // console.log(\"LoggerImpl\", this._id, this._attributes, this._withAttributes)\n }\n\n SetExposeStack(enable?: boolean): Logger {\n this._levelHandler.setExposeStack(enable);\n return this;\n }\n\n EnableLevel(level: Level, ...modules: string[]): Logger {\n this._levelHandler.enableLevel(level, ...modules);\n return this;\n }\n DisableLevel(level: Level, ...modules: string[]): Logger {\n this._levelHandler.disableLevel(level, ...modules);\n return this;\n }\n\n Module(key: string): Logger {\n this._attributes[\"module\"] = logValue(key);\n this._withAttributes[\"module\"] = logValue(key);\n return this;\n }\n // if the string is \"*\" it will enable for all modules\n SetDebug(...modules: (string | string[])[]): Logger {\n this._levelHandler.setDebug(...modules);\n return this;\n }\n\n Timestamp(): Logger {\n // this is called with .call from _produceError where this\n // this is crafted to have _sys and _attributes\n // CAUTION so done use other ref from this\n this._attributes[\"ts\"] = logValue(this._sys.Time().Now().toISOString());\n return this;\n }\n Warn(): Logger {\n this._attributes[\"level\"] = logValue(Level.WARN);\n return this;\n }\n Log(): Logger {\n return this;\n }\n Debug(): Logger {\n this._attributes[\"level\"] = logValue(Level.DEBUG);\n return this;\n }\n Error(): Logger {\n this._attributes[\"level\"] = logValue(Level.ERROR);\n return this;\n }\n Info(): Logger {\n this._attributes[\"level\"] = logValue(Level.INFO);\n return this;\n }\n Err(err: unknown): Logger {\n if (err instanceof Error) {\n this._attributes[\"error\"] = logValue(err.message);\n if (this._levelHandler.isStackExposed) {\n this._attributes[\"stack\"] = logValue(err.stack?.split(\"\\n\").map((s) => s.trim()));\n }\n } else {\n this._attributes[\"error\"] = logValue(\"\" + err);\n }\n return this;\n }\n WithLevel(l: Level): Logger {\n this._attributes[\"level\"] = logValue(l);\n return this;\n }\n\n Ref(key: string, action: { toString: () => string } | FnSerialized): Logger {\n if (typeof action === \"function\") {\n this._attributes[key] = logValue(action as FnSerialized);\n } else if (typeof action.toString === \"function\") {\n this._attributes[key] = logValue(() => action.toString());\n } else {\n this._attributes[key] = logValue(\"INVALID REF\");\n }\n return this;\n }\n Bool(key: string, value: unknown): Logger {\n this._attributes[key] = logValue(!!value);\n return this;\n }\n Result<T>(key: string, res: Result<T, Error>): Logger {\n if (res.isOk()) {\n this._attributes[key] = logValue(res.Ok() as Serialized);\n } else {\n this.Err(res.Err());\n }\n return this;\n }\n\n Len(value: unknown, key = \"len\"): Logger {\n this._attributes[key] = getLen(value);\n return this;\n }\n\n Hash(value: unknown, key = \"hash\"): Logger {\n this._attributes[key] = asyncLogValue(async () => `${getLen(value).value()}:${await hash(value)}`);\n return this;\n }\n\n Url(url: CoerceURI, key = \"url\"): Logger {\n this.Ref(key, () => URI.from(url).toString());\n return this;\n }\n\n Str(key: string, value?: string): Logger {\n this._attributes[key] = logValue(value);\n return this;\n }\n\n Any(key: string, value?: string | number | boolean | LogSerializable): Logger {\n this._attributes[key] = logValue(value);\n return this;\n }\n Dur(key: string, nsec: number): Logger {\n this._attributes[key] = logValue(`${nsec}ms`);\n // new Intl.DurationFormat(\"en\", { style: \"narrow\" }).format(nsec);\n return this;\n }\n Uint64(key: string, value: number): Logger {\n this._attributes[key] = logValue(value);\n return this;\n }\n Int(key: string, value: number): Logger {\n return this.Uint64(key, value);\n }\n\n async Flush(): Promise<void> {\n return new Promise((resolve) => {\n this._logWriter._flush(undefined, resolve);\n });\n }\n\n With(): WithLogger {\n // console.log(\"WithLoggerBuilder.With\", this._id, this._attributes, this._withAttributes);\n return new WithLoggerBuilder(\n new LoggerImpl({\n logWriter: this._logWriter,\n sys: this._sys,\n levelHandler: this._levelHandler,\n withAttributes: {\n module: this._attributes[\"module\"],\n ...this._withAttributes,\n },\n }),\n );\n }\n\n _resetAttributes(fn: () => () => string): () => string {\n const ret = fn();\n Object.keys(this._attributes).forEach((key) => {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._attributes[key];\n });\n Object.assign(this._attributes, this._withAttributes);\n return ret;\n }\n _produceError(attr: LogSerializable, ...args: string[]): string {\n attr[\"msg\"] = logValue(args.join(\" \"));\n const msg = attr[\"msg\"].value();\n if (typeof msg === \"string\" && !msg.trim().length) {\n delete attr[\"msg\"];\n }\n if (toLogValue(attr[\"ts\"])?.value() === \"ETERNITY\") {\n // hacky but it works\n this.Timestamp.call({\n _sys: this._sys,\n _attributes: attr,\n });\n }\n return JSON.stringify(attr, removeSelfRef());\n }\n\n Msg(...args: string[]): AsError {\n const fnError = this._resetAttributes(() => {\n const doWrite = this._levelHandler.isEnabled(\n toLogValue(this._attributes[\"level\"])?.value(),\n toLogValue(this._attributes[\"module\"])?.value(),\n );\n let fnRet = () => this._produceError({ ...this._attributes }, ...args);\n if (doWrite) {\n const str = fnRet();\n const encoded = encoder.encode(str + \"\\n\");\n this._logWriter.write(encoded);\n fnRet = () => str;\n }\n return fnRet;\n });\n return {\n AsError: () => new Error(fnError()),\n };\n }\n}\n\nclass WithLoggerBuilder implements WithLogger {\n readonly _li: LoggerImpl;\n constructor(li: LoggerImpl) {\n this._li = li;\n }\n\n Logger(): Logger {\n Object.assign(this._li._withAttributes, this._li._attributes);\n return this._li;\n }\n\n SetExposeStack(enable?: boolean): WithLogger {\n this._li._levelHandler.setExposeStack(enable);\n return this;\n }\n\n EnableLevel(level: Level, ...modules: string[]): WithLogger {\n this._li._levelHandler.enableLevel(level, ...modules);\n return this;\n }\n DisableLevel(level: Level, ...modules: string[]): WithLogger {\n this._li._levelHandler.enableLevel(level, ...modules);\n return this;\n }\n\n Module(key: string): WithLogger {\n this._li.Module(key);\n return this;\n }\n SetDebug(...modules: (string | string[])[]): WithLogger {\n this._li.SetDebug(...modules);\n return this;\n }\n\n Str(key: string, value?: string): WithLogger {\n this._li.Str(key, value);\n return this;\n }\n\n Len(value: unknown, key?: string): WithLogger {\n this._li.Len(value, key);\n return this;\n }\n\n Hash(value: unknown, key?: string): WithLogger {\n this._li.Hash(value, key);\n return this;\n }\n\n Ref(key: string, action: Serialized | FnSerialized): WithLogger {\n this._li.Ref(key, action);\n return this;\n }\n Bool(key: string, value: unknown): WithLogger {\n this._li.Bool(key, value);\n return this;\n }\n Result<T>(key: string, res: Result<T, Error>): WithLogger {\n this._li.Result(key, res);\n return this;\n }\n Url(url: URL, key?: string): WithLogger {\n this._li.Url(url, key);\n return this;\n }\n Int(key: string, value: number): WithLogger {\n this._li.Int(key, value);\n return this;\n }\n\n Log(): WithLogger {\n this._li.Log();\n return this;\n }\n\n WithLevel(level: Level): WithLogger {\n this._li.WithLevel(level);\n return this;\n }\n\n Error(): WithLogger {\n this._li.Error();\n return this;\n }\n Warn(): WithLogger {\n this._li.Error();\n return this;\n }\n Debug(): WithLogger {\n this._li.Debug();\n return this;\n }\n Err(err: unknown): WithLogger {\n this._li.Err(err);\n return this;\n }\n Info(): WithLogger {\n this._li.Info();\n return this;\n }\n Timestamp(): WithLogger {\n this._li._attributes[\"ts\"] = logValue(\"ETERNITY\");\n return this;\n }\n Any(key: string, value: LogSerializable): WithLogger {\n this._li.Any(key, value);\n return this;\n }\n Dur(key: string, nsec: number): WithLogger {\n this._li.Dur(key, nsec);\n return this;\n }\n Uint64(key: string, value: number): WithLogger {\n this._li.Uint64(key, value);\n return this;\n }\n}\n","import { FanoutWriteStream } from \"../utils/fanout-write-stream\";\nimport { Future } from \"../future\";\n\nexport class LogWriteStream implements WritableStreamDefaultWriter<Uint8Array> {\n private readonly _bufferArr: Uint8Array[];\n\n constructor(bufferArr: Uint8Array[]) {\n this._bufferArr = bufferArr;\n }\n\n readonly _resolveClosed = new Future<undefined>();\n readonly closed: Promise<undefined> = this._resolveClosed.asPromise();\n readonly desiredSize: number | null = null;\n readonly ready: Promise<undefined> = Promise.resolve(undefined);\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any\n abort(reason?: any): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n async close(): Promise<void> {\n await this.closed;\n return Promise.resolve(undefined);\n }\n releaseLock(): void {\n // do nothing\n }\n async write(chunk?: Uint8Array): Promise<void> {\n if (chunk) {\n this._bufferArr.push(chunk);\n }\n return Promise.resolve(undefined);\n }\n}\n\nexport class LogCollector implements WritableStream<Uint8Array> {\n readonly locked: boolean = false;\n private _writer?: FanoutWriteStream;\n private readonly _pass?: WritableStreamDefaultWriter<Uint8Array>;\n private readonly _bufferArr: Uint8Array[] = [];\n\n constructor(pass?: WritableStreamDefaultWriter<Uint8Array>) {\n this._pass = pass;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abort(reason?: Uint8Array): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n async close(): Promise<void> {\n if (this._writer) {\n const ret = await this._writer.close();\n this._writer = undefined;\n return ret;\n }\n return Promise.resolve(undefined);\n }\n\n getWriter(): WritableStreamDefaultWriter<Uint8Array> {\n if (!this._writer) {\n const dests: WritableStreamDefaultWriter[] = [new LogWriteStream(this._bufferArr)];\n if (this._pass) {\n dests.push(this._pass);\n }\n this._writer = new FanoutWriteStream(dests);\n }\n return this._writer;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Logs(): any[] {\n if (!this._writer) {\n return [];\n }\n const jsonNlStr = new TextDecoder().decode(\n new Uint8Array(\n (function* (res: Uint8Array[]) {\n for (const x of res) {\n yield* x;\n }\n })(this._bufferArr),\n ),\n );\n const splitStr = jsonNlStr.split(\"\\n\");\n const filterStr = splitStr.filter((a) => a.length);\n const mapStr = filterStr.map((a) => JSON.parse(a));\n return mapStr;\n }\n}\n","import { Logger } from \"../logger\";\nimport { LevelHandlerImpl, LoggerImpl } from \"../logger-impl\";\nimport { SysAbstraction } from \"../sys-abstraction\";\nimport { LogCollector } from \"./log-write-stream\";\n\nexport interface MockLoggerReturn {\n readonly logger: Logger;\n readonly logCollector: LogCollector;\n}\n\nexport function MockLogger(params?: {\n readonly sys?: SysAbstraction;\n readonly pass?: WritableStreamDefaultWriter<Uint8Array>;\n moduleName?: string | string[];\n readonly disableDebug?: boolean;\n}): MockLoggerReturn {\n const lc = new LogCollector(params?.pass);\n let modNames = [\"MockLogger\"];\n if (typeof params?.moduleName === \"string\") {\n modNames = [params?.moduleName];\n } else if (Array.isArray(params?.moduleName)) {\n modNames = [...params.moduleName, ...modNames];\n }\n const logger = new LoggerImpl({\n out: lc,\n sys: params?.sys,\n levelHandler: new LevelHandlerImpl(),\n })\n .With()\n .Module(modNames[0])\n .Logger();\n if (!params?.disableDebug) {\n logger.SetDebug(...modNames);\n }\n return {\n logCollector: lc,\n logger,\n };\n}\n","export abstract class Result<T, E = Error> {\n static Ok<T>(t: T): Result<T, Error> {\n return new ResultOK(t);\n }\n static Err<T extends Error = Error>(t: T | string): Result<never, T> {\n if (typeof t === \"string\") {\n return new ResultError(new Error(t) as T);\n }\n return new ResultError(t);\n }\n static Is<T>(t: unknown): t is Result<T> {\n if (!t) {\n return false;\n }\n if (t instanceof Result) {\n return true;\n }\n const rt = t as Result<T>;\n if ([typeof rt.is_ok, typeof rt.is_err, typeof rt.unwrap, typeof rt.unwrap_err].every((x) => x === \"function\")) {\n return true;\n }\n return false;\n }\n\n isOk(): boolean {\n return this.is_ok();\n }\n isErr(): boolean {\n return this.is_err();\n }\n\n Ok(): T {\n return this.unwrap();\n }\n Err(): E {\n return this.unwrap_err();\n }\n\n abstract is_ok(): boolean;\n abstract is_err(): boolean;\n abstract unwrap(): T;\n abstract unwrap_err(): E;\n}\n\nexport class ResultOK<T> extends Result<T, Error> {\n private _t: T;\n constructor(t: T) {\n super();\n this._t = t;\n }\n is_ok(): boolean {\n return true;\n }\n is_err(): boolean {\n return false;\n }\n unwrap_err(): Error {\n throw new Error(\"Result is Ok\");\n }\n unwrap(): T {\n return this._t;\n }\n}\n\nexport class ResultError<T extends Error> extends Result<never, T> {\n private _error: T;\n constructor(t: T) {\n super();\n this._error = t;\n }\n is_ok(): boolean {\n return false;\n }\n is_err(): boolean {\n return true;\n }\n unwrap(): never {\n throw new Error(`Result is Err: ${this._error}`);\n }\n unwrap_err(): T {\n return this._error;\n }\n}\n\nexport type WithoutResult<T> = T extends Result<infer U> ? U : T;\n\n/*\n\ntype FinalizedResult<T> = {\n result: T;\n scopeResult?: Result<void>;\n finally: () => Promise<void>;\n}\n\ntype exection2ResultParam<T> = {\n init: () => Promise<T>;\n inScope?: (t: T) => Promise<void>;\n cleanup: (t: T) => Promise<void>;\n\n}\n\nasync function expection2Result<T>({fn, inScope, cleanup}: exection2ResultParam<T>): Promise<Result<FinalizedResult<T>>> {\n try {\n const res = await fn();\n if (inScope) {\n try {\n await inScope?.(res)\n } catch (err) {\n return Result.Err(err as Error)\n }\n await cleanup(res)\n return Result.Ok({\n result: res,\n finally: async () => { }\n })\n }\n return Result.Ok({\n result: res ,\n finally: async () => {\n return cleanup(res)\n }\n })\n } catch (err) {\n return Result.Err(err as Error)\n }\n}\n*/\n\n// await expection2Result({\n// init: openDB,\n// inScope: (res) => {\n// res.query()\n// },\n// cleanup: async (y) => {\n// await y.close()\n// }\n// })\n// async function openDB() {\n// try {\n// const opendb = await openDB()\n// return Result.Ok({\n// openDB,\n// finally: async () => {\n// await opendb.close()\n// }})\n// } catch (err) {\n// return Result.Err(err)\n// }\n// }\n// }\n","export abstract class Option<T> {\n static Some<T>(t: T): Option<T> {\n return new Some(t);\n }\n\n static None<T>(): Option<T> {\n return new None();\n }\n\n static Is<T>(t: unknown): t is Option<T> {\n return t instanceof Option;\n }\n\n IsNone(): boolean {\n return this.is_none();\n }\n\n IsSome(): boolean {\n return this.is_some();\n }\n Unwrap(): T {\n return this.unwrap();\n }\n\n abstract is_none(): boolean;\n abstract is_some(): boolean;\n abstract unwrap(): T;\n}\n\nexport class Some<T> extends Option<T> {\n private _t: T;\n constructor(_t: T) {\n super();\n this._t = _t;\n }\n\n is_none(): boolean {\n return false;\n }\n is_some(): boolean {\n return true;\n }\n unwrap(): T {\n return this._t;\n }\n}\n\nexport class None<T> extends Option<T> {\n is_none(): boolean {\n return true;\n }\n is_some(): boolean {\n return false;\n }\n unwrap(): T {\n throw new Error(\"None.unwrap\");\n }\n}\n\nexport type WithoutOption<T> = T extends Option<infer U> ? U : T;\n","export interface CTJsonWebKey {\n alg?: string;\n crv?: string;\n d?: string;\n dp?: string;\n dq?: string;\n e?: string;\n ext?: boolean;\n k?: string;\n key_ops?: string[];\n kty?: string;\n n?: string;\n oth?: RsaOtherPrimesInfo[];\n p?: string;\n q?: string;\n qi?: string;\n use?: string;\n x?: string;\n y?: string;\n}\n\nexport type CTKeyFormat = \"jwk\" | \"pkcs8\" | \"raw\" | \"spki\";\nexport type CTKeyUsage = \"decrypt\" | \"deriveBits\" | \"deriveKey\" | \"encrypt\" | \"sign\" | \"unwrapKey\" | \"verify\" | \"wrapKey\";\n\nexport interface CTAlgorithm {\n name: string;\n}\nexport type CTAlgorithmIdentifier = CTAlgorithm | string;\n\nexport interface CTRsaHashedImportParams extends CTAlgorithm {\n hash: CTAlgorithmIdentifier;\n}\n\nexport type CTNamedCurve = string;\nexport interface CTEcKeyImportParams extends CTAlgorithm {\n namedCurve: CTNamedCurve;\n}\n\nexport interface CTHmacImportParams extends CTAlgorithm {\n hash: CTAlgorithmIdentifier;\n length?: number;\n}\n\nexport interface CTAesKeyAlgorithm extends CTAlgorithm {\n length: number;\n}\n\nexport type CTKeyType = \"private\" | \"public\" | \"secret\";\n\nexport interface CTCryptoKey {\n /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/algorithm) */\n readonly algorithm: CTAlgorithm;\n /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/extractable) */\n readonly extractable: boolean;\n /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/type) */\n readonly type: CTKeyType;\n /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/usages) */\n readonly usages: CTKeyUsage[];\n}\n\ninterface CTArrayBufferTypes {\n ArrayBuffer: ArrayBuffer;\n}\ntype CTArrayBufferLike = CTArrayBufferTypes[keyof CTArrayBufferTypes];\n\nexport interface CTArrayBufferView {\n /**\n * The ArrayBuffer instance referenced by the array.\n */\n buffer: CTArrayBufferLike;\n\n /**\n * The length in bytes of the array.\n */\n byteLength: number;\n\n /**\n * The offset in bytes of the array.\n */\n byteOffset: number;\n}\n\nexport type CTBufferSource = CTArrayBufferView | ArrayBuffer;\n\nexport interface CryptoRuntime {\n importKey(\n format: CTKeyFormat,\n keyData: CTJsonWebKey | CTBufferSource,\n algorithm: CTAlgorithmIdentifier | CTRsaHashedImportParams | CTEcKeyImportParams | CTHmacImportParams | CTAesKeyAlgorithm,\n extractable: boolean,\n keyUsages: CTKeyUsage[],\n ): Promise<CTCryptoKey>;\n\n //(format: \"raw\", key: ArrayBuffer, algo: string, extractable: boolean, usages: string[]) => Promise<CryptoKey>;\n decrypt(algo: { name: string; iv: Uint8Array; tagLength: number }, key: CTCryptoKey, data: Uint8Array): Promise<ArrayBuffer>;\n encrypt(algo: { name: string; iv: Uint8Array; tagLength: number }, key: CTCryptoKey, data: Uint8Array): Promise<ArrayBuffer>;\n digestSHA256(data: Uint8Array): Promise<ArrayBuffer>;\n randomBytes(size: number): Uint8Array;\n}\n\nfunction randomBytes(size: number) {\n const bytes = new Uint8Array(size);\n if (size > 0) {\n crypto.getRandomValues(bytes);\n }\n return bytes;\n}\n\nfunction digestSHA256(data: Uint8Array): Promise<ArrayBuffer> {\n return Promise.resolve(crypto.subtle.digest(\"SHA-256\", data));\n}\n\nexport function toCryptoRuntime(cryptoOpts: Partial<CryptoRuntime> = {}): CryptoRuntime {\n const runtime = {\n importKey: cryptoOpts.importKey || crypto.subtle.importKey.bind(crypto.subtle),\n encrypt: cryptoOpts.encrypt || crypto.subtle.encrypt.bind(crypto.subtle),\n decrypt: cryptoOpts.decrypt || crypto.subtle.decrypt.bind(crypto.subtle),\n randomBytes: cryptoOpts.randomBytes || randomBytes,\n digestSHA256: cryptoOpts.digestSHA256 || digestSHA256,\n };\n // console.log(\"cryptoOpts\", cryptoOpts, opts)\n return runtime;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,IAAK,QAAL,kBAAKA,WAAL;AACL,EAAAA,OAAA,UAAO;AACP,EAAAA,OAAA,WAAQ;AACR,EAAAA,OAAA,UAAO;AACP,EAAAA,OAAA,WAAQ;AAJE,SAAAA;AAAA,GAAA;AAUL,IAAM,WAAN,MAAe;AAAA,EACpB,YAAqB,IAAkB;AAAlB;AAAA,EAAmB;AAAA,EACxC,QAAmC;AACjC,WAAO,KAAK,GAAG;AAAA,EACjB;AAAA,EACA,SAAoC;AAClC,WAAO,KAAK,MAAM;AAAA,EACpB;AACF;AAIO,SA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