@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.cjs
CHANGED
@@ -140,13 +140,14 @@ __export(src_exports, {
|
|
140
140
|
bin2text: () => bin2text,
|
141
141
|
envFactory: () => envFactory,
|
142
142
|
exception2Result: () => exception2Result,
|
143
|
+
hasHostPartProtocols: () => hasHostPartProtocols,
|
143
144
|
isURL: () => isURL,
|
144
145
|
logValue: () => logValue,
|
145
|
-
protocols: () => protocols,
|
146
146
|
removeSelfRef: () => removeSelfRef,
|
147
147
|
runtimeFn: () => runtimeFn,
|
148
148
|
toCryptoRuntime: () => toCryptoRuntime,
|
149
|
-
utils: () => utils_exports
|
149
|
+
utils: () => utils_exports,
|
150
|
+
wrapRefcounted: () => wrapRefcounted
|
150
151
|
});
|
151
152
|
module.exports = __toCommonJS(src_exports);
|
152
153
|
|
@@ -1076,7 +1077,7 @@ var MutableURL = class _MutableURL extends URL {
|
|
1076
1077
|
constructor(urlStr) {
|
1077
1078
|
super("defect://does.not.exist");
|
1078
1079
|
const partedURL = urlStr.split(":");
|
1079
|
-
this._hasHostpart =
|
1080
|
+
this._hasHostpart = hasHostPartProtocols.has(partedURL[0]);
|
1080
1081
|
let hostPartUrl = ["http", ...partedURL.slice(1)].join(":");
|
1081
1082
|
if (!this._hasHostpart) {
|
1082
1083
|
const pathname = hostPartUrl.replace(/http:\/\/[/]*/, "").replace(/[#?].*$/, "");
|
@@ -1103,32 +1104,32 @@ var MutableURL = class _MutableURL extends URL {
|
|
1103
1104
|
get host() {
|
1104
1105
|
if (!this._hasHostpart) {
|
1105
1106
|
throw new Error(
|
1106
|
-
`you can use hostname only if protocol is ${this.toString()} ${JSON.stringify(Array.from(
|
1107
|
+
`you can use hostname only if protocol is ${this.toString()} ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`
|
1107
1108
|
);
|
1108
1109
|
}
|
1109
1110
|
return this._sysURL.host;
|
1110
1111
|
}
|
1111
1112
|
get port() {
|
1112
1113
|
if (!this._hasHostpart) {
|
1113
|
-
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(
|
1114
|
+
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);
|
1114
1115
|
}
|
1115
1116
|
return this._sysURL.port;
|
1116
1117
|
}
|
1117
1118
|
set port(p) {
|
1118
1119
|
if (!this._hasHostpart) {
|
1119
|
-
throw new Error(`you can use port only if protocol is ${JSON.stringify(Array.from(
|
1120
|
+
throw new Error(`you can use port only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);
|
1120
1121
|
}
|
1121
1122
|
this._sysURL.port = p;
|
1122
1123
|
}
|
1123
1124
|
get hostname() {
|
1124
1125
|
if (!this._hasHostpart) {
|
1125
|
-
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(
|
1126
|
+
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);
|
1126
1127
|
}
|
1127
1128
|
return this._sysURL.hostname;
|
1128
1129
|
}
|
1129
1130
|
set hostname(h) {
|
1130
1131
|
if (!this._hasHostpart) {
|
1131
|
-
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(
|
1132
|
+
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);
|
1132
1133
|
}
|
1133
1134
|
this._sysURL.hostname = h;
|
1134
1135
|
}
|
@@ -1271,13 +1272,13 @@ var BuildURI = class _BuildURI {
|
|
1271
1272
|
return URI.from(this._url);
|
1272
1273
|
}
|
1273
1274
|
};
|
1274
|
-
var
|
1275
|
+
var hasHostPartProtocols = /* @__PURE__ */ new Set(["http", "https", "ws", "wss"]);
|
1275
1276
|
var URI = class _URI {
|
1276
1277
|
static protocolHasHostpart(protocol) {
|
1277
1278
|
protocol = protocol.replace(/:$/, "");
|
1278
|
-
|
1279
|
+
hasHostPartProtocols.add(protocol);
|
1279
1280
|
return () => {
|
1280
|
-
|
1281
|
+
hasHostPartProtocols.delete(protocol);
|
1281
1282
|
};
|
1282
1283
|
}
|
1283
1284
|
// if no protocol is provided, default to file:
|
@@ -1361,6 +1362,22 @@ var URI = class _URI {
|
|
1361
1362
|
toJSON() {
|
1362
1363
|
return this.toString();
|
1363
1364
|
}
|
1365
|
+
asObj() {
|
1366
|
+
const pathURI = {
|
1367
|
+
style: "path",
|
1368
|
+
protocol: this.protocol,
|
1369
|
+
pathname: this.pathname,
|
1370
|
+
searchParams: Object.fromEntries(this.getParams)
|
1371
|
+
};
|
1372
|
+
if (hasHostPartProtocols.has(this.protocol.replace(/:$/, ""))) {
|
1373
|
+
return __spreadProps(__spreadValues({}, pathURI), {
|
1374
|
+
style: "host",
|
1375
|
+
hostname: this.hostname,
|
1376
|
+
port: this.port
|
1377
|
+
});
|
1378
|
+
}
|
1379
|
+
return pathURI;
|
1380
|
+
}
|
1364
1381
|
};
|
1365
1382
|
|
1366
1383
|
// src/runtime.ts
|
@@ -2329,6 +2346,26 @@ var VERSION = Object.keys({
|
|
2329
2346
|
__packageVersion__: "xxxx"
|
2330
2347
|
})[0];
|
2331
2348
|
|
2349
|
+
// src/refcounted.ts
|
2350
|
+
function wrapRefcounted(t, method) {
|
2351
|
+
const my2 = t;
|
2352
|
+
my2.__refcounted = (my2.__refcounted || 0) + 1;
|
2353
|
+
if (my2.__refcounted === 1) {
|
2354
|
+
my2.__unrefcounted = my2[method];
|
2355
|
+
const mRec = my2;
|
2356
|
+
mRec[method] = function() {
|
2357
|
+
this.__refcounted--;
|
2358
|
+
if (this.__refcounted === 0) {
|
2359
|
+
this.__unrefcounted();
|
2360
|
+
}
|
2361
|
+
if (this.__refcounted < 0) {
|
2362
|
+
throw new Error("already closed");
|
2363
|
+
}
|
2364
|
+
};
|
2365
|
+
}
|
2366
|
+
return t;
|
2367
|
+
}
|
2368
|
+
|
2332
2369
|
// src/utils/index.ts
|
2333
2370
|
var utils_exports = {};
|
2334
2371
|
__export(utils_exports, {
|
@@ -2582,12 +2619,13 @@ function uint8array2stream(str) {
|
|
2582
2619
|
bin2text,
|
2583
2620
|
envFactory,
|
2584
2621
|
exception2Result,
|
2622
|
+
hasHostPartProtocols,
|
2585
2623
|
isURL,
|
2586
2624
|
logValue,
|
2587
|
-
protocols,
|
2588
2625
|
removeSelfRef,
|
2589
2626
|
runtimeFn,
|
2590
2627
|
toCryptoRuntime,
|
2591
|
-
utils
|
2628
|
+
utils,
|
2629
|
+
wrapRefcounted
|
2592
2630
|
});
|
2593
2631
|
//# sourceMappingURL=index.cjs.map
|