@adviser/cement 0.2.29 → 0.2.31
Sign up to get free protection for your applications and to get access to all the features.
- package/index.cjs +51 -13
- package/index.cjs.map +1 -1
- package/index.d.cts +19 -2
- package/index.d.ts +19 -2
- package/index.js +53 -16
- package/index.js.map +1 -1
- package/package.json +14 -14
- package/src/index.ts +1 -0
- package/src/jsr.json +4 -2
- package/src/refcounted.ts +23 -0
- package/src/uri.ts +43 -9
- package/src/utils/stripper.ts +59 -0
- package/ts/index.d.ts +1 -0
- package/ts/index.d.ts.map +1 -1
- package/ts/index.js +1 -0
- package/ts/index.js.map +1 -1
- package/ts/node/node-sys-abstraction.test.js +2 -6
- package/ts/node/node-sys-abstraction.test.js.map +1 -1
- package/ts/refcounted.d.ts +2 -0
- package/ts/refcounted.d.ts.map +1 -0
- package/ts/refcounted.js +19 -0
- package/ts/refcounted.js.map +1 -0
- package/ts/refcounted.test.d.ts +2 -0
- package/ts/refcounted.test.d.ts.map +1 -0
- package/ts/refcounted.test.js +39 -0
- package/ts/refcounted.test.js.map +1 -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/src/base-sys-abstraction.test.ts +0 -95
- package/src/bin2text.test.ts +0 -59
- package/src/crypto.test.ts +0 -15
- package/src/future.test.ts +0 -32
- package/src/logger.test.ts +0 -1132
- package/src/resolve-once.test.ts +0 -321
- package/src/result.test.ts +0 -102
- package/src/sys-env.test.ts +0 -53
- package/src/tracer.test.ts +0 -314
- package/src/uri.test.ts +0 -155
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 {
|
@@ -529,4 +544,6 @@ declare function bin2string(hex: ArrayBufferView, size?: number): string;
|
|
529
544
|
|
530
545
|
declare const VERSION: string;
|
531
546
|
|
532
|
-
|
547
|
+
declare function wrapRefcounted<T, M extends string>(t: T, method: M): T;
|
548
|
+
|
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 {
|
@@ -529,4 +544,6 @@ declare function bin2string(hex: ArrayBufferView, size?: number): string;
|
|
529
544
|
|
530
545
|
declare const VERSION: string;
|
531
546
|
|
532
|
-
|
547
|
+
declare function wrapRefcounted<T, M extends string>(t: T, method: M): T;
|
548
|
+
|
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
|
@@ -1468,6 +1484,26 @@ function toCryptoRuntime(cryptoOpts = {}) {
|
|
1468
1484
|
var VERSION = Object.keys({
|
1469
1485
|
__packageVersion__: "xxxx"
|
1470
1486
|
})[0];
|
1487
|
+
|
1488
|
+
// src/refcounted.ts
|
1489
|
+
function wrapRefcounted(t, method) {
|
1490
|
+
const my = t;
|
1491
|
+
my.__refcounted = (my.__refcounted || 0) + 1;
|
1492
|
+
if (my.__refcounted === 1) {
|
1493
|
+
my.__unrefcounted = my[method];
|
1494
|
+
const mRec = my;
|
1495
|
+
mRec[method] = function() {
|
1496
|
+
this.__refcounted--;
|
1497
|
+
if (this.__refcounted === 0) {
|
1498
|
+
this.__unrefcounted();
|
1499
|
+
}
|
1500
|
+
if (this.__refcounted < 0) {
|
1501
|
+
throw new Error("already closed");
|
1502
|
+
}
|
1503
|
+
};
|
1504
|
+
}
|
1505
|
+
return t;
|
1506
|
+
}
|
1471
1507
|
export {
|
1472
1508
|
BaseSysAbstraction,
|
1473
1509
|
BrowserEnvActions,
|
@@ -1522,12 +1558,13 @@ export {
|
|
1522
1558
|
bin2text,
|
1523
1559
|
envFactory,
|
1524
1560
|
exception2Result,
|
1561
|
+
hasHostPartProtocols,
|
1525
1562
|
isURL,
|
1526
1563
|
logValue,
|
1527
|
-
protocols,
|
1528
1564
|
removeSelfRef,
|
1529
1565
|
runtimeFn,
|
1530
1566
|
toCryptoRuntime,
|
1531
|
-
utils_exports as utils
|
1567
|
+
utils_exports as utils,
|
1568
|
+
wrapRefcounted
|
1532
1569
|
};
|
1533
1570
|
//# sourceMappingURL=index.js.map
|