@adviser/cement 0.4.3 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{chunk-FZHQTSQU.js → chunk-Z724JFU6.js} +80 -9
- package/chunk-Z724JFU6.js.map +1 -0
- package/{index-BpBCVun3.d.cts → index-BJwthmNK.d.cts} +10 -2
- package/{index-Dnurrov8.d.ts → index-Bh_2ZgIk.d.ts} +10 -2
- package/index.cjs +93 -14
- package/index.cjs.map +1 -1
- package/index.d.cts +2 -2
- package/index.d.ts +2 -2
- package/index.js +15 -7
- package/index.js.map +1 -1
- package/metafile-cjs.json +1 -1
- package/metafile-esm.json +1 -1
- package/package.json +1 -1
- package/src/jsr.json +1 -1
- package/src/path-ops.ts +21 -6
- package/src/uri.ts +93 -9
- package/test/index.cjs +79 -8
- package/test/index.cjs.map +1 -1
- package/test/index.d.cts +1 -1
- package/test/index.d.ts +1 -1
- package/test/index.js +1 -1
- package/ts/src/path-ops.d.ts.map +1 -1
- package/ts/src/path-ops.js +17 -6
- package/ts/src/path-ops.js.map +1 -1
- package/ts/src/path-ops.test.js +20 -4
- package/ts/src/path-ops.test.js.map +1 -1
- package/ts/src/uri.d.ts +10 -2
- package/ts/src/uri.d.ts.map +1 -1
- package/ts/src/uri.js +79 -5
- package/ts/src/uri.js.map +1 -1
- package/ts/src/uri.test.js +97 -0
- package/ts/src/uri.test.js.map +1 -1
- package/chunk-FZHQTSQU.js.map +0 -1
@@ -623,6 +623,15 @@ function coerceKey(key, def) {
|
|
623
623
|
}
|
624
624
|
return { key, def };
|
625
625
|
}
|
626
|
+
function resolveHash(hash) {
|
627
|
+
const searchParams = new URLSearchParams(hash.replace(/^#/, ""));
|
628
|
+
return {
|
629
|
+
getParam: (k) => {
|
630
|
+
const ret = searchParams.get(k);
|
631
|
+
return ret === null ? void 0 : ret;
|
632
|
+
}
|
633
|
+
};
|
634
|
+
}
|
626
635
|
function falsy2undef(value) {
|
627
636
|
return value === void 0 || value === null ? void 0 : value;
|
628
637
|
}
|
@@ -645,6 +654,7 @@ function isURL(value) {
|
|
645
654
|
}
|
646
655
|
var customInspectSymbol = Symbol.for("nodejs.util.inspect.custom");
|
647
656
|
var MutableURL = class _MutableURL extends URL {
|
657
|
+
// override readonly hash: string;
|
648
658
|
constructor(urlStr) {
|
649
659
|
super("defect://does.not.exist");
|
650
660
|
const partedURL = urlStr.split(":");
|
@@ -667,7 +677,6 @@ var MutableURL = class _MutableURL extends URL {
|
|
667
677
|
} else {
|
668
678
|
this._pathname = urlStr.replace(new RegExp(`^${this._protocol}//`), "").replace(/[#?].*$/, "");
|
669
679
|
}
|
670
|
-
this.hash = this._sysURL.hash;
|
671
680
|
}
|
672
681
|
[customInspectSymbol]() {
|
673
682
|
return this.toString();
|
@@ -722,16 +731,26 @@ var MutableURL = class _MutableURL extends URL {
|
|
722
731
|
}
|
723
732
|
this._protocol = p;
|
724
733
|
}
|
734
|
+
get hash() {
|
735
|
+
return this._sysURL.hash;
|
736
|
+
}
|
737
|
+
set hash(h) {
|
738
|
+
this._sysURL.hash = h;
|
739
|
+
}
|
725
740
|
get searchParams() {
|
726
741
|
return this._sysURL.searchParams;
|
727
742
|
}
|
728
|
-
|
743
|
+
get search() {
|
729
744
|
let search = "";
|
730
745
|
if (this._sysURL.searchParams.size) {
|
731
746
|
for (const [key, value] of Array.from(this._sysURL.searchParams.entries()).sort((a, b) => a[0].localeCompare(b[0]))) {
|
732
747
|
search += `${!search.length ? "?" : "&"}${key}=${encodeURIComponent(value)}`;
|
733
748
|
}
|
734
749
|
}
|
750
|
+
return search;
|
751
|
+
}
|
752
|
+
toString() {
|
753
|
+
const search = this.search;
|
735
754
|
let hostpart = "";
|
736
755
|
if (this._hasHostpart) {
|
737
756
|
hostpart = this._sysURL.hostname;
|
@@ -742,7 +761,7 @@ var MutableURL = class _MutableURL extends URL {
|
|
742
761
|
hostpart += "/";
|
743
762
|
}
|
744
763
|
}
|
745
|
-
return `${this._protocol}//${hostpart}${this._pathname}${search}`;
|
764
|
+
return `${this._protocol}//${hostpart}${this._pathname}${search}${this.hash}`;
|
746
765
|
}
|
747
766
|
};
|
748
767
|
function from(fac, strURLUri, defaultProtocol) {
|
@@ -805,6 +824,10 @@ var BuildURI = class _BuildURI {
|
|
805
824
|
this._url.pathname = p;
|
806
825
|
return this;
|
807
826
|
}
|
827
|
+
hash(h) {
|
828
|
+
this._url.hash = h;
|
829
|
+
return this;
|
830
|
+
}
|
808
831
|
// could pass a relative path or a full URL
|
809
832
|
// if relative path, it will be appended to the current path
|
810
833
|
resolve(p) {
|
@@ -833,12 +856,51 @@ var BuildURI = class _BuildURI {
|
|
833
856
|
}
|
834
857
|
return this;
|
835
858
|
}
|
836
|
-
cleanParams() {
|
859
|
+
cleanParams(...remove) {
|
860
|
+
const keys = new Set(remove.flat());
|
837
861
|
for (const key of Array.from(this._url.searchParams.keys())) {
|
838
|
-
|
862
|
+
if (keys.size === 0 || keys.has(key)) {
|
863
|
+
this._url.searchParams.delete(key);
|
864
|
+
}
|
839
865
|
}
|
840
866
|
return this;
|
841
867
|
}
|
868
|
+
hashParams(val, mode = "reset") {
|
869
|
+
let preset;
|
870
|
+
switch (mode) {
|
871
|
+
case "reset":
|
872
|
+
this._url.hash = "";
|
873
|
+
preset = {};
|
874
|
+
break;
|
875
|
+
case "merge":
|
876
|
+
default:
|
877
|
+
preset = Object.fromEntries(new URLSearchParams(this._url.hash.replace(/^#/, "")).entries());
|
878
|
+
break;
|
879
|
+
}
|
880
|
+
const out = new URLSearchParams("");
|
881
|
+
for (const [key, value] of Object.entries({ ...preset, ...val }).sort((a, b) => a[0].localeCompare(b[0]))) {
|
882
|
+
switch (typeof value) {
|
883
|
+
case "string":
|
884
|
+
out.set(key, value);
|
885
|
+
break;
|
886
|
+
case "number":
|
887
|
+
out.set(key, value.toString());
|
888
|
+
break;
|
889
|
+
case "boolean":
|
890
|
+
out.set(key, value ? "true" : "false");
|
891
|
+
break;
|
892
|
+
default:
|
893
|
+
if (value instanceof Date) {
|
894
|
+
out.set(key, value.toISOString());
|
895
|
+
} else {
|
896
|
+
console.error(`unsupported type: ${typeof value} ignore key: ${key}`);
|
897
|
+
}
|
898
|
+
break;
|
899
|
+
}
|
900
|
+
}
|
901
|
+
this._url.hash = out.toString();
|
902
|
+
return this;
|
903
|
+
}
|
842
904
|
delParam(key) {
|
843
905
|
this._url.searchParams.delete(key);
|
844
906
|
return this;
|
@@ -873,6 +935,9 @@ var BuildURI = class _BuildURI {
|
|
873
935
|
getParamsResult(...keys) {
|
874
936
|
return getParamsResult(keys, this);
|
875
937
|
}
|
938
|
+
getHashParams(...keys) {
|
939
|
+
return getParamsResult(keys, resolveHash(this._url.hash));
|
940
|
+
}
|
876
941
|
toString() {
|
877
942
|
this._url.searchParams.sort();
|
878
943
|
return this._url.toString();
|
@@ -956,6 +1021,9 @@ var URI = class _URI {
|
|
956
1021
|
get hostname() {
|
957
1022
|
return this._url.hostname;
|
958
1023
|
}
|
1024
|
+
get local() {
|
1025
|
+
return this._url.pathname + this._url.search;
|
1026
|
+
}
|
959
1027
|
// get password(): string {
|
960
1028
|
// return this._url.password;
|
961
1029
|
// }
|
@@ -977,9 +1045,9 @@ var URI = class _URI {
|
|
977
1045
|
get pathname() {
|
978
1046
|
return this._url.pathname;
|
979
1047
|
}
|
980
|
-
|
981
|
-
|
982
|
-
|
1048
|
+
get hash() {
|
1049
|
+
return this._url.hash;
|
1050
|
+
}
|
983
1051
|
// get host(): string {
|
984
1052
|
// return this._url.host;
|
985
1053
|
// }
|
@@ -1003,6 +1071,9 @@ var URI = class _URI {
|
|
1003
1071
|
getParamsResult(...keys) {
|
1004
1072
|
return getParamsResult(keys, this);
|
1005
1073
|
}
|
1074
|
+
getHashParams(...keys) {
|
1075
|
+
return getParamsResult(keys, resolveHash(this._url.hash));
|
1076
|
+
}
|
1006
1077
|
clone() {
|
1007
1078
|
return new _URI(this._url);
|
1008
1079
|
}
|
@@ -1601,4 +1672,4 @@ export {
|
|
1601
1672
|
LogCollector,
|
1602
1673
|
MockLogger
|
1603
1674
|
};
|
1604
|
-
//# sourceMappingURL=chunk-
|
1675
|
+
//# sourceMappingURL=chunk-Z724JFU6.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/test/log-write-stream.ts","../../src/bin2text.ts","../../src/logger.ts","../../src/option.ts","../../src/log-level-impl.ts","../../src/logger-impl.ts","../../src/utils/relative-path.ts","../../src/uri.ts","../../src/log-writer-impl.ts","../../src/test/mock-logger.ts"],"sourcesContent":["import { FanoutWriteStream } from \"../utils/fanout-write-stream.js\";\nimport { Future } from \"../future.js\";\nimport { TxtEnDecoder, TxtEnDecoderSingleton } from \"../txt-en-decoder.js\";\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: Future<undefined> = 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 private readonly _txtEnDe: TxtEnDecoder;\n\n constructor(pass?: WritableStreamDefaultWriter<Uint8Array>, txtEnDe?: TxtEnDecoder) {\n this._pass = pass;\n this._txtEnDe = txtEnDe || TxtEnDecoderSingleton();\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<Uint8Array>[] = [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(notJsonLine = false): any[] {\n if (!this._writer) {\n return [];\n }\n const jsonNlStr = this._txtEnDe.decode(\n new Uint8Array(\n (function* (res: Uint8Array[]): Generator<number, void, undefined> {\n for (const x of res) {\n yield* x;\n }\n })(this._bufferArr),\n ),\n );\n if (!notJsonLine) {\n const splitStr = jsonNlStr.split(\"\\n\");\n const filterStr = splitStr.filter((a) => a.length);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n const mapStr = filterStr.map((a) => JSON.parse(a));\n return mapStr;\n }\n return jsonNlStr.split(\"\\n\").filter((a) => a.length);\n }\n}\n","export function bin2text(hex: ArrayBufferView, lineFn: (line: string) => void, size = 0): void {\n const arr = new Uint8Array(hex.buffer, hex.byteOffset, hex.byteLength);\n let cutted = \" \";\n if (size == 0) {\n size = arr.length;\n }\n size = Math.min(size, arr.length);\n const cols = 16;\n for (let line = 0; line < size; line += cols) {\n if (line + cols <= size || arr.length == size) {\n // normal line\n } else {\n line = arr.length - (arr.length % cols);\n size = arr.length;\n cutted = \">>\";\n }\n const l: string[] = [line.toString(16).padStart(4, \"0\"), cutted];\n for (let col = 0; col < cols; col++) {\n if (line + col < size) {\n l.push(arr[line + col].toString(16).padStart(2, \"0\"));\n } else {\n l.push(\" \");\n }\n // l.push((col > 0 && col % 4 === 3) ? \" \" : \" \");\n l.push(\" \");\n }\n for (let col = 0; col < cols; col++) {\n if (line + col < size) {\n const ch = arr[line + col];\n l.push(ch >= 32 && ch < 127 ? String.fromCharCode(ch) : \".\");\n }\n }\n lineFn(l.join(\"\"));\n }\n}\n\nexport function bin2string(hex: ArrayBufferView, size = 0): string {\n const collector: string[] = [];\n bin2text(\n hex,\n (line) => {\n collector.push(line);\n },\n size,\n );\n return collector.join(\"\\n\");\n}\n","import { isPromise } from \"./is-promise.js\";\nimport { bin2string } from \"./bin2text.js\";\nimport { Option } from \"./option.js\";\nimport { Result } from \"./result.js\";\nimport { TxtEnDecoder } from \"./txt-en-decoder.js\";\nimport { CoerceURI } from \"./uri.js\";\n\nexport const Level = {\n WARN: \"warn\",\n DEBUG: \"debug\",\n INFO: \"info\",\n ERROR: \"error\",\n};\n\nexport type Level = (typeof Level)[keyof typeof Level];\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 try {\n // console.log(\"LogValue.value\", this.fn.toString());\n return this.fn();\n } catch (e) {\n return `LogValue:${(e as Error).message}`;\n }\n }\n toJSON(): Serialized | Serialized[] {\n return this.value();\n }\n}\n\nexport type LogSerializable = Record<string, LogValue | Promise<LogValue>>;\n\n// export function sanitizeSerialize(lineEnd?: string): (key: unknown, val: unknown) => unknown {\n// const cache = new Set();\n// return function (this: unknown, 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 lineEnd ? value + lineEnd : 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 type LogValueArg = LogValue | Serialized | Serialized[] | FnSerialized | undefined | null;\n\nexport interface LogValueState {\n readonly state?: Set<unknown>;\n readonly ignoreAttr: Option<RegExp>;\n}\n\nexport function logValue(val: LogValueArg, ctx: LogValueState): LogValue {\n return logValueInternal(val, {\n ...ctx,\n state: ctx.state || new Set<unknown>([Math.random()]),\n });\n}\n\ntype LogValueStateInternal = LogValueState & { readonly state: Set<unknown> };\n\nfunction logValueInternal(val: LogValueArg, ctx: LogValueStateInternal): LogValue {\n ctx = {\n ...ctx,\n state: ctx.state || new Set<unknown>([Math.random()]),\n } satisfies LogValueStateInternal;\n switch (typeof val) {\n case \"function\":\n return new LogValue(val);\n case \"string\": {\n try {\n const ret = JSON.parse(val) as LogValueArg;\n if (typeof ret === \"object\" && ret !== null) {\n return logValueInternal(ret, ctx);\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (e) {\n try {\n const url = new URL(val);\n return new LogValue(() => url.toString());\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (e) {\n // ignore\n }\n }\n if (val.match(/[\\n\\r]/)) {\n const lines = val.split(/[\\n\\r]+/).map((v) => v.trim());\n return new LogValue(() => lines);\n }\n return new LogValue(() => val.toString());\n }\n case \"number\":\n return new LogValue(() => val);\n case \"boolean\":\n return new LogValue(() => val);\n case \"object\": {\n if (val === null) {\n return new LogValue(() => \"null\");\n }\n if (ArrayBuffer.isView(val)) {\n try {\n // should be injected\n const decoder = new TextDecoder();\n const asStr = decoder.decode(val);\n const obj = JSON.parse(asStr) as LogValueArg;\n return logValueInternal(obj, ctx);\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (e) {\n return logValueInternal(bin2string(val, 512), ctx);\n }\n }\n if (Array.isArray(val)) {\n return new LogValue(() =>\n (val as Serialized[]).map((v) => logValue(v, { ...ctx, state: undefined }).value() as Serialized),\n );\n }\n // if (val instanceof Response) {\n // // my = my.clone() as unknown as LogValue | Serialized[] | null\n // // const rval = my as unknown as Partial<Response>;\n // // delete rval.clone\n // // delete rval.blob\n // }\n if (val instanceof Headers) {\n return new LogValue(() => Object.fromEntries(val.entries()) as unknown as Serialized);\n }\n if (val instanceof ReadableStream) {\n return new LogValue(() => \">Stream<\");\n }\n if (isPromise(val)) {\n return new LogValue(() => \">Promise<\");\n }\n\n // Duplicate reference found, discard key\n if (ctx.state?.has(val)) {\n return new LogValue(() => \"...\");\n }\n ctx.state?.add(val);\n if (typeof val.toJSON === \"function\") {\n return new LogValue(() => val.toJSON());\n }\n\n const res: Record<string, LogValue> = {};\n const typedVal = val as unknown as Record<string, LogValueArg>;\n for (const key in typedVal) {\n if (ctx.ignoreAttr.IsSome() && ctx.ignoreAttr.unwrap().test(key)) {\n continue;\n }\n const element = typedVal[key];\n if (element instanceof LogValue) {\n res[key] = element;\n } else {\n if (typeof element !== \"function\") {\n res[key] = logValueInternal(element, ctx);\n }\n }\n }\n // ugly as hell cast but how declare a self-referencing type?\n return new LogValue(() => res as unknown as Serialized);\n }\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 LogFormatter {\n format(attr: LogSerializable): Uint8Array;\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 setIgnoreAttr(re?: RegExp): void;\n ignoreAttr: Option<RegExp>;\n isStackExposed: boolean;\n setDebug(...modules: (string | string[])[]): void;\n isEnabled(ilevel: unknown, module: unknown): boolean;\n}\n\nexport type HttpType = Response | Result<Response> | Request | Result<Request>;\n\nexport interface LoggerInterface<R> {\n readonly levelHandler: LevelHandler;\n TxtEnDe(): TxtEnDecoder;\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 Attributes(): Record<string, unknown>;\n\n SetDebug(...modules: (string | string[])[]): R;\n // default is /^_/\n SetIgnoreAttribute(re?: RegExp): R;\n SetExposeStack(enable?: boolean): R;\n SetFormatter(fmt: LogFormatter): 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<T extends string | Record<string, string>>(key: T, value?: T extends string ? string : undefined): R;\n Uint64<T extends string | Record<string, number>>(key: T, value?: T extends string ? number : undefined): R;\n Int<T extends string | Record<string, number>>(key: T, value?: T extends string ? number : undefined): R;\n Bool<T extends string | Record<string, unknown>>(key: T, value?: T extends string ? unknown : undefined): R;\n Any<T extends string | Record<string, unknown>>(key: T, value?: T extends string ? unknown : undefined): R;\n\n // first string is the key\n // first response is Response\n // first request is Request\n Http(...mix: (HttpType | string)[]): R;\n Pair(x: Record<string, unknown>): R;\n\n Error(): R;\n Warn(): R;\n Debug(): R;\n Log(): R;\n WithLevel(level: Level): R;\n\n Err<T>(err: T | Result<T> | Error): R; // could be Error, or something which coerces to string\n Info(): R;\n Timestamp(): R;\n Dur(key: string, nsec: number): 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 .map((fn) => typeof (obj as Record<string, unknown>)[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 ResultError<T>(): Result<T>;\n}\n\nexport interface Logger extends LoggerInterface<Logger> {\n With(): WithLogger;\n\n Msg(...args: string[]): AsError;\n Flush(): Promise<void>;\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 static From<T>(t?: T): Option<T> {\n if (!t) {\n return new None();\n }\n return new Some(t);\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","import { LevelHandler, Level } from \"./logger.js\";\nimport { Option } from \"./option.js\";\n\nexport class LevelHandlerImpl implements LevelHandler {\n readonly _globalLevels: Set<Level> = new Set<Level>([Level.INFO, Level.ERROR, Level.WARN]);\n readonly _modules: Map<string, Set<Level>> = new Map<string, Set<Level>>();\n\n ignoreAttr: Option<RegExp> = Option.Some(/^_/);\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 setIgnoreAttr(re?: RegExp): void {\n this.ignoreAttr = Option.From(re);\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 function LevelHandlerSingleton(): LevelHandler {\n return levelSingleton;\n}\n","// import { v4 } from \"uuid\";\nimport YAML from \"yaml\";\nimport {\n AsError,\n FnSerialized,\n LogSerializable,\n Level,\n Logger,\n logValue,\n Serialized,\n WithLogger,\n // sanitizeSerialize,\n Sized,\n Lengthed,\n LogValue,\n LevelHandler,\n LogFormatter,\n LogValueArg,\n HttpType,\n LogValueState,\n} from \"./logger.js\";\nimport { BasicSysAbstraction } from \"./sys-abstraction.js\";\nimport { Result } from \"./result.js\";\nimport { CoerceURI, URI } from \"./uri.js\";\nimport { TxtEnDecoder, TxtEnDecoderSingleton } from \"./txt-en-decoder.js\";\nimport { LevelHandlerSingleton } from \"./log-level-impl.js\";\nimport { BasicSysAbstractionFactory } from \"./base-sys-abstraction.js\";\nimport { LogWriterStream } from \"./log-writer-impl.js\";\n\nfunction getLen(value: unknown, lvs: LogValueState): LogValue {\n if (Array.isArray(value)) {\n return logValue(() => value.length, lvs);\n } else if (typeof value === \"string\") {\n return logValue(() => value.length, lvs);\n } else if (typeof value === \"object\" && value !== null) {\n if (typeof (value as Sized).size === \"number\") {\n return logValue(() => (value as Sized).size, lvs);\n } else if (typeof (value as Lengthed).length === \"number\") {\n return logValue(() => (value as Lengthed).length, lvs);\n }\n return logValue(() => Object.keys(value).length, lvs);\n }\n return logValue(() => -1, lvs);\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 class JSONFormatter implements LogFormatter {\n private readonly _txtEnDe: TxtEnDecoder;\n private readonly _space?: number;\n constructor(txtEnde: TxtEnDecoder, space?: number) {\n this._txtEnDe = txtEnde;\n this._space = space;\n }\n format(attr: LogSerializable): Uint8Array {\n let ret: string;\n try {\n ret = JSON.stringify(attr, null, this._space);\n } catch (e) {\n ret = JSON.stringify({ internal: { message: (e as Error).message, stack: (e as Error).stack } });\n }\n return this._txtEnDe.encode(ret + \"\\n\");\n }\n}\n\nexport class YAMLFormatter implements LogFormatter {\n private readonly _txtEnDe: TxtEnDecoder;\n private readonly _space?: number;\n constructor(txtEnde: TxtEnDecoder, space?: number) {\n this._txtEnDe = txtEnde;\n this._space = space;\n }\n format(attr: LogSerializable): Uint8Array {\n return this._txtEnDe.encode(\"---\\n\" + YAML.stringify(attr, null, this._space) + \"\\n\");\n }\n}\n\nexport interface LoggerImplParams {\n readonly out?: WritableStream<Uint8Array>;\n readonly logWriter?: LogWriterStream;\n readonly sys?: BasicSysAbstraction;\n readonly withAttributes?: LogSerializable;\n readonly levelHandler?: LevelHandler;\n readonly txtEnDe?: TxtEnDecoder;\n readonly formatter?: LogFormatter;\n}\n\nfunction toLogValueCtx(lvh: LevelHandler): LogValueState {\n return {\n ignoreAttr: lvh.ignoreAttr,\n };\n}\n\nexport class LoggerImpl implements Logger {\n readonly _sys: BasicSysAbstraction;\n readonly _attributes: LogSerializable = {};\n readonly _withAttributes: LogSerializable;\n readonly _logWriter: LogWriterStream;\n readonly levelHandler: LevelHandler;\n readonly _txtEnDe: TxtEnDecoder;\n _formatter: LogFormatter;\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 = BasicSysAbstractionFactory();\n } else {\n this._sys = params.sys;\n }\n if (!params.txtEnDe) {\n this._txtEnDe = TxtEnDecoderSingleton();\n } else {\n this._txtEnDe = params.txtEnDe;\n }\n if (!params.formatter) {\n this._formatter = new JSONFormatter(this._txtEnDe);\n } else {\n this._formatter = params.formatter;\n }\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 || rt.isDeno || rt.isCFWorker) {\n // stream = this._sys.Stdout();\n // } else {\n // throw new Error(\"No output defined for runtime\");\n // }\n // }\n this._logWriter = new LogWriterStream(this._sys.Stdout());\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 = LevelHandlerSingleton();\n }\n // console.log(\"LoggerImpl\", this._id, this._attributes, this._withAttributes)\n }\n\n TxtEnDe(): TxtEnDecoder {\n return this._txtEnDe;\n }\n\n Attributes(): Record<string, unknown> {\n return JSON.parse(JSON.stringify(this._attributes, null)) as Record<string, unknown>;\n // return Array.from(Object.entries(this._attributes)).reduce(\n // (acc, [key, value]) => {\n // if (value instanceof LogValue) {\n // acc[key] = value.value();\n // }\n // return acc;\n // },\n // {} as Record<string, unknown>,\n // );\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, toLogValueCtx(this.levelHandler));\n this._withAttributes[\"module\"] = logValue(key, toLogValueCtx(this.levelHandler));\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 SetIgnoreAttribute(re?: RegExp): Logger {\n this.levelHandler.setIgnoreAttr(re);\n return this;\n }\n\n SetFormatter(formatter: LogFormatter): Logger {\n this._formatter = formatter;\n return this;\n }\n\n Timestamp(): Logger {\n this._attributes[\"ts\"] = logValue(() => this._sys.Time().Now().toISOString(), toLogValueCtx(this.levelHandler));\n return this;\n }\n Warn(): Logger {\n this._attributes[\"level\"] = logValue(Level.WARN, toLogValueCtx(this.levelHandler));\n return this;\n }\n Log(): Logger {\n return this;\n }\n Debug(): Logger {\n this._attributes[\"level\"] = logValue(Level.DEBUG, toLogValueCtx(this.levelHandler));\n return this;\n }\n Error(): Logger {\n this._attributes[\"level\"] = logValue(Level.ERROR, toLogValueCtx(this.levelHandler));\n return this;\n }\n Info(): Logger {\n this._attributes[\"level\"] = logValue(Level.INFO, toLogValueCtx(this.levelHandler));\n return this;\n }\n Err<T>(err: T | Result<T> | Error): Logger {\n let key = \"error\";\n if (Result.Is(err)) {\n if (err.isOk()) {\n key = \"noerror\";\n err = err.Ok();\n } else {\n err = err.Err();\n }\n }\n if (err instanceof Error) {\n if (err.cause) {\n this.coerceKey(key, {\n message: err.message,\n cause: err.cause,\n });\n } else {\n this._attributes[key] = logValue(err.message, toLogValueCtx(this.levelHandler));\n }\n if (this.levelHandler.isStackExposed) {\n this._attributes[\"stack\"] = logValue(\n err.stack?.split(/[\\r\\n]+/).map((s) => s.trim()),\n toLogValueCtx(this.levelHandler),\n );\n }\n } else {\n this.Any(key, err as LogSerializable);\n }\n return this;\n }\n WithLevel(l: Level): Logger {\n this._attributes[\"level\"] = logValue(l, toLogValueCtx(this.levelHandler));\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, toLogValueCtx(this.levelHandler));\n } else if (typeof action.toString === \"function\") {\n this._attributes[key] = logValue(() => action.toString(), toLogValueCtx(this.levelHandler));\n } else {\n this._attributes[key] = logValue(\"INVALID REF\", toLogValueCtx(this.levelHandler));\n }\n return this;\n }\n Bool(key: string | Record<string, unknown>, value: unknown): Logger {\n this.coerceKey(key, !!value);\n // this._attributes[key] = logValue(!!value);\n return this;\n }\n\n Http(...mix: (HttpType | string)[]): Logger {\n const key: string | undefined = mix.find((x) => typeof x === \"string\");\n mix = mix.filter((x) => typeof x !== \"string\");\n const resErrors = mix.filter((x) => Result.Is(x) && x.isErr()) as Result<unknown, Error>[];\n if (resErrors.length) {\n this.Err(resErrors.map((x) => x.Err().message).join(\"\\n\"));\n return this;\n }\n const req = mix\n .map((reqOrResult) => (Result.Is(reqOrResult) ? reqOrResult.Ok() : reqOrResult))\n .find((req) => typeof (req as Response).status !== \"number\") as Request | undefined;\n const res = mix\n .map((resOrResult) => (Result.Is(resOrResult) ? resOrResult.Ok() : resOrResult))\n .find((res) => typeof (res as Response).status === \"number\") as Response | undefined;\n let reqAndOrres: { res: Response; req: Request } | Response | Request | undefined;\n if (res && req) {\n reqAndOrres = { res, req };\n } else if (!res && !req) {\n reqAndOrres = undefined;\n } else if (res) {\n reqAndOrres = res;\n } else if (req) {\n reqAndOrres = req;\n }\n if (reqAndOrres) {\n this.Any(key || \"Http\", reqAndOrres as unknown as LogSerializable);\n }\n return this;\n }\n Pair(x: Record<string, unknown>): Logger {\n for (const key of Object.keys(x)) {\n const value = x[key];\n if (value instanceof LogValue) {\n this._attributes[key] = value;\n continue;\n }\n if (Result.Is(value)) {\n this.Result(key, value);\n continue;\n }\n this.Any(key, value as LogSerializable);\n }\n return this;\n }\n\n Result<T>(key: string, res: Result<T, Error>): Logger {\n if (res.isOk()) {\n this._attributes[key] = logValue(res.Ok() as Serialized, toLogValueCtx(this.levelHandler));\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, toLogValueCtx(this.levelHandler));\n return this;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n Hash(value: unknown, key = \"hash\"): Logger {\n throw new Error(\"Not implemented\");\n // this._attributes[key] = asyncLogValue(\n // async () => `${getLen(value, toLogValueCtx(this.levelHandler)).value()}:${await hash(value)}`,\n // );\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 private coerceKey(key: string | Record<string, unknown>, value?: unknown): void {\n if (typeof key === \"string\") {\n this._attributes[key] = logValue(value as LogValueArg, toLogValueCtx(this.levelHandler));\n } else {\n this.Pair(key);\n }\n }\n\n Str(key: string | Record<string, string>, value?: string): Logger {\n this.coerceKey(key, value);\n return this;\n }\n\n Any(key: string | Record<string, unknown>, value?: unknown): Logger {\n this.coerceKey(key, value);\n //this._attributes[coerceKey(key)] = logValue(value as LogValueArg);\n return this;\n }\n Dur(key: string, nsec: number): Logger {\n this._attributes[key] = logValue(`${nsec}ms`, toLogValueCtx(this.levelHandler));\n // new Intl.DurationFormat(\"en\", { style: \"narrow\" }).format(nsec);\n return this;\n }\n Uint64(key: string | Record<string, number>, value?: number): Logger {\n this.coerceKey(key, value);\n //this._attributes[coerceKey(key)] = logValue(value);\n return this;\n }\n Int(key: string | Record<string, number>, 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 formatter: this._formatter,\n withAttributes: {\n module: this._attributes[\"module\"],\n ...this._withAttributes,\n },\n }),\n );\n }\n\n _resetAttributes(fn: () => () => Uint8Array): () => Uint8Array {\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\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 this._attributes[\"msg\"] = logValue(args.join(\" \"), toLogValueCtx(this.levelHandler));\n const msg = this._attributes[\"msg\"].value();\n if (typeof msg === \"string\" && !msg.trim().length) {\n delete this._attributes[\"msg\"];\n }\n let fnRet = (): Uint8Array => this._formatter.format({ ...this._attributes });\n if (doWrite) {\n const encoded = fnRet();\n this._logWriter.write(encoded);\n fnRet = (): Uint8Array => encoded;\n }\n return fnRet;\n });\n const asError = (): Error => new Error(this._txtEnDe.decode(fnError()));\n return {\n ResultError: () => Result.Err(asError()),\n AsError: asError,\n };\n }\n}\n\nclass WithLoggerBuilder implements WithLogger {\n readonly _li: LoggerImpl;\n readonly levelHandler: LevelHandler;\n constructor(li: LoggerImpl) {\n this._li = li;\n this.levelHandler = li.levelHandler;\n }\n\n TxtEnDe(): TxtEnDecoder {\n return this._li.TxtEnDe();\n }\n\n Logger(): Logger {\n Object.assign(this._li._withAttributes, this._li._attributes);\n return this._li;\n }\n\n Attributes(): Record<string, unknown> {\n return { ...this._li._attributes };\n }\n\n SetExposeStack(enable?: boolean): WithLogger {\n this._li.levelHandler.setExposeStack(enable);\n return this;\n }\n\n SetIgnoreAttribute(re?: RegExp): WithLogger {\n this._li.levelHandler.setIgnoreAttr(re);\n return this;\n }\n\n SetFormatter(fmt: LogFormatter): WithLogger {\n this._li.SetFormatter(fmt);\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 Http(...mix: (HttpType | string)[]): WithLogger {\n this._li.Http(...mix);\n return this;\n }\n Pair(x: Record<string, unknown>): WithLogger {\n this._li.Pair(x);\n return this;\n }\n\n Str(key: string | Record<string, 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 | Record<string, unknown>, 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: CoerceURI, key?: string): WithLogger {\n this._li.Url(url, key);\n return this;\n }\n Int(key: string | Record<string, number>, 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.Timestamp();\n return this;\n }\n Any<T>(key: string | Record<string, unknown>, value?: T | 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 | Record<string, number>, value?: number): WithLogger {\n this._li.Uint64(key, value);\n return this;\n }\n}\n","export const PartType = {\n Slash: 0x1,\n Root: 0x3,\n Up: 0x4 /* /../ */,\n Noop: 0x8 /* ./ */,\n // RootUp = 0x8 /* ../ */,\n};\n\nexport type PartType = (typeof PartType)[keyof typeof PartType];\n\nexport type PathItem = string | PartType;\n\nexport class Path {\n readonly parts: PathItem[];\n constructor(parts: PathItem[] = []) {\n this.parts = parts;\n }\n\n toString(): string {\n return this.parts\n .map((part) => {\n if (typeof part === \"string\") {\n return part;\n } else {\n switch (part) {\n case PartType.Slash:\n case PartType.Root:\n return \"/\";\n case PartType.Up:\n return \"..\";\n default:\n return part;\n }\n }\n })\n .join(\"\");\n }\n\n add(part: PathItem): void {\n if (this.parts.includes(PartType.Root) && part === PartType.Root) {\n throw new Error(\"Cannot add absolute part to absolute path\");\n }\n const last = this.parts[this.parts.length - 1] as PartType;\n if (last & PartType.Slash && part === PartType.Slash) {\n return;\n }\n switch (part) {\n case \".\":\n this.parts.push(PartType.Noop);\n return;\n case \"..\":\n part = PartType.Up;\n }\n\n // if (part === PartType.Up && last === PartType.Slash) {\n // this.parts[this.parts.length - 1] = PartType.Up\n // return\n // }\n if (last === PartType.Noop && part === PartType.Slash) {\n if (last === PartType.Noop) {\n this.parts.pop();\n }\n return;\n }\n this.parts.push(part);\n }\n}\n\nexport function splitPath(path: string): Path {\n const p = new Path();\n if (path === \"\") {\n return p;\n }\n for (let count = 0; path.length; count++) {\n // const ipath = path\n if (path.match(/^\\/+/)) {\n if (count === 0) {\n p.add(PartType.Root);\n } else {\n p.add(PartType.Slash);\n }\n path = path.replace(/^\\/+/, \"\");\n } else {\n const part = path.replace(/\\/.*$/, \"\");\n p.add(part);\n path = path.replace(/^[^/]+/, \"\");\n }\n }\n return p;\n}\n\nexport function pathJoin(...paths: string[]): string {\n let prev = \"\";\n const res: string[] = [];\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\n for (let i = 0; i < paths.length; i++) {\n const path = paths[i];\n if (path === \"\") {\n continue;\n }\n // i + 1 !== paths.length &&\n if (!(prev.endsWith(\"/\") || path.startsWith(\"/\"))) {\n if (prev !== \"\") {\n res.push(\"/\");\n }\n res.push(path);\n } else {\n res.push(path);\n }\n prev = path;\n }\n return res.join(\"\");\n}\n\nexport function relativePath(path: string, relative: string): string {\n const relativeParts = splitPath(relative);\n let result: string;\n if (relativeParts.parts[0] === PartType.Root) {\n result = relative;\n } else {\n result = pathJoin(path, relative);\n }\n const unoptPath = splitPath(result);\n // console.log(\"What\", result, unoptPath.parts)\n const out: PathItem[] = [];\n let topUp = false;\n for (const part of unoptPath.parts) {\n switch (part) {\n case PartType.Root:\n out.push(PartType.Root);\n break;\n case PartType.Up:\n if (out.length && !topUp) {\n const last = out.length - 1;\n if (typeof out[last] === \"string\" && (out[last - 1] as PartType) == PartType.Root) {\n out.pop();\n } else {\n out.pop();\n out.pop();\n }\n if (out.length === 0) {\n topUp = !topUp ? true : topUp;\n out.push(PartType.Up);\n }\n } else {\n out.push(PartType.Up);\n }\n break;\n case PartType.Slash:\n if (!((out[out.length - 1] as PartType) & PartType.Slash)) {\n out.push(PartType.Slash);\n }\n break;\n default:\n out.push(part);\n break;\n }\n }\n return new Path(out).toString();\n // return pathParts\n // .filter((part, index) => part !== relativeParts[index])\n // .join(\"\")\n}\n","import type { DeepWritable } from \"ts-essentials\";\nimport { exception2Result, Result } from \"./result.js\";\nimport { getParamsResult, KeysParam } from \"./utils/get-params-result.js\";\nimport { relativePath } from \"./utils/relative-path.js\";\nimport { StripCommand, stripper } from \"./utils/stripper.js\";\n// import { param } from \"./types.js\";\n\ntype NullOrUndef = null | undefined;\n\ntype OneKey<K extends string, V = string> = Record<K, V>;\n\n/** @xdeprecated use param from get-params-result */\n// export const key = param;\n\n/*\n if KeyParam is a Object\n if the right side is a string, it is the default value\n if the right side is a !string | REQUIRED, it is required\n*/\n\n// type ReturnType<T extends (...args: KeysParam) => unknown> = T extends (...args: KeysParam) => infer R ? R : unknown;\n\n// function fetchData<T extends (...args: any[]) => Promise<any>>(fn: T): ReturnType<T> {\n// return fn();\n// }\n// type ReturnObject<T extends KeysParam> = {\n// [K in keyof T]: string;\n// };\n\nexport interface URIInterface<R extends URIInterface<R>> {\n // readonly hostname: string;\n // readonly port: string;\n // readonly host: string;\n // readonly protocol: string;\n // readonly pathname: string;\n readonly getParams: Iterable<[string, string]>;\n\n hasParam(key: string): boolean;\n getParam<T extends string | undefined>(key: string | OneKey<string>, def?: T): T extends string ? string : string | undefined;\n getParamResult(key: string, msgFn?: (key: string) => string): Result<string>;\n getParamsResult(...keys: KeysParam): Result<Record<string, string>>;\n match(other: CoerceURI): MatchResult;\n clone(): R;\n asURL(): URL;\n toString(): string;\n toJSON(): string;\n asObj(...strips: StripCommand[]): Partial<HostURIObject | PathURIObject>;\n}\n\nexport interface MatchResult {\n readonly score: number;\n readonly protocol: boolean;\n readonly hostname: boolean;\n readonly port: boolean;\n readonly pathname: boolean;\n readonly pathParts: string[];\n readonly params: Record<string, string>;\n}\n\nfunction match(iref: CoerceURI, ioth: CoerceURI): MatchResult {\n const mr: DeepWritable<MatchResult> = {\n score: 0,\n protocol: false,\n hostname: false,\n port: false,\n pathname: false,\n pathParts: [],\n params: {},\n };\n const ref = URI.from(iref);\n const oth = URI.from(ioth);\n if (ref.protocol === oth.protocol) {\n mr.score += 1;\n mr.protocol = true;\n }\n try {\n const refH = ref.hostname;\n const refP = ref.port;\n if (refH === oth.hostname) {\n mr.score += 1;\n mr.hostname = true;\n }\n if (refP.length && refP === oth.port) {\n mr.score += 1;\n mr.port = true;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (e) {\n // ignore\n }\n if (ref.pathname.length && ref.pathname !== \"/\") {\n const pref = ref.pathname.split(\"/\").filter((p) => p.length);\n const poth = oth.pathname.split(\"/\").filter((p) => p.length);\n for (let i = 0; i < pref.length && i < poth.length; i++) {\n if (poth[i] === pref[i]) {\n mr.score += 1;\n mr.pathname = true;\n mr.pathParts.push(pref[i]);\n }\n }\n }\n for (const [key, value] of ref.getParams) {\n if (oth.getParam(key) === value) {\n mr.score += 1;\n mr.params[key] = value;\n }\n }\n return mr;\n}\n\nfunction coerceKey(key: string | OneKey<string>, def?: string): { key: string; def?: string } {\n if (typeof key === \"object\") {\n const keys = Object.keys(key);\n if (keys.length !== 1) {\n throw new Error(`Invalid key: ${JSON.stringify(key)}`);\n }\n return { key: keys[0], def: key[keys[0]] };\n }\n return { key, def: def };\n}\n\nfunction resolveHash(hash: string): { getParam: (k: string) => string | undefined } {\n const searchParams = new URLSearchParams(hash.replace(/^#/, \"\"));\n return {\n getParam: (k): string | undefined => {\n const ret = searchParams.get(k);\n return ret === null ? undefined : ret;\n },\n };\n}\n\nexport interface URIObject {\n readonly style: \"host\" | \"path\";\n readonly protocol: string;\n readonly pathname: string;\n readonly searchParams: Record<string, string>;\n}\n\nexport interface PathURIObject extends URIObject {\n readonly style: \"path\";\n}\n\nexport interface HostURIObject extends URIObject {\n readonly style: \"host\";\n readonly hostname: string;\n readonly port: string;\n}\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): MutableURL {\n if (!url) {\n return new MutableURL(`${defaultProtocol}//`);\n }\n if (typeof url === \"string\") {\n try {\n return new MutableURL(url);\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (e) {\n return new MutableURL(`${defaultProtocol}//${url}`);\n }\n } else {\n return new MutableURL(url.toString());\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\n// due to that the System URL class is has a strange behavior\n// on different platforms, we need to implement our own URL class\nconst customInspectSymbol = Symbol.for(\"nodejs.util.inspect.custom\");\nexport class MutableURL extends URL {\n private readonly _sysURL: URL;\n // private readonly _urlStr: string;\n\n private _protocol: string;\n private _pathname: string;\n private _hasHostpart: boolean;\n\n // override readonly hash: string;\n\n constructor(urlStr: string) {\n super(\"defect://does.not.exist\");\n const partedURL = urlStr.split(\":\");\n this._hasHostpart = hasHostPartProtocols.has(partedURL[0]);\n let hostPartUrl = [\"http\", ...partedURL.slice(1)].join(\":\");\n if (!this._hasHostpart) {\n const pathname = hostPartUrl.replace(/http:\\/\\/[/]*/, \"\").replace(/[#?].*$/, \"\");\n hostPartUrl = hostPartUrl.replace(/http:\\/\\//, `http://localhost/${pathname}`);\n }\n try {\n this._sysURL = new URL(hostPartUrl);\n } catch (ie) {\n const e = ie as Error;\n e.message = `${e.message} for URL: ${urlStr}`;\n throw e;\n }\n this._protocol = `${partedURL[0]}:`; // this._sysURL.protocol.replace(new RegExp(\"^cement-\"), \"\");\n if (this._hasHostpart) {\n this._pathname = this._sysURL.pathname;\n } else {\n this._pathname = urlStr.replace(new RegExp(`^${this._protocol}//`), \"\").replace(/[#?].*$/, \"\");\n }\n // this.hash = this._sysURL.hash;\n }\n\n [customInspectSymbol](): string {\n // make node inspect to show the URL and not crash if URI is not http/https/file\n return this.toString();\n }\n\n clone(): MutableURL {\n return new MutableURL(this.toString());\n }\n\n override get host(): string {\n if (!this._hasHostpart) {\n throw new Error(\n `you can use hostname only if protocol is ${this.toString()} ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`,\n );\n }\n return this._sysURL.host;\n }\n\n override get port(): string {\n if (!this._hasHostpart) {\n throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);\n }\n return this._sysURL.port;\n }\n\n override set port(p: string) {\n if (!this._hasHostpart) {\n throw new Error(`you can use port only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);\n }\n this._sysURL.port = p;\n }\n\n override get hostname(): string {\n if (!this._hasHostpart) {\n throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);\n }\n return this._sysURL.hostname;\n }\n\n override set hostname(h: string) {\n if (!this._hasHostpart) {\n throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);\n }\n this._sysURL.hostname = h;\n }\n\n override set pathname(p: string) {\n this._pathname = p;\n }\n\n override get pathname(): string {\n return this._pathname;\n }\n\n override get protocol(): string {\n return this._protocol;\n }\n\n override set protocol(p: string) {\n if (!p.endsWith(\":\")) {\n p = `${p}:`;\n }\n this._protocol = p;\n }\n\n override get hash(): string {\n return this._sysURL.hash;\n }\n\n override set hash(h: string) {\n this._sysURL.hash = h;\n }\n\n override get searchParams(): URLSearchParams {\n return this._sysURL.searchParams;\n }\n\n override get search(): string {\n let search = \"\";\n if (this._sysURL.searchParams.size) {\n for (const [key, value] of Array.from(this._sysURL.searchParams.entries()).sort((a, b) => a[0].localeCompare(b[0]))) {\n search += `${!search.length ? \"?\" : \"&\"}${key}=${encodeURIComponent(value)}`;\n }\n }\n return search;\n }\n\n override toString(): string {\n const search = this.search;\n let hostpart = \"\";\n if (this._hasHostpart) {\n hostpart = this._sysURL.hostname;\n if (this._sysURL.port) {\n hostpart += `:${this._sysURL.port}`;\n }\n if (!this._pathname.startsWith(\"/\")) {\n hostpart += \"/\";\n }\n }\n return `${this._protocol}//${hostpart}${this._pathname}${search}${this.hash}`;\n }\n}\n\nfunction from<T>(fac: (url: MutableURL) => T, strURLUri: CoerceURI | undefined, defaultProtocol: string): T {\n switch (typeof falsy2undef(strURLUri)) {\n case \"undefined\":\n return fac(new MutableURL(`${defaultProtocol}///`));\n case \"string\":\n return fac(ensureURLWithDefaultProto(strURLUri as string, defaultProtocol));\n case \"object\":\n if (BuildURI.is(strURLUri)) {\n return fac(new MutableURL(strURLUri._url.toString()));\n } else if (URI.is(strURLUri)) {\n return fac(new MutableURL(strURLUri._url.toString()));\n } else if (isURL(strURLUri)) {\n return fac(new MutableURL(strURLUri.toString()));\n }\n throw new Error(`unknown object type: ${strURLUri}`);\n default:\n throw new Error(`Invalid argument: ${typeof strURLUri}`);\n }\n}\n\nfunction getParamResult(\n key: string,\n val: string | undefined,\n msgFn: (key: string) => string = (key) => {\n return `missing parameter: ${key}`;\n },\n): Result<string> {\n if (val === undefined) {\n return Result.Err(msgFn(key));\n }\n return Result.Ok(val);\n}\n\nexport class BuildURI implements URIInterface<BuildURI> {\n _url: MutableURL; // pathname needs this\n private constructor(url: MutableURL) {\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 match(other: CoerceURI): MatchResult {\n return match(this.URI(), URI.from(other));\n }\n\n port(p: string): BuildURI {\n this._url.port = p;\n return this;\n }\n\n hostname(h: string): BuildURI {\n this._url.hostname = h;\n return this;\n }\n\n protocol(p: string): BuildURI {\n if (!p.endsWith(\":\")) {\n p = `${p}:`;\n }\n this._url.protocol = p;\n return this;\n }\n\n pathname(p: string): BuildURI {\n this._url.pathname = p;\n return this;\n }\n\n hash(h: string): BuildURI {\n this._url.hash = h;\n return this;\n }\n\n // could pass a relative path or a full URL\n // if relative path, it will be appended to the current path\n resolve(p: CoerceURI): BuildURI {\n if (!p) {\n return this;\n }\n if (typeof p === \"string\") {\n // relative path\n if (!p.match(/^[a-zA-Z0-9]+:/)) {\n if (p.startsWith(\"/\")) {\n this.pathname(p);\n return this;\n }\n return this.appendRelative(p);\n }\n }\n this._url = new MutableURL(p.toString());\n return this;\n }\n\n appendRelative(p: CoerceURI): BuildURI {\n const appendUrl = URI.from(p);\n const pathname = \"./\" + appendUrl.pathname;\n const basePath = this._url.pathname;\n /*\n * cases\n * pathname \"\" basePAth \"\" -> \"\"\n * pathname \"/\" basePath \"\" -> \"/\"\n * pathname \"\" basePath \"/\" -> \"/\"\n * pathname \"/\" basePath \"/\" -> \"/\"\n * pathname \"ab\" basePath \"\" -> \"/ab\"\n * pathname \"ab\" basePath \"/\" -> \"/ab\"\n * pathname \"ab\" basePath \"/ab/\" -> \"/ab/ab\"\n * pathname \"/ab/\" basePath \"/ab/\" -> \"/ab/ab/\"\n */\n this.pathname(relativePath(basePath, pathname));\n // if (pathname.startsWith(\"/\")) {\n // pathname = pathname.replace(/^\\//, \"\");\n // }\n // if (basePath.length > 0) {\n // basePath = basePath.replace(/\\/$/, \"\");\n // }\n // this.pathname(basePath + \"/\" + pathname);\n for (const [key, value] of appendUrl.getParams) {\n this.setParam(key, value);\n }\n return this;\n }\n\n cleanParams(...remove: (string | string[])[]): BuildURI {\n const keys = new Set(remove.flat());\n for (const key of Array.from(this._url.searchParams.keys())) {\n if (keys.size === 0 || keys.has(key)) {\n this._url.searchParams.delete(key);\n }\n }\n return this;\n }\n\n hashParams(\n val: Record<string, string | number | boolean | Date | null | undefined>,\n mode: \"reset\" | \"merge\" = \"reset\",\n ): BuildURI {\n let preset: Record<string, string>;\n switch (mode) {\n case \"reset\":\n this._url.hash = \"\";\n preset = {};\n break;\n case \"merge\":\n default:\n preset = Object.fromEntries(new URLSearchParams(this._url.hash.replace(/^#/, \"\")).entries());\n break;\n }\n const out = new URLSearchParams(\"\");\n for (const [key, value] of Object.entries({ ...preset, ...val }).sort((a, b) => a[0].localeCompare(b[0]))) {\n switch (typeof value) {\n case \"string\":\n out.set(key, value);\n break;\n case \"number\":\n out.set(key, value.toString());\n break;\n case \"boolean\":\n out.set(key, value ? \"true\" : \"false\");\n break;\n default:\n if (value instanceof Date) {\n out.set(key, value.toISOString());\n } else {\n // eslint-disable-next-line no-console\n console.error(`unsupported type: ${typeof value} ignore key: ${key}`);\n }\n break;\n }\n }\n this._url.hash = out.toString();\n return this;\n }\n\n delParam(key: string): BuildURI {\n this._url.searchParams.delete(key);\n return this;\n }\n\n defParam(key: string, str: string): BuildURI {\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): BuildURI {\n this._url.searchParams.set(key, str);\n return this;\n }\n\n hasParam(key: string): boolean {\n return this._url.searchParams.has(key);\n }\n\n get getParams(): Iterable<[string, string]> {\n return this._url.searchParams.entries();\n }\n\n getParam<T extends string | undefined>(key: string | OneKey<string>, def?: T): T extends string ? string : string | undefined {\n const { key: k, def: d } = coerceKey(key, def);\n let val = this._url.searchParams.get(k);\n if (!falsy2undef(val) && d) {\n val = d;\n }\n return falsy2undef(val) as T extends string ? string : string | undefined;\n }\n\n getParamResult(key: string, msgFn?: (key: string) => string): Result<string> {\n return getParamResult(key, this.getParam(key), msgFn);\n }\n\n getParamsResult(...keys: KeysParam): Result<Record<string, string>> {\n return getParamsResult(keys, this);\n }\n\n getHashParams(...keys: KeysParam): Result<Record<string, string>> {\n return getParamsResult(keys, resolveHash(this._url.hash));\n }\n\n toString(): string {\n this._url.searchParams.sort();\n return this._url.toString();\n }\n toJSON(): string {\n return this.toString();\n }\n\n asURL(): URL {\n return this.URI().asURL();\n }\n\n asObj(...strips: StripCommand[]): Partial<HostURIObject | PathURIObject> {\n return this.URI().asObj(...strips);\n }\n\n clone(): BuildURI {\n return BuildURI.from(this.toString());\n }\n\n URI(): URI {\n return URI.from(this._url);\n }\n}\n\nexport type CoerceURI = string | URI | MutableURL | URL | BuildURI | NullOrUndef;\n\nexport function isCoerceURI(value: unknown): value is CoerceURI {\n if (!value) {\n return false;\n }\n if (isURL(value)) {\n // includes MutableURL\n return true;\n }\n if (URI.is(value)) {\n return true;\n }\n if (BuildURI.is(value)) {\n return true;\n }\n if (typeof value === \"string\") {\n return true;\n }\n return false;\n}\n\nexport const hasHostPartProtocols: Set<string> = new Set<string>([\"http\", \"https\", \"ws\", \"wss\"]);\n\n// non mutable URL Implementation\nexport class URI implements URIInterface<URI> {\n static protocolHasHostpart(protocol: string): () => void {\n protocol = protocol.replace(/:$/, \"\");\n hasHostPartProtocols.add(protocol);\n return () => {\n hasHostPartProtocols.delete(protocol);\n };\n }\n\n match(other: CoerceURI): MatchResult {\n return match(this, other);\n }\n\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\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 static fromResult(strURLUri?: CoerceURI, defaultProtocol = \"file:\"): Result<URI> {\n return exception2Result(() => from((url) => new URI(url), strURLUri, defaultProtocol)) as Result<URI>;\n }\n\n readonly _url: MutableURL;\n private constructor(url: MutableURL) {\n this._url = url.clone();\n }\n\n build(): BuildURI {\n return BuildURI.from(this._url);\n }\n\n get hostname(): string {\n return this._url.hostname;\n }\n\n get local(): string {\n return this._url.pathname + this._url.search;\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 host(): string {\n return this._url.host;\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.pathname;\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\n getParam<T extends string | undefined>(key: string | OneKey<string>, def?: T): T extends string ? string : string | undefined {\n const { key: k, def: d } = coerceKey(key, def);\n let val = this._url.searchParams.get(k);\n if (!falsy2undef(val) && d) {\n val = d;\n }\n return falsy2undef(val) as T extends string ? string : string | undefined;\n }\n\n getParamResult(key: string, msgFn?: (key: string) => string): Result<string> {\n return getParamResult(key, this.getParam(key), msgFn);\n }\n\n getParamsResult(...keys: KeysParam): Result<Record<string, string>> {\n return getParamsResult(keys, this);\n }\n\n getHashParams(...keys: KeysParam): Result<Record<string, string>> {\n return getParamsResult(keys, resolveHash(this._url.hash));\n }\n\n clone(): URI {\n return new URI(this._url);\n }\n\n asURL(): URL {\n // const url = new URL(this._url.toString());\n // url.searchParams.sort();\n return this._url.clone() as unknown as URL;\n }\n\n toString(): string {\n // this._url.searchParams.sort();\n return this._url.toString();\n }\n toJSON(): string {\n return this.toString();\n }\n asObj(...strips: StripCommand[]): Partial<HostURIObject | PathURIObject> {\n const pathURI: PathURIObject = {\n style: \"path\",\n protocol: this.protocol,\n pathname: this.pathname,\n searchParams: Object.fromEntries(this.getParams),\n };\n if (hasHostPartProtocols.has(this.protocol.replace(/:$/, \"\"))) {\n return stripper(strips, {\n ...pathURI,\n style: \"host\",\n hostname: this.hostname,\n port: this.port,\n }) as Partial<HostURIObject>;\n }\n return stripper(strips, pathURI) as Partial<PathURIObject>;\n }\n}\n","export class LogWriterStream {\n readonly _out: WritableStream<Uint8Array>;\n readonly _toFlush: (() => Promise<void>)[] = [];\n\n readonly _id: number;\n\n constructor(out: WritableStream<Uint8Array>) {\n this._out = out;\n this._id = Math.random();\n // console.log(\">>>My:constructor:\", this._id);\n }\n\n write(encoded: Uint8Array): void {\n const my = async (): Promise<void> => {\n // const val = Math.random();\n // console.log(\">>>My:\", encoded)\n try {\n // console.log(\">>>My:getWriter:get:\", this._id);\n const writer = this._out.getWriter();\n await writer.ready;\n await writer.write(encoded);\n writer.releaseLock();\n // console.log(\">>>My:getWriter:release\", this._id);\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: (() => 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?.()\n .catch((e) => {\n // eslint-disable-next-line no-console\n console.error(\"Flush error:\", e);\n })\n .finally(() => {\n // console.log(\"<<<Msg:\", this._toFlush.length)\n this._flush(this._toFlush);\n });\n }\n}\n","import { LevelHandlerImpl } from \"../log-level-impl.js\";\nimport { Logger } from \"../logger.js\";\nimport { LoggerImpl } from \"../logger-impl.js\";\nimport { LogCollector } from \"./log-write-stream.js\";\nimport { BasicSysAbstraction } from \"../sys-abstraction.js\";\n\nexport interface MockLoggerReturn {\n readonly logger: Logger;\n readonly logCollector: LogCollector;\n}\n\nexport function MockLogger(params?: {\n readonly sys?: BasicSysAbstraction;\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"],"mappings":";;;;;;;;;;;;;;;;;AAIO,IAAM,iBAAN,MAAwE;AAAA,EAG7E,YAAY,WAAyB;AAIrC,SAAS,iBAAoC,IAAI,OAAkB;AACnE,SAAS,SAA6B,KAAK,eAAe,UAAU;AACpE,SAAS,cAA6B;AACtC,SAAS,QAA4B,QAAQ,QAAQ,MAAS;AAN5D,SAAK,aAAa;AAAA,EACpB;AAAA;AAAA,EAQA,MAAM,QAA6B;AACjC,UAAM,IAAI,MAAM,yBAAyB;AAAA,EAC3C;AAAA,EACA,MAAM,QAAuB;AAC3B,UAAM,KAAK;AACX,WAAO,QAAQ,QAAQ,MAAS;AAAA,EAClC;AAAA,EACA,cAAoB;AAAA,EAEpB;AAAA,EACA,MAAM,MAAM,OAAmC;AAC7C,QAAI,OAAO;AACT,WAAK,WAAW,KAAK,KAAK;AAAA,IAC5B;AACA,WAAO,QAAQ,QAAQ,MAAS;AAAA,EAClC;AACF;AAEO,IAAM,eAAN,MAAyD;AAAA,EAO9D,Y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A,IACL,KAAK,iCAAQ;AAAA,IACb,cAAc,IAAI,iBAAiB;AAAA,EACrC,CAAC,EACE,KAAK,EACL,OAAO,SAAS,CAAC,CAAC,EAClB,OAAO;AACV,MAAI,EAAC,iCAAQ,eAAc;AACzB,WAAO,SAAS,GAAG,QAAQ;AAAA,EAC7B;AACA,SAAO;AAAA,IACL,cAAc;AAAA,IACd;AAAA,EACF;AACF;","names":["e","key","from","req","res"]}
|
@@ -73,7 +73,6 @@ declare class MutableURL extends URL {
|
|
73
73
|
private _protocol;
|
74
74
|
private _pathname;
|
75
75
|
private _hasHostpart;
|
76
|
-
readonly hash: string;
|
77
76
|
constructor(urlStr: string);
|
78
77
|
[customInspectSymbol](): string;
|
79
78
|
clone(): MutableURL;
|
@@ -86,7 +85,10 @@ declare class MutableURL extends URL {
|
|
86
85
|
get pathname(): string;
|
87
86
|
get protocol(): string;
|
88
87
|
set protocol(p: string);
|
88
|
+
get hash(): string;
|
89
|
+
set hash(h: string);
|
89
90
|
get searchParams(): URLSearchParams;
|
91
|
+
get search(): string;
|
90
92
|
toString(): string;
|
91
93
|
}
|
92
94
|
declare class BuildURI implements URIInterface<BuildURI> {
|
@@ -99,9 +101,11 @@ declare class BuildURI implements URIInterface<BuildURI> {
|
|
99
101
|
hostname(h: string): BuildURI;
|
100
102
|
protocol(p: string): BuildURI;
|
101
103
|
pathname(p: string): BuildURI;
|
104
|
+
hash(h: string): BuildURI;
|
102
105
|
resolve(p: CoerceURI): BuildURI;
|
103
106
|
appendRelative(p: CoerceURI): BuildURI;
|
104
|
-
cleanParams(): BuildURI;
|
107
|
+
cleanParams(...remove: (string | string[])[]): BuildURI;
|
108
|
+
hashParams(val: Record<string, string | number | boolean | Date | null | undefined>, mode?: "reset" | "merge"): BuildURI;
|
105
109
|
delParam(key: string): BuildURI;
|
106
110
|
defParam(key: string, str: string): BuildURI;
|
107
111
|
setParam(key: string, str: string): BuildURI;
|
@@ -110,6 +114,7 @@ declare class BuildURI implements URIInterface<BuildURI> {
|
|
110
114
|
getParam<T extends string | undefined>(key: string | OneKey<string>, def?: T): T extends string ? string : string | undefined;
|
111
115
|
getParamResult(key: string, msgFn?: (key: string) => string): Result<string>;
|
112
116
|
getParamsResult(...keys: KeysParam): Result<Record<string, string>>;
|
117
|
+
getHashParams(...keys: KeysParam): Result<Record<string, string>>;
|
113
118
|
toString(): string;
|
114
119
|
toJSON(): string;
|
115
120
|
asURL(): URL;
|
@@ -131,15 +136,18 @@ declare class URI implements URIInterface<URI> {
|
|
131
136
|
private constructor();
|
132
137
|
build(): BuildURI;
|
133
138
|
get hostname(): string;
|
139
|
+
get local(): string;
|
134
140
|
get port(): string;
|
135
141
|
get host(): string;
|
136
142
|
get protocol(): string;
|
137
143
|
get pathname(): string;
|
144
|
+
get hash(): string;
|
138
145
|
get getParams(): Iterable<[string, string]>;
|
139
146
|
hasParam(key: string): boolean;
|
140
147
|
getParam<T extends string | undefined>(key: string | OneKey<string>, def?: T): T extends string ? string : string | undefined;
|
141
148
|
getParamResult(key: string, msgFn?: (key: string) => string): Result<string>;
|
142
149
|
getParamsResult(...keys: KeysParam): Result<Record<string, string>>;
|
150
|
+
getHashParams(...keys: KeysParam): Result<Record<string, string>>;
|
143
151
|
clone(): URI;
|
144
152
|
asURL(): URL;
|
145
153
|
toString(): string;
|
@@ -73,7 +73,6 @@ declare class MutableURL extends URL {
|
|
73
73
|
private _protocol;
|
74
74
|
private _pathname;
|
75
75
|
private _hasHostpart;
|
76
|
-
readonly hash: string;
|
77
76
|
constructor(urlStr: string);
|
78
77
|
[customInspectSymbol](): string;
|
79
78
|
clone(): MutableURL;
|
@@ -86,7 +85,10 @@ declare class MutableURL extends URL {
|
|
86
85
|
get pathname(): string;
|
87
86
|
get protocol(): string;
|
88
87
|
set protocol(p: string);
|
88
|
+
get hash(): string;
|
89
|
+
set hash(h: string);
|
89
90
|
get searchParams(): URLSearchParams;
|
91
|
+
get search(): string;
|
90
92
|
toString(): string;
|
91
93
|
}
|
92
94
|
declare class BuildURI implements URIInterface<BuildURI> {
|
@@ -99,9 +101,11 @@ declare class BuildURI implements URIInterface<BuildURI> {
|
|
99
101
|
hostname(h: string): BuildURI;
|
100
102
|
protocol(p: string): BuildURI;
|
101
103
|
pathname(p: string): BuildURI;
|
104
|
+
hash(h: string): BuildURI;
|
102
105
|
resolve(p: CoerceURI): BuildURI;
|
103
106
|
appendRelative(p: CoerceURI): BuildURI;
|
104
|
-
cleanParams(): BuildURI;
|
107
|
+
cleanParams(...remove: (string | string[])[]): BuildURI;
|
108
|
+
hashParams(val: Record<string, string | number | boolean | Date | null | undefined>, mode?: "reset" | "merge"): BuildURI;
|
105
109
|
delParam(key: string): BuildURI;
|
106
110
|
defParam(key: string, str: string): BuildURI;
|
107
111
|
setParam(key: string, str: string): BuildURI;
|
@@ -110,6 +114,7 @@ declare class BuildURI implements URIInterface<BuildURI> {
|
|
110
114
|
getParam<T extends string | undefined>(key: string | OneKey<string>, def?: T): T extends string ? string : string | undefined;
|
111
115
|
getParamResult(key: string, msgFn?: (key: string) => string): Result<string>;
|
112
116
|
getParamsResult(...keys: KeysParam): Result<Record<string, string>>;
|
117
|
+
getHashParams(...keys: KeysParam): Result<Record<string, string>>;
|
113
118
|
toString(): string;
|
114
119
|
toJSON(): string;
|
115
120
|
asURL(): URL;
|
@@ -131,15 +136,18 @@ declare class URI implements URIInterface<URI> {
|
|
131
136
|
private constructor();
|
132
137
|
build(): BuildURI;
|
133
138
|
get hostname(): string;
|
139
|
+
get local(): string;
|
134
140
|
get port(): string;
|
135
141
|
get host(): string;
|
136
142
|
get protocol(): string;
|
137
143
|
get pathname(): string;
|
144
|
+
get hash(): string;
|
138
145
|
get getParams(): Iterable<[string, string]>;
|
139
146
|
hasParam(key: string): boolean;
|
140
147
|
getParam<T extends string | undefined>(key: string | OneKey<string>, def?: T): T extends string ? string : string | undefined;
|
141
148
|
getParamResult(key: string, msgFn?: (key: string) => string): Result<string>;
|
142
149
|
getParamsResult(...keys: KeysParam): Result<Record<string, string>>;
|
150
|
+
getHashParams(...keys: KeysParam): Result<Record<string, string>>;
|
143
151
|
clone(): URI;
|
144
152
|
asURL(): URL;
|
145
153
|
toString(): string;
|