@adviser/cement 0.2.30 → 0.2.31
Sign up to get free protection for your applications and to get access to all the features.
- package/index.cjs +27 -11
- package/index.cjs.map +1 -1
- package/index.d.cts +17 -2
- package/index.d.ts +17 -2
- package/index.js +31 -15
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/src/jsr.json +1 -1
- package/src/uri.ts +43 -9
- package/src/utils/stripper.ts +59 -0
- package/ts/uri.d.ts +16 -1
- package/ts/uri.d.ts.map +1 -1
- package/ts/uri.js +21 -9
- package/ts/uri.js.map +1 -1
- package/ts/uri.test.js +28 -0
- package/ts/uri.test.js.map +1 -1
- package/ts/utils/stripper.d.ts +3 -0
- package/ts/utils/stripper.d.ts.map +1 -0
- package/ts/utils/stripper.js +56 -0
- package/ts/utils/stripper.js.map +1 -0
- package/ts/utils/stripper.test.d.ts +2 -0
- package/ts/utils/stripper.test.d.ts.map +1 -0
- package/ts/utils/stripper.test.js +97 -0
- package/ts/utils/stripper.test.js.map +1 -0
package/index.d.cts
CHANGED
@@ -38,6 +38,20 @@ type WithResult<T> = T extends Promise<infer U> ? Promise<Result<U>> : Result<T>
|
|
38
38
|
declare function exception2Result<FN extends () => Promise<T> | T, T>(fn: FN): WithResult<ReturnType<FN>>;
|
39
39
|
|
40
40
|
type NullOrUndef = null | undefined;
|
41
|
+
interface URIObject {
|
42
|
+
readonly style: "host" | "path";
|
43
|
+
readonly protocol: string;
|
44
|
+
readonly pathname: string;
|
45
|
+
readonly searchParams: Record<string, string>;
|
46
|
+
}
|
47
|
+
interface PathURIObject extends URIObject {
|
48
|
+
readonly style: "path";
|
49
|
+
}
|
50
|
+
interface HostURIObject extends URIObject {
|
51
|
+
readonly style: "host";
|
52
|
+
readonly hostname: string;
|
53
|
+
readonly port: string;
|
54
|
+
}
|
41
55
|
declare function isURL(value: unknown): value is URL;
|
42
56
|
declare class MutableURL extends URL {
|
43
57
|
private readonly _sysURL;
|
@@ -78,7 +92,7 @@ declare class BuildURI {
|
|
78
92
|
URI(): URI;
|
79
93
|
}
|
80
94
|
type CoerceURI = string | URI | MutableURL | URL | BuildURI | NullOrUndef;
|
81
|
-
declare const
|
95
|
+
declare const hasHostPartProtocols: Set<string>;
|
82
96
|
declare class URI {
|
83
97
|
static protocolHasHostpart(protocol: string): () => void;
|
84
98
|
static merge(into: CoerceURI, from: CoerceURI, defaultProtocol?: string): URI;
|
@@ -100,6 +114,7 @@ declare class URI {
|
|
100
114
|
asURL(): URL;
|
101
115
|
toString(): string;
|
102
116
|
toJSON(): string;
|
117
|
+
asObj(): HostURIObject | PathURIObject;
|
103
118
|
}
|
104
119
|
|
105
120
|
declare enum Level {
|
@@ -531,4 +546,4 @@ declare const VERSION: string;
|
|
531
546
|
|
532
547
|
declare function wrapRefcounted<T, M extends string>(t: T, method: M): T;
|
533
548
|
|
534
|
-
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 CleanCtx, type CoerceURI, type CryptoRuntime, type FnSerialized, Future, type Invokaction, IsLogger, JSONFormatter, Keyed, KeyedResolvOnce, KeyedResolvSeq, type Lengthed, Level, type LevelHandler, LevelHandlerImpl, LevelHandlerSingleton, LogCollector, type LogFormatter, type LogSerializable, LogValue, type LogValueArg, LogWriteStream, type Logger, LoggerImpl, type LoggerImplParams, type LoggerInterface, Metric, type MetricMap, Metrics, MockLogger, type MockLoggerReturn, MutableURL, None, Option, ResolveOnce, ResolveSeq, Result, ResultError, ResultOK, type Runtime, type Serialized, type SizeOrLength, type Sized, Some, SysAbstraction, Time, type TraceCtx, type TraceCtxParam, TraceNode, type TraceNodeMap, TxtEnDecoder, URI, VERSION, type WithLogger, type WithoutOption, type WithoutResult, YAMLFormatter, asyncLogValue, bin2string, bin2text, exception2Result, isURL, logValue,
|
549
|
+
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 CleanCtx, type CoerceURI, type CryptoRuntime, type FnSerialized, Future, type HostURIObject, type Invokaction, IsLogger, JSONFormatter, Keyed, KeyedResolvOnce, KeyedResolvSeq, type Lengthed, Level, type LevelHandler, LevelHandlerImpl, LevelHandlerSingleton, LogCollector, type LogFormatter, type LogSerializable, LogValue, type LogValueArg, LogWriteStream, type Logger, LoggerImpl, type LoggerImplParams, type LoggerInterface, Metric, type MetricMap, Metrics, MockLogger, type MockLoggerReturn, MutableURL, None, Option, type PathURIObject, ResolveOnce, ResolveSeq, Result, ResultError, ResultOK, type Runtime, type Serialized, type SizeOrLength, type Sized, Some, SysAbstraction, Time, type TraceCtx, type TraceCtxParam, TraceNode, type TraceNodeMap, TxtEnDecoder, URI, type URIObject, VERSION, type WithLogger, type WithoutOption, type WithoutResult, YAMLFormatter, asyncLogValue, bin2string, bin2text, exception2Result, hasHostPartProtocols, isURL, logValue, removeSelfRef, runtimeFn, toCryptoRuntime, wrapRefcounted };
|
package/index.d.ts
CHANGED
@@ -38,6 +38,20 @@ type WithResult<T> = T extends Promise<infer U> ? Promise<Result<U>> : Result<T>
|
|
38
38
|
declare function exception2Result<FN extends () => Promise<T> | T, T>(fn: FN): WithResult<ReturnType<FN>>;
|
39
39
|
|
40
40
|
type NullOrUndef = null | undefined;
|
41
|
+
interface URIObject {
|
42
|
+
readonly style: "host" | "path";
|
43
|
+
readonly protocol: string;
|
44
|
+
readonly pathname: string;
|
45
|
+
readonly searchParams: Record<string, string>;
|
46
|
+
}
|
47
|
+
interface PathURIObject extends URIObject {
|
48
|
+
readonly style: "path";
|
49
|
+
}
|
50
|
+
interface HostURIObject extends URIObject {
|
51
|
+
readonly style: "host";
|
52
|
+
readonly hostname: string;
|
53
|
+
readonly port: string;
|
54
|
+
}
|
41
55
|
declare function isURL(value: unknown): value is URL;
|
42
56
|
declare class MutableURL extends URL {
|
43
57
|
private readonly _sysURL;
|
@@ -78,7 +92,7 @@ declare class BuildURI {
|
|
78
92
|
URI(): URI;
|
79
93
|
}
|
80
94
|
type CoerceURI = string | URI | MutableURL | URL | BuildURI | NullOrUndef;
|
81
|
-
declare const
|
95
|
+
declare const hasHostPartProtocols: Set<string>;
|
82
96
|
declare class URI {
|
83
97
|
static protocolHasHostpart(protocol: string): () => void;
|
84
98
|
static merge(into: CoerceURI, from: CoerceURI, defaultProtocol?: string): URI;
|
@@ -100,6 +114,7 @@ declare class URI {
|
|
100
114
|
asURL(): URL;
|
101
115
|
toString(): string;
|
102
116
|
toJSON(): string;
|
117
|
+
asObj(): HostURIObject | PathURIObject;
|
103
118
|
}
|
104
119
|
|
105
120
|
declare enum Level {
|
@@ -531,4 +546,4 @@ declare const VERSION: string;
|
|
531
546
|
|
532
547
|
declare function wrapRefcounted<T, M extends string>(t: T, method: M): T;
|
533
548
|
|
534
|
-
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 CleanCtx, type CoerceURI, type CryptoRuntime, type FnSerialized, Future, type Invokaction, IsLogger, JSONFormatter, Keyed, KeyedResolvOnce, KeyedResolvSeq, type Lengthed, Level, type LevelHandler, LevelHandlerImpl, LevelHandlerSingleton, LogCollector, type LogFormatter, type LogSerializable, LogValue, type LogValueArg, LogWriteStream, type Logger, LoggerImpl, type LoggerImplParams, type LoggerInterface, Metric, type MetricMap, Metrics, MockLogger, type MockLoggerReturn, MutableURL, None, Option, ResolveOnce, ResolveSeq, Result, ResultError, ResultOK, type Runtime, type Serialized, type SizeOrLength, type Sized, Some, SysAbstraction, Time, type TraceCtx, type TraceCtxParam, TraceNode, type TraceNodeMap, TxtEnDecoder, URI, VERSION, type WithLogger, type WithoutOption, type WithoutResult, YAMLFormatter, asyncLogValue, bin2string, bin2text, exception2Result, isURL, logValue,
|
549
|
+
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 CleanCtx, type CoerceURI, type CryptoRuntime, type FnSerialized, Future, type HostURIObject, type Invokaction, IsLogger, JSONFormatter, Keyed, KeyedResolvOnce, KeyedResolvSeq, type Lengthed, Level, type LevelHandler, LevelHandlerImpl, LevelHandlerSingleton, LogCollector, type LogFormatter, type LogSerializable, LogValue, type LogValueArg, LogWriteStream, type Logger, LoggerImpl, type LoggerImplParams, type LoggerInterface, Metric, type MetricMap, Metrics, MockLogger, type MockLoggerReturn, MutableURL, None, Option, type PathURIObject, ResolveOnce, ResolveSeq, Result, ResultError, ResultOK, type Runtime, type Serialized, type SizeOrLength, type Sized, Some, SysAbstraction, Time, type TraceCtx, type TraceCtxParam, TraceNode, type TraceNodeMap, TxtEnDecoder, URI, type URIObject, VERSION, type WithLogger, type WithoutOption, type WithoutResult, YAMLFormatter, asyncLogValue, bin2string, bin2text, exception2Result, hasHostPartProtocols, isURL, logValue, removeSelfRef, runtimeFn, toCryptoRuntime, wrapRefcounted };
|
package/index.js
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
import {
|
2
|
+
ConsoleWriterStream,
|
3
|
+
FanoutWriteStream,
|
4
|
+
utils_exports
|
5
|
+
} from "./chunk-7KFVMTOS.js";
|
1
6
|
import {
|
2
7
|
WebSysAbstraction
|
3
8
|
} from "./chunk-WMMUXBDX.js";
|
@@ -26,11 +31,6 @@ import {
|
|
26
31
|
WrapperSysAbstraction,
|
27
32
|
envFactory
|
28
33
|
} from "./chunk-Q65HLCNL.js";
|
29
|
-
import {
|
30
|
-
ConsoleWriterStream,
|
31
|
-
FanoutWriteStream,
|
32
|
-
utils_exports
|
33
|
-
} from "./chunk-7KFVMTOS.js";
|
34
34
|
import {
|
35
35
|
Utf8EnDecoder,
|
36
36
|
Utf8EnDecoderSingleton,
|
@@ -306,7 +306,7 @@ var MutableURL = class _MutableURL extends URL {
|
|
306
306
|
constructor(urlStr) {
|
307
307
|
super("defect://does.not.exist");
|
308
308
|
const partedURL = urlStr.split(":");
|
309
|
-
this._hasHostpart =
|
309
|
+
this._hasHostpart = hasHostPartProtocols.has(partedURL[0]);
|
310
310
|
let hostPartUrl = ["http", ...partedURL.slice(1)].join(":");
|
311
311
|
if (!this._hasHostpart) {
|
312
312
|
const pathname = hostPartUrl.replace(/http:\/\/[/]*/, "").replace(/[#?].*$/, "");
|
@@ -333,32 +333,32 @@ var MutableURL = class _MutableURL extends URL {
|
|
333
333
|
get host() {
|
334
334
|
if (!this._hasHostpart) {
|
335
335
|
throw new Error(
|
336
|
-
`you can use hostname only if protocol is ${this.toString()} ${JSON.stringify(Array.from(
|
336
|
+
`you can use hostname only if protocol is ${this.toString()} ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`
|
337
337
|
);
|
338
338
|
}
|
339
339
|
return this._sysURL.host;
|
340
340
|
}
|
341
341
|
get port() {
|
342
342
|
if (!this._hasHostpart) {
|
343
|
-
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(
|
343
|
+
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);
|
344
344
|
}
|
345
345
|
return this._sysURL.port;
|
346
346
|
}
|
347
347
|
set port(p) {
|
348
348
|
if (!this._hasHostpart) {
|
349
|
-
throw new Error(`you can use port only if protocol is ${JSON.stringify(Array.from(
|
349
|
+
throw new Error(`you can use port only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);
|
350
350
|
}
|
351
351
|
this._sysURL.port = p;
|
352
352
|
}
|
353
353
|
get hostname() {
|
354
354
|
if (!this._hasHostpart) {
|
355
|
-
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(
|
355
|
+
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);
|
356
356
|
}
|
357
357
|
return this._sysURL.hostname;
|
358
358
|
}
|
359
359
|
set hostname(h) {
|
360
360
|
if (!this._hasHostpart) {
|
361
|
-
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(
|
361
|
+
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);
|
362
362
|
}
|
363
363
|
this._sysURL.hostname = h;
|
364
364
|
}
|
@@ -501,13 +501,13 @@ var BuildURI = class _BuildURI {
|
|
501
501
|
return URI.from(this._url);
|
502
502
|
}
|
503
503
|
};
|
504
|
-
var
|
504
|
+
var hasHostPartProtocols = /* @__PURE__ */ new Set(["http", "https", "ws", "wss"]);
|
505
505
|
var URI = class _URI {
|
506
506
|
static protocolHasHostpart(protocol) {
|
507
507
|
protocol = protocol.replace(/:$/, "");
|
508
|
-
|
508
|
+
hasHostPartProtocols.add(protocol);
|
509
509
|
return () => {
|
510
|
-
|
510
|
+
hasHostPartProtocols.delete(protocol);
|
511
511
|
};
|
512
512
|
}
|
513
513
|
// if no protocol is provided, default to file:
|
@@ -591,6 +591,22 @@ var URI = class _URI {
|
|
591
591
|
toJSON() {
|
592
592
|
return this.toString();
|
593
593
|
}
|
594
|
+
asObj() {
|
595
|
+
const pathURI = {
|
596
|
+
style: "path",
|
597
|
+
protocol: this.protocol,
|
598
|
+
pathname: this.pathname,
|
599
|
+
searchParams: Object.fromEntries(this.getParams)
|
600
|
+
};
|
601
|
+
if (hasHostPartProtocols.has(this.protocol.replace(/:$/, ""))) {
|
602
|
+
return __spreadProps(__spreadValues({}, pathURI), {
|
603
|
+
style: "host",
|
604
|
+
hostname: this.hostname,
|
605
|
+
port: this.port
|
606
|
+
});
|
607
|
+
}
|
608
|
+
return pathURI;
|
609
|
+
}
|
594
610
|
};
|
595
611
|
|
596
612
|
// src/runtime.ts
|
@@ -1542,9 +1558,9 @@ export {
|
|
1542
1558
|
bin2text,
|
1543
1559
|
envFactory,
|
1544
1560
|
exception2Result,
|
1561
|
+
hasHostPartProtocols,
|
1545
1562
|
isURL,
|
1546
1563
|
logValue,
|
1547
|
-
protocols,
|
1548
1564
|
removeSelfRef,
|
1549
1565
|
runtimeFn,
|
1550
1566
|
toCryptoRuntime,
|