@adviser/cement 0.2.30 → 0.2.32
Sign up to get free protection for your applications and to get access to all the features.
- package/index.cjs +142 -36
- package/index.cjs.map +1 -1
- package/index.d.cts +26 -4
- package/index.d.ts +26 -4
- package/index.js +140 -33
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +0 -1
- package/src/jsr.json +1 -1
- package/src/logger-impl.ts +3 -1
- package/src/logger.ts +1 -0
- package/src/uri.ts +117 -9
- package/src/utils/stripper.ts +59 -0
- package/ts/index.d.ts +0 -1
- package/ts/index.d.ts.map +1 -1
- package/ts/index.js +0 -1
- package/ts/index.js.map +1 -1
- package/ts/logger-impl.d.ts.map +1 -1
- package/ts/logger-impl.js +3 -1
- package/ts/logger-impl.js.map +1 -1
- package/ts/logger.d.ts +1 -0
- package/ts/logger.d.ts.map +1 -1
- package/ts/logger.test.js +14 -0
- package/ts/logger.test.js.map +1 -1
- package/ts/uri.d.ts +23 -1
- package/ts/uri.d.ts.map +1 -1
- package/ts/uri.js +81 -10
- package/ts/uri.js.map +1 -1
- package/ts/uri.test.js +85 -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/src/refcounted.ts +0 -23
- package/ts/refcounted.d.ts +0 -2
- package/ts/refcounted.d.ts.map +0 -1
- package/ts/refcounted.js +0 -19
- package/ts/refcounted.js.map +0 -1
- package/ts/refcounted.test.d.ts +0 -2
- package/ts/refcounted.test.d.ts.map +0 -1
- package/ts/refcounted.test.js +0 -39
- package/ts/refcounted.test.js.map +0 -1
package/index.d.cts
CHANGED
@@ -37,7 +37,23 @@ type WithoutResult<T> = T extends Result<infer U> ? U : T;
|
|
37
37
|
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
|
+
type StripCommand = string | RegExp;
|
41
|
+
|
40
42
|
type NullOrUndef = null | undefined;
|
43
|
+
interface URIObject {
|
44
|
+
readonly style: "host" | "path";
|
45
|
+
readonly protocol: string;
|
46
|
+
readonly pathname: string;
|
47
|
+
readonly searchParams: Record<string, string>;
|
48
|
+
}
|
49
|
+
interface PathURIObject extends URIObject {
|
50
|
+
readonly style: "path";
|
51
|
+
}
|
52
|
+
interface HostURIObject extends URIObject {
|
53
|
+
readonly style: "host";
|
54
|
+
readonly hostname: string;
|
55
|
+
readonly port: string;
|
56
|
+
}
|
41
57
|
declare function isURL(value: unknown): value is URL;
|
42
58
|
declare class MutableURL extends URL {
|
43
59
|
private readonly _sysURL;
|
@@ -59,6 +75,7 @@ declare class MutableURL extends URL {
|
|
59
75
|
get searchParams(): URLSearchParams;
|
60
76
|
toString(): string;
|
61
77
|
}
|
78
|
+
type keysParam = (string | ((...keys: string[]) => string))[];
|
62
79
|
declare class BuildURI {
|
63
80
|
_url: MutableURL;
|
64
81
|
private constructor();
|
@@ -68,17 +85,21 @@ declare class BuildURI {
|
|
68
85
|
hostname(h: string): BuildURI;
|
69
86
|
protocol(p: string): BuildURI;
|
70
87
|
pathname(p: string): BuildURI;
|
88
|
+
appendRelative(p: CoerceURI): BuildURI;
|
71
89
|
delParam(key: string): BuildURI;
|
72
90
|
defParam(key: string, str: string): BuildURI;
|
73
91
|
setParam(key: string, str: string): BuildURI;
|
74
92
|
hasParam(key: string): boolean;
|
75
93
|
getParam(key: string): string | undefined;
|
94
|
+
getParamResult(key: string, msgFn?: (key: string) => string): Result<string>;
|
95
|
+
getParamsResult(...keys: keysParam): Result<Record<string, string>>;
|
76
96
|
toString(): string;
|
77
97
|
toJSON(): string;
|
98
|
+
asObj(...strips: StripCommand[]): HostURIObject | PathURIObject;
|
78
99
|
URI(): URI;
|
79
100
|
}
|
80
101
|
type CoerceURI = string | URI | MutableURL | URL | BuildURI | NullOrUndef;
|
81
|
-
declare const
|
102
|
+
declare const hasHostPartProtocols: Set<string>;
|
82
103
|
declare class URI {
|
83
104
|
static protocolHasHostpart(protocol: string): () => void;
|
84
105
|
static merge(into: CoerceURI, from: CoerceURI, defaultProtocol?: string): URI;
|
@@ -96,10 +117,12 @@ declare class URI {
|
|
96
117
|
get getParams(): Iterable<[string, string]>;
|
97
118
|
hasParam(key: string): boolean;
|
98
119
|
getParam(key: string): string | undefined;
|
120
|
+
getParamResult(key: string, msgFn?: (key: string) => string): Result<string>;
|
99
121
|
clone(): URI;
|
100
122
|
asURL(): URL;
|
101
123
|
toString(): string;
|
102
124
|
toJSON(): string;
|
125
|
+
asObj(...strips: StripCommand[]): HostURIObject | PathURIObject;
|
103
126
|
}
|
104
127
|
|
105
128
|
declare enum Level {
|
@@ -176,6 +199,7 @@ interface WithLogger extends LoggerInterface<WithLogger> {
|
|
176
199
|
}
|
177
200
|
interface AsError {
|
178
201
|
AsError(): Error;
|
202
|
+
ResultError<T>(): Result<T>;
|
179
203
|
}
|
180
204
|
interface Logger extends LoggerInterface<Logger> {
|
181
205
|
With(): WithLogger;
|
@@ -529,6 +553,4 @@ declare function bin2string(hex: ArrayBufferView, size?: number): string;
|
|
529
553
|
|
530
554
|
declare const VERSION: string;
|
531
555
|
|
532
|
-
|
533
|
-
|
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, protocols, removeSelfRef, runtimeFn, toCryptoRuntime, wrapRefcounted };
|
556
|
+
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 };
|
package/index.d.ts
CHANGED
@@ -37,7 +37,23 @@ type WithoutResult<T> = T extends Result<infer U> ? U : T;
|
|
37
37
|
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
|
+
type StripCommand = string | RegExp;
|
41
|
+
|
40
42
|
type NullOrUndef = null | undefined;
|
43
|
+
interface URIObject {
|
44
|
+
readonly style: "host" | "path";
|
45
|
+
readonly protocol: string;
|
46
|
+
readonly pathname: string;
|
47
|
+
readonly searchParams: Record<string, string>;
|
48
|
+
}
|
49
|
+
interface PathURIObject extends URIObject {
|
50
|
+
readonly style: "path";
|
51
|
+
}
|
52
|
+
interface HostURIObject extends URIObject {
|
53
|
+
readonly style: "host";
|
54
|
+
readonly hostname: string;
|
55
|
+
readonly port: string;
|
56
|
+
}
|
41
57
|
declare function isURL(value: unknown): value is URL;
|
42
58
|
declare class MutableURL extends URL {
|
43
59
|
private readonly _sysURL;
|
@@ -59,6 +75,7 @@ declare class MutableURL extends URL {
|
|
59
75
|
get searchParams(): URLSearchParams;
|
60
76
|
toString(): string;
|
61
77
|
}
|
78
|
+
type keysParam = (string | ((...keys: string[]) => string))[];
|
62
79
|
declare class BuildURI {
|
63
80
|
_url: MutableURL;
|
64
81
|
private constructor();
|
@@ -68,17 +85,21 @@ declare class BuildURI {
|
|
68
85
|
hostname(h: string): BuildURI;
|
69
86
|
protocol(p: string): BuildURI;
|
70
87
|
pathname(p: string): BuildURI;
|
88
|
+
appendRelative(p: CoerceURI): BuildURI;
|
71
89
|
delParam(key: string): BuildURI;
|
72
90
|
defParam(key: string, str: string): BuildURI;
|
73
91
|
setParam(key: string, str: string): BuildURI;
|
74
92
|
hasParam(key: string): boolean;
|
75
93
|
getParam(key: string): string | undefined;
|
94
|
+
getParamResult(key: string, msgFn?: (key: string) => string): Result<string>;
|
95
|
+
getParamsResult(...keys: keysParam): Result<Record<string, string>>;
|
76
96
|
toString(): string;
|
77
97
|
toJSON(): string;
|
98
|
+
asObj(...strips: StripCommand[]): HostURIObject | PathURIObject;
|
78
99
|
URI(): URI;
|
79
100
|
}
|
80
101
|
type CoerceURI = string | URI | MutableURL | URL | BuildURI | NullOrUndef;
|
81
|
-
declare const
|
102
|
+
declare const hasHostPartProtocols: Set<string>;
|
82
103
|
declare class URI {
|
83
104
|
static protocolHasHostpart(protocol: string): () => void;
|
84
105
|
static merge(into: CoerceURI, from: CoerceURI, defaultProtocol?: string): URI;
|
@@ -96,10 +117,12 @@ declare class URI {
|
|
96
117
|
get getParams(): Iterable<[string, string]>;
|
97
118
|
hasParam(key: string): boolean;
|
98
119
|
getParam(key: string): string | undefined;
|
120
|
+
getParamResult(key: string, msgFn?: (key: string) => string): Result<string>;
|
99
121
|
clone(): URI;
|
100
122
|
asURL(): URL;
|
101
123
|
toString(): string;
|
102
124
|
toJSON(): string;
|
125
|
+
asObj(...strips: StripCommand[]): HostURIObject | PathURIObject;
|
103
126
|
}
|
104
127
|
|
105
128
|
declare enum Level {
|
@@ -176,6 +199,7 @@ interface WithLogger extends LoggerInterface<WithLogger> {
|
|
176
199
|
}
|
177
200
|
interface AsError {
|
178
201
|
AsError(): Error;
|
202
|
+
ResultError<T>(): Result<T>;
|
179
203
|
}
|
180
204
|
interface Logger extends LoggerInterface<Logger> {
|
181
205
|
With(): WithLogger;
|
@@ -529,6 +553,4 @@ declare function bin2string(hex: ArrayBufferView, size?: number): string;
|
|
529
553
|
|
530
554
|
declare const VERSION: string;
|
531
555
|
|
532
|
-
|
533
|
-
|
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, protocols, removeSelfRef, runtimeFn, toCryptoRuntime, wrapRefcounted };
|
556
|
+
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 };
|
package/index.js
CHANGED
@@ -281,6 +281,61 @@ function exception2Result(fn) {
|
|
281
281
|
}
|
282
282
|
}
|
283
283
|
|
284
|
+
// src/utils/stripper.ts
|
285
|
+
function stripper(strip, obj) {
|
286
|
+
const strips = Array.isArray(strip) ? strip : [strip];
|
287
|
+
const restrips = strips.map((s) => {
|
288
|
+
if (typeof s === "string") {
|
289
|
+
const escaped = s.replace(/[-\\[\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\^\\$\\|]/g, "\\$&");
|
290
|
+
return new RegExp(`^${escaped}$`);
|
291
|
+
}
|
292
|
+
return s;
|
293
|
+
});
|
294
|
+
return localStripper(void 0, restrips, obj);
|
295
|
+
}
|
296
|
+
function localStripper(path, restrips, obj) {
|
297
|
+
if (typeof obj !== "object" || obj === null) {
|
298
|
+
return obj;
|
299
|
+
}
|
300
|
+
const ret = __spreadValues({}, obj);
|
301
|
+
const matcher = (key, nextPath) => {
|
302
|
+
for (const re of restrips) {
|
303
|
+
if (re.test(key) || re.test(nextPath)) {
|
304
|
+
return true;
|
305
|
+
}
|
306
|
+
}
|
307
|
+
return false;
|
308
|
+
};
|
309
|
+
for (const key in ret) {
|
310
|
+
if (Object.prototype.hasOwnProperty.call(ret, key)) {
|
311
|
+
let nextPath;
|
312
|
+
if (path) {
|
313
|
+
nextPath = [path, key].join(".");
|
314
|
+
} else {
|
315
|
+
nextPath = key;
|
316
|
+
}
|
317
|
+
if (matcher(key, nextPath)) {
|
318
|
+
delete ret[key];
|
319
|
+
continue;
|
320
|
+
}
|
321
|
+
if (typeof ret[key] === "object") {
|
322
|
+
if (Array.isArray(ret[key])) {
|
323
|
+
ret[key] = ret[key].reduce((acc, v, i) => {
|
324
|
+
const toDelete = matcher(key, `${nextPath}[${i}]`);
|
325
|
+
if (!toDelete) {
|
326
|
+
acc.push(localStripper(`${nextPath}[${i}]`, restrips, v));
|
327
|
+
}
|
328
|
+
return acc;
|
329
|
+
}, []);
|
330
|
+
} else {
|
331
|
+
ret[key] = localStripper(nextPath, restrips, ret[key]);
|
332
|
+
}
|
333
|
+
}
|
334
|
+
}
|
335
|
+
}
|
336
|
+
return ret;
|
337
|
+
}
|
338
|
+
|
284
339
|
// src/uri.ts
|
285
340
|
function falsy2undef(value) {
|
286
341
|
return value === void 0 || value === null ? void 0 : value;
|
@@ -306,7 +361,7 @@ var MutableURL = class _MutableURL extends URL {
|
|
306
361
|
constructor(urlStr) {
|
307
362
|
super("defect://does.not.exist");
|
308
363
|
const partedURL = urlStr.split(":");
|
309
|
-
this._hasHostpart =
|
364
|
+
this._hasHostpart = hasHostPartProtocols.has(partedURL[0]);
|
310
365
|
let hostPartUrl = ["http", ...partedURL.slice(1)].join(":");
|
311
366
|
if (!this._hasHostpart) {
|
312
367
|
const pathname = hostPartUrl.replace(/http:\/\/[/]*/, "").replace(/[#?].*$/, "");
|
@@ -333,32 +388,32 @@ var MutableURL = class _MutableURL extends URL {
|
|
333
388
|
get host() {
|
334
389
|
if (!this._hasHostpart) {
|
335
390
|
throw new Error(
|
336
|
-
`you can use hostname only if protocol is ${this.toString()} ${JSON.stringify(Array.from(
|
391
|
+
`you can use hostname only if protocol is ${this.toString()} ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`
|
337
392
|
);
|
338
393
|
}
|
339
394
|
return this._sysURL.host;
|
340
395
|
}
|
341
396
|
get port() {
|
342
397
|
if (!this._hasHostpart) {
|
343
|
-
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(
|
398
|
+
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);
|
344
399
|
}
|
345
400
|
return this._sysURL.port;
|
346
401
|
}
|
347
402
|
set port(p) {
|
348
403
|
if (!this._hasHostpart) {
|
349
|
-
throw new Error(`you can use port only if protocol is ${JSON.stringify(Array.from(
|
404
|
+
throw new Error(`you can use port only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);
|
350
405
|
}
|
351
406
|
this._sysURL.port = p;
|
352
407
|
}
|
353
408
|
get hostname() {
|
354
409
|
if (!this._hasHostpart) {
|
355
|
-
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(
|
410
|
+
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);
|
356
411
|
}
|
357
412
|
return this._sysURL.hostname;
|
358
413
|
}
|
359
414
|
set hostname(h) {
|
360
415
|
if (!this._hasHostpart) {
|
361
|
-
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(
|
416
|
+
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);
|
362
417
|
}
|
363
418
|
this._sysURL.hostname = h;
|
364
419
|
}
|
@@ -419,6 +474,35 @@ function from(fac, strURLUri, defaultProtocol) {
|
|
419
474
|
throw new Error(`Invalid argument: ${typeof strURLUri}`);
|
420
475
|
}
|
421
476
|
}
|
477
|
+
function getParamResult(key, val, msgFn = (key2) => {
|
478
|
+
return `missing parameter: ${key2}`;
|
479
|
+
}) {
|
480
|
+
if (val === void 0) {
|
481
|
+
return Result.Err(msgFn(key));
|
482
|
+
}
|
483
|
+
return Result.Ok(val);
|
484
|
+
}
|
485
|
+
function getParamsResult(keys, getParam) {
|
486
|
+
const keyStrs = keys.flat().filter((k) => typeof k === "string");
|
487
|
+
const msgFn = keys.find((k) => typeof k === "function") || ((...keys2) => {
|
488
|
+
const msg = keys2.join(",");
|
489
|
+
return `missing parameters: ${msg}`;
|
490
|
+
});
|
491
|
+
const errors = [];
|
492
|
+
const result = {};
|
493
|
+
for (const key of keyStrs) {
|
494
|
+
const val = getParam.getParam(key);
|
495
|
+
if (val === void 0) {
|
496
|
+
errors.push(key);
|
497
|
+
} else {
|
498
|
+
result[key] = val;
|
499
|
+
}
|
500
|
+
}
|
501
|
+
if (errors.length) {
|
502
|
+
return Result.Err(msgFn(...errors));
|
503
|
+
}
|
504
|
+
return Result.Ok(result);
|
505
|
+
}
|
422
506
|
var BuildURI = class _BuildURI {
|
423
507
|
// pathname needs this
|
424
508
|
constructor(url) {
|
@@ -470,6 +554,20 @@ var BuildURI = class _BuildURI {
|
|
470
554
|
// this._url.host = h;
|
471
555
|
// return this;
|
472
556
|
// }
|
557
|
+
appendRelative(p) {
|
558
|
+
const url = URI.from(p);
|
559
|
+
let pathname = url.pathname;
|
560
|
+
if (url.pathname === "/") {
|
561
|
+
pathname = "";
|
562
|
+
} else if (!pathname.startsWith("/")) {
|
563
|
+
pathname = `/${pathname}`;
|
564
|
+
}
|
565
|
+
this.pathname(this._url.pathname + pathname);
|
566
|
+
for (const [key, value] of url.getParams) {
|
567
|
+
this.setParam(key, value);
|
568
|
+
}
|
569
|
+
return this;
|
570
|
+
}
|
473
571
|
delParam(key) {
|
474
572
|
this._url.searchParams.delete(key);
|
475
573
|
return this;
|
@@ -490,6 +588,12 @@ var BuildURI = class _BuildURI {
|
|
490
588
|
getParam(key) {
|
491
589
|
return falsy2undef(this._url.searchParams.get(key));
|
492
590
|
}
|
591
|
+
getParamResult(key, msgFn) {
|
592
|
+
return getParamResult(key, this.getParam(key), msgFn);
|
593
|
+
}
|
594
|
+
getParamsResult(...keys) {
|
595
|
+
return getParamsResult(keys, this);
|
596
|
+
}
|
493
597
|
toString() {
|
494
598
|
this._url.searchParams.sort();
|
495
599
|
return this._url.toString();
|
@@ -497,17 +601,20 @@ var BuildURI = class _BuildURI {
|
|
497
601
|
toJSON() {
|
498
602
|
return this.toString();
|
499
603
|
}
|
604
|
+
asObj(...strips) {
|
605
|
+
return this.URI().asObj(...strips);
|
606
|
+
}
|
500
607
|
URI() {
|
501
608
|
return URI.from(this._url);
|
502
609
|
}
|
503
610
|
};
|
504
|
-
var
|
611
|
+
var hasHostPartProtocols = /* @__PURE__ */ new Set(["http", "https", "ws", "wss"]);
|
505
612
|
var URI = class _URI {
|
506
613
|
static protocolHasHostpart(protocol) {
|
507
614
|
protocol = protocol.replace(/:$/, "");
|
508
|
-
|
615
|
+
hasHostPartProtocols.add(protocol);
|
509
616
|
return () => {
|
510
|
-
|
617
|
+
hasHostPartProtocols.delete(protocol);
|
511
618
|
};
|
512
619
|
}
|
513
620
|
// if no protocol is provided, default to file:
|
@@ -579,6 +686,9 @@ var URI = class _URI {
|
|
579
686
|
getParam(key) {
|
580
687
|
return falsy2undef(this._url.searchParams.get(key));
|
581
688
|
}
|
689
|
+
getParamResult(key, msgFn) {
|
690
|
+
return getParamResult(key, this.getParam(key), msgFn);
|
691
|
+
}
|
582
692
|
clone() {
|
583
693
|
return new _URI(this._url);
|
584
694
|
}
|
@@ -591,6 +701,22 @@ var URI = class _URI {
|
|
591
701
|
toJSON() {
|
592
702
|
return this.toString();
|
593
703
|
}
|
704
|
+
asObj(...strips) {
|
705
|
+
const pathURI = {
|
706
|
+
style: "path",
|
707
|
+
protocol: this.protocol,
|
708
|
+
pathname: this.pathname,
|
709
|
+
searchParams: Object.fromEntries(this.getParams)
|
710
|
+
};
|
711
|
+
if (hasHostPartProtocols.has(this.protocol.replace(/:$/, ""))) {
|
712
|
+
return stripper(strips, __spreadProps(__spreadValues({}, pathURI), {
|
713
|
+
style: "host",
|
714
|
+
hostname: this.hostname,
|
715
|
+
port: this.port
|
716
|
+
}));
|
717
|
+
}
|
718
|
+
return stripper(strips, pathURI);
|
719
|
+
}
|
594
720
|
};
|
595
721
|
|
596
722
|
// src/runtime.ts
|
@@ -1018,8 +1144,10 @@ var LoggerImpl = class _LoggerImpl {
|
|
1018
1144
|
}
|
1019
1145
|
return fnRet;
|
1020
1146
|
});
|
1147
|
+
const asError = () => new Error(this._txtEnDe.decode(fnError()));
|
1021
1148
|
return {
|
1022
|
-
|
1149
|
+
ResultError: () => Result.Err(asError()),
|
1150
|
+
AsError: asError
|
1023
1151
|
};
|
1024
1152
|
}
|
1025
1153
|
};
|
@@ -1468,26 +1596,6 @@ function toCryptoRuntime(cryptoOpts = {}) {
|
|
1468
1596
|
var VERSION = Object.keys({
|
1469
1597
|
__packageVersion__: "xxxx"
|
1470
1598
|
})[0];
|
1471
|
-
|
1472
|
-
// src/refcounted.ts
|
1473
|
-
function wrapRefcounted(t, method) {
|
1474
|
-
const my = t;
|
1475
|
-
my.__refcounted = (my.__refcounted || 0) + 1;
|
1476
|
-
if (my.__refcounted === 1) {
|
1477
|
-
my.__unrefcounted = my[method];
|
1478
|
-
const mRec = my;
|
1479
|
-
mRec[method] = function() {
|
1480
|
-
this.__refcounted--;
|
1481
|
-
if (this.__refcounted === 0) {
|
1482
|
-
this.__unrefcounted();
|
1483
|
-
}
|
1484
|
-
if (this.__refcounted < 0) {
|
1485
|
-
throw new Error("already closed");
|
1486
|
-
}
|
1487
|
-
};
|
1488
|
-
}
|
1489
|
-
return t;
|
1490
|
-
}
|
1491
1599
|
export {
|
1492
1600
|
BaseSysAbstraction,
|
1493
1601
|
BrowserEnvActions,
|
@@ -1542,13 +1650,12 @@ export {
|
|
1542
1650
|
bin2text,
|
1543
1651
|
envFactory,
|
1544
1652
|
exception2Result,
|
1653
|
+
hasHostPartProtocols,
|
1545
1654
|
isURL,
|
1546
1655
|
logValue,
|
1547
|
-
protocols,
|
1548
1656
|
removeSelfRef,
|
1549
1657
|
runtimeFn,
|
1550
1658
|
toCryptoRuntime,
|
1551
|
-
utils_exports as utils
|
1552
|
-
wrapRefcounted
|
1659
|
+
utils_exports as utils
|
1553
1660
|
};
|
1554
1661
|
//# sourceMappingURL=index.js.map
|