@adviser/cement 0.2.16 → 0.2.18
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/{sys_abstraction-CmSCeK7b.d.cts → base-sys-abstraction-BzVP_lX0.d.cts} +77 -1
- package/{sys_abstraction-CmSCeK7b.d.ts → base-sys-abstraction-BzVP_lX0.d.ts} +77 -1
- package/chunk-AO7BGISE.js +353 -0
- package/chunk-AO7BGISE.js.map +1 -0
- package/{chunk-J2IM7FHM.js → chunk-I4NUGWZ6.js} +6 -1
- package/{chunk-XJF7FQUN.js → chunk-LJRKN3XI.js} +3 -3
- package/{chunk-XJF7FQUN.js.map → chunk-LJRKN3XI.js.map} +1 -1
- package/{chunk-O4F5AURC.js → chunk-P4FB5FHU.js} +185 -179
- package/chunk-P4FB5FHU.js.map +1 -0
- package/index-_GuS2IT4.d.cts +93 -0
- package/index-_GuS2IT4.d.ts +93 -0
- package/index.cjs +416 -52
- package/index.cjs.map +1 -1
- package/index.d.cts +27 -21
- package/index.d.ts +27 -21
- package/index.js +86 -49
- package/index.js.map +1 -1
- package/node/index.cjs +5 -5
- package/node/index.cjs.map +1 -1
- package/node/index.d.cts +1 -2
- package/node/index.d.ts +1 -2
- package/node/index.js +5 -5
- package/node/index.js.map +1 -1
- package/package.json +4 -4
- package/utils/index.cjs +98 -2
- package/utils/index.cjs.map +1 -1
- package/utils/index.d.cts +2 -36
- package/utils/index.d.ts +2 -36
- package/utils/index.js +21 -221
- package/utils/index.js.map +1 -1
- package/web/index.cjs +3 -3
- package/web/index.cjs.map +1 -1
- package/web/index.d.cts +1 -2
- package/web/index.d.ts +1 -2
- package/web/index.js +3 -3
- package/base_sys_abstraction-CJqRmTui.d.ts +0 -21
- package/base_sys_abstraction-nsNTl07w.d.cts +0 -21
- package/chunk-O4F5AURC.js.map +0 -1
- /package/{chunk-J2IM7FHM.js.map → chunk-I4NUGWZ6.js.map} +0 -0
package/index.cjs
CHANGED
|
@@ -74,11 +74,14 @@ var __yieldStar = (value) => {
|
|
|
74
74
|
// src/index.ts
|
|
75
75
|
var src_exports = {};
|
|
76
76
|
__export(src_exports, {
|
|
77
|
+
BaseSysAbstraction: () => BaseSysAbstraction,
|
|
77
78
|
BrowserEnvActions: () => BrowserEnvActions,
|
|
78
79
|
BuildURI: () => BuildURI,
|
|
80
|
+
ConstTime: () => ConstTime,
|
|
79
81
|
EnvImpl: () => EnvImpl,
|
|
80
82
|
Future: () => Future,
|
|
81
83
|
IDMode: () => IDMode,
|
|
84
|
+
IdService: () => IdService,
|
|
82
85
|
IsLogger: () => IsLogger,
|
|
83
86
|
Keyed: () => Keyed,
|
|
84
87
|
KeyedResolvOnce: () => KeyedResolvOnce,
|
|
@@ -87,30 +90,37 @@ __export(src_exports, {
|
|
|
87
90
|
LevelHandlerImpl: () => LevelHandlerImpl,
|
|
88
91
|
LogCollector: () => LogCollector,
|
|
89
92
|
LogValue: () => LogValue,
|
|
90
|
-
|
|
93
|
+
LogWriteStream: () => LogWriteStream,
|
|
94
|
+
LogWriterStream: () => LogWriterStream,
|
|
91
95
|
LoggerImpl: () => LoggerImpl,
|
|
92
96
|
MockLogger: () => MockLogger,
|
|
93
97
|
None: () => None,
|
|
94
98
|
Option: () => Option,
|
|
95
99
|
RandomMode: () => RandomMode,
|
|
100
|
+
RandomService: () => RandomService,
|
|
96
101
|
ResolveOnce: () => ResolveOnce,
|
|
97
102
|
ResolveSeq: () => ResolveSeq,
|
|
98
103
|
Result: () => Result,
|
|
99
104
|
ResultError: () => ResultError,
|
|
100
105
|
ResultOK: () => ResultOK,
|
|
101
106
|
Some: () => Some,
|
|
107
|
+
StepTime: () => StepTime,
|
|
102
108
|
String2TimeMode: () => String2TimeMode,
|
|
109
|
+
SysTime: () => SysTime,
|
|
103
110
|
Time: () => Time,
|
|
111
|
+
TimeFactory: () => TimeFactory,
|
|
104
112
|
TimeMode: () => TimeMode,
|
|
105
113
|
TimeUnits: () => TimeUnits,
|
|
106
114
|
URI: () => URI,
|
|
115
|
+
WrapperSysAbstraction: () => WrapperSysAbstraction,
|
|
107
116
|
asyncLogValue: () => asyncLogValue,
|
|
108
117
|
envFactory: () => envFactory,
|
|
109
118
|
isURL: () => isURL,
|
|
110
119
|
logValue: () => logValue,
|
|
111
120
|
removeSelfRef: () => removeSelfRef,
|
|
112
121
|
runtimeFn: () => runtimeFn,
|
|
113
|
-
toCryptoRuntime: () => toCryptoRuntime
|
|
122
|
+
toCryptoRuntime: () => toCryptoRuntime,
|
|
123
|
+
utils: () => utils_exports
|
|
114
124
|
});
|
|
115
125
|
module.exports = __toCommonJS(src_exports);
|
|
116
126
|
|
|
@@ -195,7 +205,7 @@ function IsLogger(obj) {
|
|
|
195
205
|
].map((fn) => typeof obj[fn] === "function").reduce((a, b) => a && b, true);
|
|
196
206
|
}
|
|
197
207
|
|
|
198
|
-
// src/
|
|
208
|
+
// src/sys-abstraction.ts
|
|
199
209
|
var TimeMode = /* @__PURE__ */ ((TimeMode2) => {
|
|
200
210
|
TimeMode2["REAL"] = "real";
|
|
201
211
|
TimeMode2["CONST"] = "const";
|
|
@@ -242,7 +252,7 @@ var TimeUnits = /* @__PURE__ */ ((TimeUnits2) => {
|
|
|
242
252
|
return TimeUnits2;
|
|
243
253
|
})(TimeUnits || {});
|
|
244
254
|
|
|
245
|
-
// src/
|
|
255
|
+
// src/base-sys-abstraction.ts
|
|
246
256
|
var SysTime = class extends Time {
|
|
247
257
|
Now() {
|
|
248
258
|
return /* @__PURE__ */ new Date();
|
|
@@ -586,7 +596,7 @@ var KeyedResolvSeq = class extends Keyed {
|
|
|
586
596
|
}
|
|
587
597
|
};
|
|
588
598
|
|
|
589
|
-
// src/
|
|
599
|
+
// src/sys-env.ts
|
|
590
600
|
var _node;
|
|
591
601
|
var NodeEnvActions = class {
|
|
592
602
|
// eslint-disable-next-line @typescript-eslint/no-useless-constructor, @typescript-eslint/no-unused-vars
|
|
@@ -756,7 +766,7 @@ var EnvImpl = class {
|
|
|
756
766
|
}
|
|
757
767
|
};
|
|
758
768
|
|
|
759
|
-
// src/web/
|
|
769
|
+
// src/web/web-sys-abstraction.ts
|
|
760
770
|
var WebFileService = class {
|
|
761
771
|
get baseDir() {
|
|
762
772
|
throw new Error("basedir-Method not implemented.");
|
|
@@ -1024,7 +1034,94 @@ var URI = class _URI {
|
|
|
1024
1034
|
}
|
|
1025
1035
|
};
|
|
1026
1036
|
|
|
1027
|
-
// src/
|
|
1037
|
+
// src/runtime.ts
|
|
1038
|
+
function isSet(value, ref = globalThis) {
|
|
1039
|
+
const [head, ...tail] = value.split(".");
|
|
1040
|
+
if (["object", "function"].includes(typeof ref) && ref && ["object", "function"].includes(typeof ref[head]) && ref[head]) {
|
|
1041
|
+
if (tail.length <= 1) {
|
|
1042
|
+
return true;
|
|
1043
|
+
}
|
|
1044
|
+
return isSet(tail.join("."), ref[head]);
|
|
1045
|
+
}
|
|
1046
|
+
return false;
|
|
1047
|
+
}
|
|
1048
|
+
function runtimeFn() {
|
|
1049
|
+
const isReactNative = isSet("navigator.product") && globalThis.navigator.product === "ReactNative";
|
|
1050
|
+
const isNodeIsh = isSet("process.versions.node") && !isReactNative;
|
|
1051
|
+
const isDeno = isSet("Deno") && !isReactNative;
|
|
1052
|
+
return {
|
|
1053
|
+
isNodeIsh,
|
|
1054
|
+
isBrowser: !(isNodeIsh || isDeno) && !isReactNative,
|
|
1055
|
+
isDeno,
|
|
1056
|
+
isReactNative
|
|
1057
|
+
};
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
// src/utils/console-write-stream.ts
|
|
1061
|
+
var ConsoleWriterStreamDefaultWriter = class {
|
|
1062
|
+
constructor(stream) {
|
|
1063
|
+
this.stream = stream;
|
|
1064
|
+
this.desiredSize = null;
|
|
1065
|
+
this.decoder = new TextDecoder();
|
|
1066
|
+
this._stream = stream;
|
|
1067
|
+
this.ready = Promise.resolve(void 0);
|
|
1068
|
+
this.closed = Promise.resolve(void 0);
|
|
1069
|
+
}
|
|
1070
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
1071
|
+
abort(reason) {
|
|
1072
|
+
throw new Error("Method not implemented.");
|
|
1073
|
+
}
|
|
1074
|
+
async close() {
|
|
1075
|
+
}
|
|
1076
|
+
releaseLock() {
|
|
1077
|
+
this._stream.locked = false;
|
|
1078
|
+
this.ready = Promise.resolve(void 0);
|
|
1079
|
+
this.closed = Promise.resolve(void 0);
|
|
1080
|
+
}
|
|
1081
|
+
async write(chunk) {
|
|
1082
|
+
const str = this.decoder.decode(chunk).trimEnd();
|
|
1083
|
+
let output = "log";
|
|
1084
|
+
try {
|
|
1085
|
+
const decode = JSON.parse(str);
|
|
1086
|
+
output = decode.level;
|
|
1087
|
+
} catch (e) {
|
|
1088
|
+
}
|
|
1089
|
+
switch (output) {
|
|
1090
|
+
case "error":
|
|
1091
|
+
console.error(str);
|
|
1092
|
+
break;
|
|
1093
|
+
case "warn":
|
|
1094
|
+
console.warn(str);
|
|
1095
|
+
break;
|
|
1096
|
+
default:
|
|
1097
|
+
console.log(str);
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
};
|
|
1101
|
+
var ConsoleWriterStream = class {
|
|
1102
|
+
constructor() {
|
|
1103
|
+
this.locked = false;
|
|
1104
|
+
}
|
|
1105
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
1106
|
+
abort(reason) {
|
|
1107
|
+
throw new Error("Method not implemented.");
|
|
1108
|
+
}
|
|
1109
|
+
async close() {
|
|
1110
|
+
return;
|
|
1111
|
+
}
|
|
1112
|
+
getWriter() {
|
|
1113
|
+
if (this.locked) {
|
|
1114
|
+
throw new Error("Stream is locked");
|
|
1115
|
+
}
|
|
1116
|
+
this.locked = true;
|
|
1117
|
+
if (!this._writer) {
|
|
1118
|
+
this._writer = new ConsoleWriterStreamDefaultWriter(this);
|
|
1119
|
+
}
|
|
1120
|
+
return this._writer;
|
|
1121
|
+
}
|
|
1122
|
+
};
|
|
1123
|
+
|
|
1124
|
+
// src/logger-impl.ts
|
|
1028
1125
|
var encoder = new TextEncoder();
|
|
1029
1126
|
var LevelHandlerImpl = class {
|
|
1030
1127
|
constructor() {
|
|
@@ -1102,7 +1199,7 @@ var LevelHandlerImpl = class {
|
|
|
1102
1199
|
}
|
|
1103
1200
|
};
|
|
1104
1201
|
var levelSingleton = new LevelHandlerImpl();
|
|
1105
|
-
var
|
|
1202
|
+
var LogWriterStream = class {
|
|
1106
1203
|
constructor(out) {
|
|
1107
1204
|
this._toFlush = [];
|
|
1108
1205
|
this._flushIsRunning = false;
|
|
@@ -1184,9 +1281,20 @@ var LoggerImpl = class _LoggerImpl {
|
|
|
1184
1281
|
this._logWriter = params.logWriter;
|
|
1185
1282
|
} else {
|
|
1186
1283
|
if (!params.out) {
|
|
1187
|
-
|
|
1284
|
+
const rt = runtimeFn();
|
|
1285
|
+
let stream;
|
|
1286
|
+
if (rt.isBrowser) {
|
|
1287
|
+
stream = new ConsoleWriterStream();
|
|
1288
|
+
} else {
|
|
1289
|
+
if (rt.isNodeIsh || rt.isReactNative) {
|
|
1290
|
+
stream = this._sys.Stdout();
|
|
1291
|
+
} else {
|
|
1292
|
+
throw new Error("No output defined for runtime");
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
this._logWriter = new LogWriterStream(stream);
|
|
1188
1296
|
} else {
|
|
1189
|
-
this._logWriter = new
|
|
1297
|
+
this._logWriter = new LogWriterStream(params.out);
|
|
1190
1298
|
}
|
|
1191
1299
|
}
|
|
1192
1300
|
if (!params.withAttributes) {
|
|
@@ -1482,29 +1590,52 @@ var WithLoggerBuilder = class {
|
|
|
1482
1590
|
}
|
|
1483
1591
|
};
|
|
1484
1592
|
|
|
1485
|
-
// src/
|
|
1486
|
-
var
|
|
1487
|
-
constructor() {
|
|
1488
|
-
this._bufferArr = [];
|
|
1593
|
+
// src/utils/fanout-write-stream.ts
|
|
1594
|
+
var FanoutWriteStream = class {
|
|
1595
|
+
constructor(writers) {
|
|
1489
1596
|
this.desiredSize = null;
|
|
1490
|
-
this.
|
|
1491
|
-
this.
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1597
|
+
this._writers = writers;
|
|
1598
|
+
this.ready = Promise.all(this._writers.map((w) => w.ready)).then(() => void 0);
|
|
1599
|
+
this.closed = Promise.all(this._writers.map((w) => w.closed)).then(() => void 0);
|
|
1600
|
+
}
|
|
1601
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1602
|
+
abort(reason) {
|
|
1603
|
+
return Promise.all(this._writers.map((w) => w.abort(reason))).then(() => {
|
|
1495
1604
|
});
|
|
1496
1605
|
}
|
|
1606
|
+
close() {
|
|
1607
|
+
return Promise.all(this._writers.map((w) => w.close())).then(() => {
|
|
1608
|
+
});
|
|
1609
|
+
}
|
|
1610
|
+
releaseLock() {
|
|
1611
|
+
this._writers.map((w) => w.releaseLock());
|
|
1612
|
+
}
|
|
1613
|
+
write(chunk) {
|
|
1614
|
+
return Promise.all(this._writers.map((w) => w.write(chunk))).then(() => {
|
|
1615
|
+
});
|
|
1616
|
+
}
|
|
1617
|
+
};
|
|
1618
|
+
|
|
1619
|
+
// src/test/log-write-stream.ts
|
|
1620
|
+
var LogWriteStream = class {
|
|
1621
|
+
constructor(bufferArr) {
|
|
1622
|
+
this._resolveClosed = new Future();
|
|
1623
|
+
this.closed = this._resolveClosed.asPromise();
|
|
1624
|
+
this.desiredSize = null;
|
|
1625
|
+
this.ready = Promise.resolve(void 0);
|
|
1626
|
+
this._bufferArr = bufferArr;
|
|
1627
|
+
}
|
|
1497
1628
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
1498
1629
|
abort(reason) {
|
|
1499
1630
|
throw new Error("Method not implemented.");
|
|
1500
1631
|
}
|
|
1501
|
-
close() {
|
|
1502
|
-
this.
|
|
1632
|
+
async close() {
|
|
1633
|
+
await this.closed;
|
|
1503
1634
|
return Promise.resolve(void 0);
|
|
1504
1635
|
}
|
|
1505
1636
|
releaseLock() {
|
|
1506
1637
|
}
|
|
1507
|
-
write(chunk) {
|
|
1638
|
+
async write(chunk) {
|
|
1508
1639
|
if (chunk) {
|
|
1509
1640
|
this._bufferArr.push(chunk);
|
|
1510
1641
|
}
|
|
@@ -1512,8 +1643,10 @@ var LogWriter2 = class {
|
|
|
1512
1643
|
}
|
|
1513
1644
|
};
|
|
1514
1645
|
var LogCollector = class {
|
|
1515
|
-
constructor() {
|
|
1646
|
+
constructor(pass) {
|
|
1516
1647
|
this.locked = false;
|
|
1648
|
+
this._bufferArr = [];
|
|
1649
|
+
this._pass = pass;
|
|
1517
1650
|
}
|
|
1518
1651
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1519
1652
|
abort(reason) {
|
|
@@ -1529,7 +1662,11 @@ var LogCollector = class {
|
|
|
1529
1662
|
}
|
|
1530
1663
|
getWriter() {
|
|
1531
1664
|
if (!this._writer) {
|
|
1532
|
-
|
|
1665
|
+
const dests = [new LogWriteStream(this._bufferArr)];
|
|
1666
|
+
if (this._pass) {
|
|
1667
|
+
dests.push(this._pass);
|
|
1668
|
+
}
|
|
1669
|
+
this._writer = new FanoutWriteStream(dests);
|
|
1533
1670
|
}
|
|
1534
1671
|
return this._writer;
|
|
1535
1672
|
}
|
|
@@ -1544,7 +1681,7 @@ var LogCollector = class {
|
|
|
1544
1681
|
for (const x of res) {
|
|
1545
1682
|
yield* __yieldStar(x);
|
|
1546
1683
|
}
|
|
1547
|
-
}(this.
|
|
1684
|
+
}(this._bufferArr)
|
|
1548
1685
|
)
|
|
1549
1686
|
);
|
|
1550
1687
|
const splitStr = jsonNlStr.split("\n");
|
|
@@ -1554,9 +1691,9 @@ var LogCollector = class {
|
|
|
1554
1691
|
}
|
|
1555
1692
|
};
|
|
1556
1693
|
|
|
1557
|
-
// src/test/
|
|
1694
|
+
// src/test/mock-logger.ts
|
|
1558
1695
|
function MockLogger(params) {
|
|
1559
|
-
const lc = new LogCollector();
|
|
1696
|
+
const lc = new LogCollector(params == null ? void 0 : params.pass);
|
|
1560
1697
|
let modNames = ["MockLogger"];
|
|
1561
1698
|
if (typeof (params == null ? void 0 : params.moduleName) === "string") {
|
|
1562
1699
|
modNames = [params == null ? void 0 : params.moduleName];
|
|
@@ -1699,29 +1836,6 @@ var None = class extends Option {
|
|
|
1699
1836
|
}
|
|
1700
1837
|
};
|
|
1701
1838
|
|
|
1702
|
-
// src/runtime.ts
|
|
1703
|
-
function isSet(value, ref = globalThis) {
|
|
1704
|
-
const [head, ...tail] = value.split(".");
|
|
1705
|
-
if (["object", "function"].includes(typeof ref) && ref && ["object", "function"].includes(typeof ref[head]) && ref[head]) {
|
|
1706
|
-
if (tail.length <= 1) {
|
|
1707
|
-
return true;
|
|
1708
|
-
}
|
|
1709
|
-
return isSet(tail.join("."), ref[head]);
|
|
1710
|
-
}
|
|
1711
|
-
return false;
|
|
1712
|
-
}
|
|
1713
|
-
function runtimeFn() {
|
|
1714
|
-
const isReactNative = isSet("navigator.product") && globalThis.navigator.product === "ReactNative";
|
|
1715
|
-
const isNodeIsh = isSet("process.versions.node") && !isReactNative;
|
|
1716
|
-
const isDeno = isSet("Deno") && !isReactNative;
|
|
1717
|
-
return {
|
|
1718
|
-
isNodeIsh,
|
|
1719
|
-
isBrowser: !(isNodeIsh || isDeno) && !isReactNative,
|
|
1720
|
-
isDeno,
|
|
1721
|
-
isReactNative
|
|
1722
|
-
};
|
|
1723
|
-
}
|
|
1724
|
-
|
|
1725
1839
|
// src/crypto.ts
|
|
1726
1840
|
function randomBytes(size) {
|
|
1727
1841
|
const bytes = new Uint8Array(size);
|
|
@@ -1743,13 +1857,256 @@ function toCryptoRuntime(cryptoOpts = {}) {
|
|
|
1743
1857
|
};
|
|
1744
1858
|
return runtime;
|
|
1745
1859
|
}
|
|
1860
|
+
|
|
1861
|
+
// src/utils/index.ts
|
|
1862
|
+
var utils_exports = {};
|
|
1863
|
+
__export(utils_exports, {
|
|
1864
|
+
ConsoleWriterStream: () => ConsoleWriterStream,
|
|
1865
|
+
ConsoleWriterStreamDefaultWriter: () => ConsoleWriterStreamDefaultWriter,
|
|
1866
|
+
FanoutWriteStream: () => FanoutWriteStream,
|
|
1867
|
+
array2stream: () => array2stream,
|
|
1868
|
+
devnull: () => devnull,
|
|
1869
|
+
rebuffer: () => rebuffer,
|
|
1870
|
+
rebufferArray: () => rebufferArray,
|
|
1871
|
+
receiveFromStream: () => receiveFromStream,
|
|
1872
|
+
sendToStream: () => sendToStream,
|
|
1873
|
+
stream2array: () => stream2array,
|
|
1874
|
+
stream2string: () => stream2string,
|
|
1875
|
+
stream2uint8array: () => stream2uint8array,
|
|
1876
|
+
streamMap: () => streamMap,
|
|
1877
|
+
string2stream: () => string2stream,
|
|
1878
|
+
uint8array2stream: () => uint8array2stream
|
|
1879
|
+
});
|
|
1880
|
+
|
|
1881
|
+
// src/utils/stream-map.ts
|
|
1882
|
+
function streamMap(s, sm) {
|
|
1883
|
+
const state = { reader: s.getReader(), streamMap: sm, idx: 0 };
|
|
1884
|
+
return new ReadableStream({
|
|
1885
|
+
async pull(controller) {
|
|
1886
|
+
const { done, value } = await state.reader.read();
|
|
1887
|
+
if (done) {
|
|
1888
|
+
if (state.streamMap.Close) {
|
|
1889
|
+
state.streamMap.Close();
|
|
1890
|
+
}
|
|
1891
|
+
controller.close();
|
|
1892
|
+
return;
|
|
1893
|
+
}
|
|
1894
|
+
const promiseOrU = state.streamMap.Map(value, state.idx++);
|
|
1895
|
+
let mapped;
|
|
1896
|
+
if (promiseOrU instanceof Promise || typeof promiseOrU.then === "function") {
|
|
1897
|
+
mapped = await promiseOrU;
|
|
1898
|
+
} else {
|
|
1899
|
+
mapped = promiseOrU;
|
|
1900
|
+
}
|
|
1901
|
+
controller.enqueue(mapped);
|
|
1902
|
+
}
|
|
1903
|
+
});
|
|
1904
|
+
}
|
|
1905
|
+
async function devnull(a) {
|
|
1906
|
+
const reader = a.getReader();
|
|
1907
|
+
let cnt = 0;
|
|
1908
|
+
while (true) {
|
|
1909
|
+
const { done } = await reader.read();
|
|
1910
|
+
if (done) {
|
|
1911
|
+
break;
|
|
1912
|
+
}
|
|
1913
|
+
cnt++;
|
|
1914
|
+
}
|
|
1915
|
+
return cnt;
|
|
1916
|
+
}
|
|
1917
|
+
function array2stream(a) {
|
|
1918
|
+
let i = 0;
|
|
1919
|
+
return new ReadableStream({
|
|
1920
|
+
pull(controller) {
|
|
1921
|
+
if (i >= a.length) {
|
|
1922
|
+
controller.close();
|
|
1923
|
+
return;
|
|
1924
|
+
}
|
|
1925
|
+
controller.enqueue(a[i]);
|
|
1926
|
+
i++;
|
|
1927
|
+
}
|
|
1928
|
+
});
|
|
1929
|
+
}
|
|
1930
|
+
async function stream2array(a) {
|
|
1931
|
+
const ret = [];
|
|
1932
|
+
const reader = a.getReader();
|
|
1933
|
+
while (true) {
|
|
1934
|
+
const { done, value } = await reader.read();
|
|
1935
|
+
if (done) {
|
|
1936
|
+
break;
|
|
1937
|
+
}
|
|
1938
|
+
ret.push(value);
|
|
1939
|
+
}
|
|
1940
|
+
return ret;
|
|
1941
|
+
}
|
|
1942
|
+
|
|
1943
|
+
// src/utils/rebuffer.ts
|
|
1944
|
+
async function rebufferArray(a, chunkSize) {
|
|
1945
|
+
return stream2array(rebuffer(array2stream(a), chunkSize));
|
|
1946
|
+
}
|
|
1947
|
+
function reChunk(cs, chunkSize) {
|
|
1948
|
+
const len = cs.reduce((acc, v) => acc + v.length, 0);
|
|
1949
|
+
const last = cs[cs.length - 1];
|
|
1950
|
+
const lastOfs = len - last.length;
|
|
1951
|
+
const rest = last.subarray(chunkSize - lastOfs);
|
|
1952
|
+
cs[cs.length - 1] = last.subarray(0, chunkSize - lastOfs);
|
|
1953
|
+
const chunk = new Uint8Array(chunkSize);
|
|
1954
|
+
let ofs = 0;
|
|
1955
|
+
for (const c of cs) {
|
|
1956
|
+
chunk.set(c, ofs);
|
|
1957
|
+
ofs += c.length;
|
|
1958
|
+
}
|
|
1959
|
+
return { rest, chunk };
|
|
1960
|
+
}
|
|
1961
|
+
function pump(ps, controller, next) {
|
|
1962
|
+
ps.reader.read().then(({ done, value }) => {
|
|
1963
|
+
if (done) {
|
|
1964
|
+
if (ps.tmpLen > 0) {
|
|
1965
|
+
controller.enqueue(reChunk(ps.tmp, ps.tmpLen).chunk);
|
|
1966
|
+
}
|
|
1967
|
+
controller.close();
|
|
1968
|
+
next();
|
|
1969
|
+
return;
|
|
1970
|
+
}
|
|
1971
|
+
if (ps.tmpLen + value.length > ps.chunkSize) {
|
|
1972
|
+
ps.tmp.push(value);
|
|
1973
|
+
const res = reChunk(ps.tmp, ps.chunkSize);
|
|
1974
|
+
controller.enqueue(res.chunk);
|
|
1975
|
+
ps.tmp = [res.rest];
|
|
1976
|
+
ps.tmpLen = res.rest.length;
|
|
1977
|
+
next();
|
|
1978
|
+
return;
|
|
1979
|
+
} else if (value.length) {
|
|
1980
|
+
ps.tmp.push(value);
|
|
1981
|
+
ps.tmpLen += value.length;
|
|
1982
|
+
}
|
|
1983
|
+
pump(ps, controller, next);
|
|
1984
|
+
});
|
|
1985
|
+
}
|
|
1986
|
+
function rebuffer(a, chunkSize) {
|
|
1987
|
+
const state = {
|
|
1988
|
+
reader: a.getReader(),
|
|
1989
|
+
tmp: [],
|
|
1990
|
+
tmpLen: 0,
|
|
1991
|
+
chunkSize
|
|
1992
|
+
};
|
|
1993
|
+
return new ReadableStream({
|
|
1994
|
+
async pull(controller) {
|
|
1995
|
+
return new Promise((resolve) => {
|
|
1996
|
+
pump(state, controller, resolve);
|
|
1997
|
+
});
|
|
1998
|
+
}
|
|
1999
|
+
});
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
// src/utils/stream2string.ts
|
|
2003
|
+
async function stream2string(stream, maxSize) {
|
|
2004
|
+
if (!stream) {
|
|
2005
|
+
return Promise.resolve("");
|
|
2006
|
+
}
|
|
2007
|
+
const reader = stream.getReader();
|
|
2008
|
+
let res = "";
|
|
2009
|
+
const decoder2 = new TextDecoder();
|
|
2010
|
+
let rSize = 0;
|
|
2011
|
+
while (typeof maxSize === "undefined" || rSize < maxSize) {
|
|
2012
|
+
try {
|
|
2013
|
+
const read = await reader.read();
|
|
2014
|
+
if (read.done) {
|
|
2015
|
+
break;
|
|
2016
|
+
}
|
|
2017
|
+
if (maxSize && rSize + read.value.length > maxSize) {
|
|
2018
|
+
read.value = read.value.slice(0, maxSize - rSize);
|
|
2019
|
+
}
|
|
2020
|
+
const block = decoder2.decode(read.value, { stream: true });
|
|
2021
|
+
rSize += read.value.length;
|
|
2022
|
+
res += block;
|
|
2023
|
+
} catch (err) {
|
|
2024
|
+
return Promise.reject(err);
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
return Promise.resolve(res);
|
|
2028
|
+
}
|
|
2029
|
+
async function stream2uint8array(stream) {
|
|
2030
|
+
if (!stream) {
|
|
2031
|
+
return Promise.resolve(new Uint8Array());
|
|
2032
|
+
}
|
|
2033
|
+
const reader = stream.getReader();
|
|
2034
|
+
let res = new Uint8Array();
|
|
2035
|
+
while (1) {
|
|
2036
|
+
try {
|
|
2037
|
+
const { done, value } = await reader.read();
|
|
2038
|
+
if (done) {
|
|
2039
|
+
break;
|
|
2040
|
+
}
|
|
2041
|
+
res = new Uint8Array([...res, ...value]);
|
|
2042
|
+
} catch (err) {
|
|
2043
|
+
return Promise.reject(err);
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
return Promise.resolve(res);
|
|
2047
|
+
}
|
|
2048
|
+
|
|
2049
|
+
// src/utils/stream-test-helper.ts
|
|
2050
|
+
async function receiveFromStream(reb, state) {
|
|
2051
|
+
return new Promise((resolve) => {
|
|
2052
|
+
let reBufferCalls = 0;
|
|
2053
|
+
const reader = reb.getReader();
|
|
2054
|
+
function pump2() {
|
|
2055
|
+
reader.read().then(({ done, value }) => {
|
|
2056
|
+
state.CollectorFn({ done, value, fillCalls: state.fillCalls, reBufferCalls });
|
|
2057
|
+
reBufferCalls++;
|
|
2058
|
+
if (done) {
|
|
2059
|
+
resolve();
|
|
2060
|
+
return;
|
|
2061
|
+
}
|
|
2062
|
+
pump2();
|
|
2063
|
+
});
|
|
2064
|
+
}
|
|
2065
|
+
pump2();
|
|
2066
|
+
});
|
|
2067
|
+
}
|
|
2068
|
+
async function sendToStream(reb, state) {
|
|
2069
|
+
return new Promise((resolve) => {
|
|
2070
|
+
const writer = reb.getWriter();
|
|
2071
|
+
function pump2(i) {
|
|
2072
|
+
if (i >= state.sendChunks) {
|
|
2073
|
+
writer.close();
|
|
2074
|
+
resolve();
|
|
2075
|
+
return;
|
|
2076
|
+
}
|
|
2077
|
+
writer.ready.then(() => {
|
|
2078
|
+
state.fillCalls++;
|
|
2079
|
+
writer.write(new Uint8Array(Array(state.sendChunkSize).fill(i)));
|
|
2080
|
+
pump2(i + 1);
|
|
2081
|
+
});
|
|
2082
|
+
}
|
|
2083
|
+
pump2(0);
|
|
2084
|
+
});
|
|
2085
|
+
}
|
|
2086
|
+
|
|
2087
|
+
// src/utils/string2stream.ts
|
|
2088
|
+
function string2stream(str) {
|
|
2089
|
+
const encoder2 = new TextEncoder();
|
|
2090
|
+
return uint8array2stream(encoder2.encode(str));
|
|
2091
|
+
}
|
|
2092
|
+
function uint8array2stream(str) {
|
|
2093
|
+
return new ReadableStream({
|
|
2094
|
+
start(controller) {
|
|
2095
|
+
controller.enqueue(str);
|
|
2096
|
+
controller.close();
|
|
2097
|
+
}
|
|
2098
|
+
});
|
|
2099
|
+
}
|
|
1746
2100
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1747
2101
|
0 && (module.exports = {
|
|
2102
|
+
BaseSysAbstraction,
|
|
1748
2103
|
BrowserEnvActions,
|
|
1749
2104
|
BuildURI,
|
|
2105
|
+
ConstTime,
|
|
1750
2106
|
EnvImpl,
|
|
1751
2107
|
Future,
|
|
1752
2108
|
IDMode,
|
|
2109
|
+
IdService,
|
|
1753
2110
|
IsLogger,
|
|
1754
2111
|
Keyed,
|
|
1755
2112
|
KeyedResolvOnce,
|
|
@@ -1758,29 +2115,36 @@ function toCryptoRuntime(cryptoOpts = {}) {
|
|
|
1758
2115
|
LevelHandlerImpl,
|
|
1759
2116
|
LogCollector,
|
|
1760
2117
|
LogValue,
|
|
1761
|
-
|
|
2118
|
+
LogWriteStream,
|
|
2119
|
+
LogWriterStream,
|
|
1762
2120
|
LoggerImpl,
|
|
1763
2121
|
MockLogger,
|
|
1764
2122
|
None,
|
|
1765
2123
|
Option,
|
|
1766
2124
|
RandomMode,
|
|
2125
|
+
RandomService,
|
|
1767
2126
|
ResolveOnce,
|
|
1768
2127
|
ResolveSeq,
|
|
1769
2128
|
Result,
|
|
1770
2129
|
ResultError,
|
|
1771
2130
|
ResultOK,
|
|
1772
2131
|
Some,
|
|
2132
|
+
StepTime,
|
|
1773
2133
|
String2TimeMode,
|
|
2134
|
+
SysTime,
|
|
1774
2135
|
Time,
|
|
2136
|
+
TimeFactory,
|
|
1775
2137
|
TimeMode,
|
|
1776
2138
|
TimeUnits,
|
|
1777
2139
|
URI,
|
|
2140
|
+
WrapperSysAbstraction,
|
|
1778
2141
|
asyncLogValue,
|
|
1779
2142
|
envFactory,
|
|
1780
2143
|
isURL,
|
|
1781
2144
|
logValue,
|
|
1782
2145
|
removeSelfRef,
|
|
1783
2146
|
runtimeFn,
|
|
1784
|
-
toCryptoRuntime
|
|
2147
|
+
toCryptoRuntime,
|
|
2148
|
+
utils
|
|
1785
2149
|
});
|
|
1786
2150
|
//# sourceMappingURL=index.cjs.map
|