@adviser/cement 0.2.17 → 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 +362 -102
- package/index.cjs.map +1 -1
- package/index.d.cts +8 -18
- package/index.d.ts +8 -18
- package/index.js +33 -98
- 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 +1 -1
- 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,12 +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
|
-
FanoutWriter: () => FanoutWriter,
|
|
81
82
|
Future: () => Future,
|
|
82
83
|
IDMode: () => IDMode,
|
|
84
|
+
IdService: () => IdService,
|
|
83
85
|
IsLogger: () => IsLogger,
|
|
84
86
|
Keyed: () => Keyed,
|
|
85
87
|
KeyedResolvOnce: () => KeyedResolvOnce,
|
|
@@ -88,31 +90,37 @@ __export(src_exports, {
|
|
|
88
90
|
LevelHandlerImpl: () => LevelHandlerImpl,
|
|
89
91
|
LogCollector: () => LogCollector,
|
|
90
92
|
LogValue: () => LogValue,
|
|
91
|
-
|
|
93
|
+
LogWriteStream: () => LogWriteStream,
|
|
92
94
|
LogWriterStream: () => LogWriterStream,
|
|
93
95
|
LoggerImpl: () => LoggerImpl,
|
|
94
96
|
MockLogger: () => MockLogger,
|
|
95
97
|
None: () => None,
|
|
96
98
|
Option: () => Option,
|
|
97
99
|
RandomMode: () => RandomMode,
|
|
100
|
+
RandomService: () => RandomService,
|
|
98
101
|
ResolveOnce: () => ResolveOnce,
|
|
99
102
|
ResolveSeq: () => ResolveSeq,
|
|
100
103
|
Result: () => Result,
|
|
101
104
|
ResultError: () => ResultError,
|
|
102
105
|
ResultOK: () => ResultOK,
|
|
103
106
|
Some: () => Some,
|
|
107
|
+
StepTime: () => StepTime,
|
|
104
108
|
String2TimeMode: () => String2TimeMode,
|
|
109
|
+
SysTime: () => SysTime,
|
|
105
110
|
Time: () => Time,
|
|
111
|
+
TimeFactory: () => TimeFactory,
|
|
106
112
|
TimeMode: () => TimeMode,
|
|
107
113
|
TimeUnits: () => TimeUnits,
|
|
108
114
|
URI: () => URI,
|
|
115
|
+
WrapperSysAbstraction: () => WrapperSysAbstraction,
|
|
109
116
|
asyncLogValue: () => asyncLogValue,
|
|
110
117
|
envFactory: () => envFactory,
|
|
111
118
|
isURL: () => isURL,
|
|
112
119
|
logValue: () => logValue,
|
|
113
120
|
removeSelfRef: () => removeSelfRef,
|
|
114
121
|
runtimeFn: () => runtimeFn,
|
|
115
|
-
toCryptoRuntime: () => toCryptoRuntime
|
|
122
|
+
toCryptoRuntime: () => toCryptoRuntime,
|
|
123
|
+
utils: () => utils_exports
|
|
116
124
|
});
|
|
117
125
|
module.exports = __toCommonJS(src_exports);
|
|
118
126
|
|
|
@@ -197,7 +205,7 @@ function IsLogger(obj) {
|
|
|
197
205
|
].map((fn) => typeof obj[fn] === "function").reduce((a, b) => a && b, true);
|
|
198
206
|
}
|
|
199
207
|
|
|
200
|
-
// src/
|
|
208
|
+
// src/sys-abstraction.ts
|
|
201
209
|
var TimeMode = /* @__PURE__ */ ((TimeMode2) => {
|
|
202
210
|
TimeMode2["REAL"] = "real";
|
|
203
211
|
TimeMode2["CONST"] = "const";
|
|
@@ -244,7 +252,7 @@ var TimeUnits = /* @__PURE__ */ ((TimeUnits2) => {
|
|
|
244
252
|
return TimeUnits2;
|
|
245
253
|
})(TimeUnits || {});
|
|
246
254
|
|
|
247
|
-
// src/
|
|
255
|
+
// src/base-sys-abstraction.ts
|
|
248
256
|
var SysTime = class extends Time {
|
|
249
257
|
Now() {
|
|
250
258
|
return /* @__PURE__ */ new Date();
|
|
@@ -588,7 +596,7 @@ var KeyedResolvSeq = class extends Keyed {
|
|
|
588
596
|
}
|
|
589
597
|
};
|
|
590
598
|
|
|
591
|
-
// src/
|
|
599
|
+
// src/sys-env.ts
|
|
592
600
|
var _node;
|
|
593
601
|
var NodeEnvActions = class {
|
|
594
602
|
// eslint-disable-next-line @typescript-eslint/no-useless-constructor, @typescript-eslint/no-unused-vars
|
|
@@ -758,7 +766,7 @@ var EnvImpl = class {
|
|
|
758
766
|
}
|
|
759
767
|
};
|
|
760
768
|
|
|
761
|
-
// src/web/
|
|
769
|
+
// src/web/web-sys-abstraction.ts
|
|
762
770
|
var WebFileService = class {
|
|
763
771
|
get baseDir() {
|
|
764
772
|
throw new Error("basedir-Method not implemented.");
|
|
@@ -1049,7 +1057,71 @@ function runtimeFn() {
|
|
|
1049
1057
|
};
|
|
1050
1058
|
}
|
|
1051
1059
|
|
|
1052
|
-
// src/
|
|
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
|
|
1053
1125
|
var encoder = new TextEncoder();
|
|
1054
1126
|
var LevelHandlerImpl = class {
|
|
1055
1127
|
constructor() {
|
|
@@ -1193,68 +1265,6 @@ function toLogValue(lop) {
|
|
|
1193
1265
|
}
|
|
1194
1266
|
return lop;
|
|
1195
1267
|
}
|
|
1196
|
-
var ConsoleWriterStreamDefaultWriter = class {
|
|
1197
|
-
constructor(stream) {
|
|
1198
|
-
this.stream = stream;
|
|
1199
|
-
this.desiredSize = null;
|
|
1200
|
-
this.decoder = new TextDecoder();
|
|
1201
|
-
this._stream = stream;
|
|
1202
|
-
this.ready = Promise.resolve(void 0);
|
|
1203
|
-
this.closed = Promise.resolve(void 0);
|
|
1204
|
-
}
|
|
1205
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
1206
|
-
abort(reason) {
|
|
1207
|
-
throw new Error("Method not implemented.");
|
|
1208
|
-
}
|
|
1209
|
-
async close() {
|
|
1210
|
-
}
|
|
1211
|
-
releaseLock() {
|
|
1212
|
-
this._stream.locked = false;
|
|
1213
|
-
this.ready = Promise.resolve(void 0);
|
|
1214
|
-
this.closed = Promise.resolve(void 0);
|
|
1215
|
-
}
|
|
1216
|
-
async write(chunk) {
|
|
1217
|
-
const str = this.decoder.decode(chunk).trimEnd();
|
|
1218
|
-
let output = "log";
|
|
1219
|
-
try {
|
|
1220
|
-
const decode = JSON.parse(str);
|
|
1221
|
-
output = decode.level;
|
|
1222
|
-
} catch (e) {
|
|
1223
|
-
}
|
|
1224
|
-
switch (output) {
|
|
1225
|
-
case "error":
|
|
1226
|
-
console.error(str);
|
|
1227
|
-
break;
|
|
1228
|
-
case "warn":
|
|
1229
|
-
console.warn(str);
|
|
1230
|
-
break;
|
|
1231
|
-
default:
|
|
1232
|
-
console.log(str);
|
|
1233
|
-
}
|
|
1234
|
-
}
|
|
1235
|
-
};
|
|
1236
|
-
var ConsoleWriterStream = class {
|
|
1237
|
-
constructor() {
|
|
1238
|
-
this.locked = false;
|
|
1239
|
-
}
|
|
1240
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
1241
|
-
abort(reason) {
|
|
1242
|
-
throw new Error("Method not implemented.");
|
|
1243
|
-
}
|
|
1244
|
-
async close() {
|
|
1245
|
-
return;
|
|
1246
|
-
}
|
|
1247
|
-
getWriter() {
|
|
1248
|
-
if (this.locked) {
|
|
1249
|
-
throw new Error("Stream is locked");
|
|
1250
|
-
}
|
|
1251
|
-
this.locked = true;
|
|
1252
|
-
if (!this._writer) {
|
|
1253
|
-
this._writer = new ConsoleWriterStreamDefaultWriter(this);
|
|
1254
|
-
}
|
|
1255
|
-
return this._writer;
|
|
1256
|
-
}
|
|
1257
|
-
};
|
|
1258
1268
|
var LoggerImpl = class _LoggerImpl {
|
|
1259
1269
|
// readonly _id: string = "logger-" + Math.random().toString(36)
|
|
1260
1270
|
constructor(params) {
|
|
@@ -1580,8 +1590,34 @@ var WithLoggerBuilder = class {
|
|
|
1580
1590
|
}
|
|
1581
1591
|
};
|
|
1582
1592
|
|
|
1583
|
-
// src/
|
|
1584
|
-
var
|
|
1593
|
+
// src/utils/fanout-write-stream.ts
|
|
1594
|
+
var FanoutWriteStream = class {
|
|
1595
|
+
constructor(writers) {
|
|
1596
|
+
this.desiredSize = null;
|
|
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(() => {
|
|
1604
|
+
});
|
|
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 {
|
|
1585
1621
|
constructor(bufferArr) {
|
|
1586
1622
|
this._resolveClosed = new Future();
|
|
1587
1623
|
this.closed = this._resolveClosed.asPromise();
|
|
@@ -1606,30 +1642,6 @@ var LogWriterCollector = class {
|
|
|
1606
1642
|
return Promise.resolve(void 0);
|
|
1607
1643
|
}
|
|
1608
1644
|
};
|
|
1609
|
-
var FanoutWriter = class {
|
|
1610
|
-
constructor(writers) {
|
|
1611
|
-
this.desiredSize = null;
|
|
1612
|
-
this._writers = writers;
|
|
1613
|
-
this.ready = Promise.all(this._writers.map((w) => w.ready)).then(() => void 0);
|
|
1614
|
-
this.closed = Promise.all(this._writers.map((w) => w.closed)).then(() => void 0);
|
|
1615
|
-
}
|
|
1616
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1617
|
-
abort(reason) {
|
|
1618
|
-
return Promise.all(this._writers.map((w) => w.abort(reason))).then(() => {
|
|
1619
|
-
});
|
|
1620
|
-
}
|
|
1621
|
-
close() {
|
|
1622
|
-
return Promise.all(this._writers.map((w) => w.close())).then(() => {
|
|
1623
|
-
});
|
|
1624
|
-
}
|
|
1625
|
-
releaseLock() {
|
|
1626
|
-
this._writers.map((w) => w.releaseLock());
|
|
1627
|
-
}
|
|
1628
|
-
write(chunk) {
|
|
1629
|
-
return Promise.all(this._writers.map((w) => w.write(chunk))).then(() => {
|
|
1630
|
-
});
|
|
1631
|
-
}
|
|
1632
|
-
};
|
|
1633
1645
|
var LogCollector = class {
|
|
1634
1646
|
constructor(pass) {
|
|
1635
1647
|
this.locked = false;
|
|
@@ -1650,11 +1662,11 @@ var LogCollector = class {
|
|
|
1650
1662
|
}
|
|
1651
1663
|
getWriter() {
|
|
1652
1664
|
if (!this._writer) {
|
|
1653
|
-
const dests = [new
|
|
1665
|
+
const dests = [new LogWriteStream(this._bufferArr)];
|
|
1654
1666
|
if (this._pass) {
|
|
1655
1667
|
dests.push(this._pass);
|
|
1656
1668
|
}
|
|
1657
|
-
this._writer = new
|
|
1669
|
+
this._writer = new FanoutWriteStream(dests);
|
|
1658
1670
|
}
|
|
1659
1671
|
return this._writer;
|
|
1660
1672
|
}
|
|
@@ -1679,7 +1691,7 @@ var LogCollector = class {
|
|
|
1679
1691
|
}
|
|
1680
1692
|
};
|
|
1681
1693
|
|
|
1682
|
-
// src/test/
|
|
1694
|
+
// src/test/mock-logger.ts
|
|
1683
1695
|
function MockLogger(params) {
|
|
1684
1696
|
const lc = new LogCollector(params == null ? void 0 : params.pass);
|
|
1685
1697
|
let modNames = ["MockLogger"];
|
|
@@ -1845,14 +1857,256 @@ function toCryptoRuntime(cryptoOpts = {}) {
|
|
|
1845
1857
|
};
|
|
1846
1858
|
return runtime;
|
|
1847
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
|
+
}
|
|
1848
2100
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1849
2101
|
0 && (module.exports = {
|
|
2102
|
+
BaseSysAbstraction,
|
|
1850
2103
|
BrowserEnvActions,
|
|
1851
2104
|
BuildURI,
|
|
2105
|
+
ConstTime,
|
|
1852
2106
|
EnvImpl,
|
|
1853
|
-
FanoutWriter,
|
|
1854
2107
|
Future,
|
|
1855
2108
|
IDMode,
|
|
2109
|
+
IdService,
|
|
1856
2110
|
IsLogger,
|
|
1857
2111
|
Keyed,
|
|
1858
2112
|
KeyedResolvOnce,
|
|
@@ -1861,30 +2115,36 @@ function toCryptoRuntime(cryptoOpts = {}) {
|
|
|
1861
2115
|
LevelHandlerImpl,
|
|
1862
2116
|
LogCollector,
|
|
1863
2117
|
LogValue,
|
|
1864
|
-
|
|
2118
|
+
LogWriteStream,
|
|
1865
2119
|
LogWriterStream,
|
|
1866
2120
|
LoggerImpl,
|
|
1867
2121
|
MockLogger,
|
|
1868
2122
|
None,
|
|
1869
2123
|
Option,
|
|
1870
2124
|
RandomMode,
|
|
2125
|
+
RandomService,
|
|
1871
2126
|
ResolveOnce,
|
|
1872
2127
|
ResolveSeq,
|
|
1873
2128
|
Result,
|
|
1874
2129
|
ResultError,
|
|
1875
2130
|
ResultOK,
|
|
1876
2131
|
Some,
|
|
2132
|
+
StepTime,
|
|
1877
2133
|
String2TimeMode,
|
|
2134
|
+
SysTime,
|
|
1878
2135
|
Time,
|
|
2136
|
+
TimeFactory,
|
|
1879
2137
|
TimeMode,
|
|
1880
2138
|
TimeUnits,
|
|
1881
2139
|
URI,
|
|
2140
|
+
WrapperSysAbstraction,
|
|
1882
2141
|
asyncLogValue,
|
|
1883
2142
|
envFactory,
|
|
1884
2143
|
isURL,
|
|
1885
2144
|
logValue,
|
|
1886
2145
|
removeSelfRef,
|
|
1887
2146
|
runtimeFn,
|
|
1888
|
-
toCryptoRuntime
|
|
2147
|
+
toCryptoRuntime,
|
|
2148
|
+
utils
|
|
1889
2149
|
});
|
|
1890
2150
|
//# sourceMappingURL=index.cjs.map
|