@adviser/cement 0.0.0-jsr-t1
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +201 -0
- package/README.md +39 -0
- package/base-sys-abstraction-BkEiLHl0.d.ts +193 -0
- package/base-sys-abstraction-Qj7pkY1N.d.cts +193 -0
- package/chunk-7KFVMTOS.js +311 -0
- package/chunk-7KFVMTOS.js.map +1 -0
- package/chunk-GES3MUGV.js +92 -0
- package/chunk-GES3MUGV.js.map +1 -0
- package/chunk-Q65HLCNL.js +601 -0
- package/chunk-Q65HLCNL.js.map +1 -0
- package/chunk-WMMUXBDX.js +87 -0
- package/chunk-WMMUXBDX.js.map +1 -0
- package/index-Q3phXzYr.d.cts +75 -0
- package/index-tIGZMHTc.d.ts +75 -0
- package/index.cjs +2593 -0
- package/index.cjs.map +1 -0
- package/index.d.cts +532 -0
- package/index.d.ts +532 -0
- package/index.js +1533 -0
- package/index.js.map +1 -0
- package/node/index.cjs +924 -0
- package/node/index.cjs.map +1 -0
- package/node/index.d.cts +65 -0
- package/node/index.d.ts +65 -0
- package/node/index.js +398 -0
- package/node/index.js.map +1 -0
- package/package.json +81 -0
- package/src/base-sys-abstraction.test.ts +95 -0
- package/src/base-sys-abstraction.ts +242 -0
- package/src/bin2text.test.ts +59 -0
- package/src/bin2text.ts +47 -0
- package/src/crypto.test.ts +15 -0
- package/src/crypto.ts +125 -0
- package/src/file-service.ts +24 -0
- package/src/future.test.ts +32 -0
- package/src/future.ts +27 -0
- package/src/index.ts +22 -0
- package/src/jsr.json +20 -0
- package/src/log-level-impl.ts +87 -0
- package/src/log-writer-impl.ts +58 -0
- package/src/logger-impl.ts +498 -0
- package/src/logger.test.ts +1132 -0
- package/src/logger.ts +208 -0
- package/src/node/deno-file-service.ts +92 -0
- package/src/node/deno-sys-abstraction.ts +133 -0
- package/src/node/index.ts +4 -0
- package/src/node/mock-file-service.ts +45 -0
- package/src/node/node-file-service.ts +91 -0
- package/src/node/node-sys-abstraction.ts +121 -0
- package/src/option.ts +60 -0
- package/src/resolve-once.test.ts +321 -0
- package/src/resolve-once.ts +179 -0
- package/src/result.test.ts +102 -0
- package/src/result.ts +165 -0
- package/src/runtime.ts +36 -0
- package/src/sys-abstraction.ts +53 -0
- package/src/sys-env.test.ts +53 -0
- package/src/sys-env.ts +216 -0
- package/src/test/log-write-stream.ts +95 -0
- package/src/test/mock-logger.ts +40 -0
- package/src/time.ts +20 -0
- package/src/tracer.test.ts +314 -0
- package/src/tracer.ts +222 -0
- package/src/txt-en-decoder.ts +21 -0
- package/src/uri.test.ts +155 -0
- package/src/uri.ts +421 -0
- package/src/utils/console-write-stream.ts +72 -0
- package/src/utils/fanout-write-stream.ts +32 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/rebuffer.ts +75 -0
- package/src/utils/stream-map.ts +67 -0
- package/src/utils/stream2string.ts +47 -0
- package/src/utils/string2stream.ts +14 -0
- package/src/version.ts +3 -0
- package/src/web/index.ts +1 -0
- package/src/web/web-sys-abstraction.ts +80 -0
- package/ts/LICENSE +201 -0
- package/ts/README.md +39 -0
- package/ts/base-sys-abstraction.d.ts +84 -0
- package/ts/base-sys-abstraction.d.ts.map +1 -0
- package/ts/base-sys-abstraction.js +178 -0
- package/ts/base-sys-abstraction.js.map +1 -0
- package/ts/base-sys-abstraction.test.d.ts +2 -0
- package/ts/base-sys-abstraction.test.d.ts.map +1 -0
- package/ts/base-sys-abstraction.test.js +82 -0
- package/ts/base-sys-abstraction.test.js.map +1 -0
- package/ts/bin2text.d.ts +3 -0
- package/ts/bin2text.d.ts.map +1 -0
- package/ts/bin2text.js +43 -0
- package/ts/bin2text.js.map +1 -0
- package/ts/bin2text.test.d.ts +2 -0
- package/ts/bin2text.test.d.ts.map +1 -0
- package/ts/bin2text.test.js +51 -0
- package/ts/bin2text.test.js.map +1 -0
- package/ts/crypto.d.ts +76 -0
- package/ts/crypto.d.ts.map +1 -0
- package/ts/crypto.js +22 -0
- package/ts/crypto.js.map +1 -0
- package/ts/crypto.test.d.ts +2 -0
- package/ts/crypto.test.d.ts.map +1 -0
- package/ts/crypto.test.js +14 -0
- package/ts/crypto.test.js.map +1 -0
- package/ts/file-service.d.ts +17 -0
- package/ts/file-service.d.ts.map +1 -0
- package/ts/file-service.js +2 -0
- package/ts/file-service.js.map +1 -0
- package/ts/future.d.ts +8 -0
- package/ts/future.d.ts.map +1 -0
- package/ts/future.js +38 -0
- package/ts/future.js.map +1 -0
- package/ts/future.test.d.ts +2 -0
- package/ts/future.test.d.ts.map +1 -0
- package/ts/future.test.js +28 -0
- package/ts/future.test.js.map +1 -0
- package/ts/index.d.ts +23 -0
- package/ts/index.d.ts.map +1 -0
- package/ts/index.js +23 -0
- package/ts/index.js.map +1 -0
- package/ts/log-level-impl.d.ts +14 -0
- package/ts/log-level-impl.d.ts.map +1 -0
- package/ts/log-level-impl.js +72 -0
- package/ts/log-level-impl.js.map +1 -0
- package/ts/log-writer-impl.d.ts +10 -0
- package/ts/log-writer-impl.d.ts.map +1 -0
- package/ts/log-writer-impl.js +45 -0
- package/ts/log-writer-impl.js.map +1 -0
- package/ts/logger-impl.d.ts +71 -0
- package/ts/logger-impl.d.ts.map +1 -0
- package/ts/logger-impl.js +412 -0
- package/ts/logger-impl.js.map +1 -0
- package/ts/logger.d.ts +84 -0
- package/ts/logger.d.ts.map +1 -0
- package/ts/logger.js +114 -0
- package/ts/logger.js.map +1 -0
- package/ts/logger.test.d.ts +2 -0
- package/ts/logger.test.d.ts.map +1 -0
- package/ts/logger.test.js +1023 -0
- package/ts/logger.test.js.map +1 -0
- package/ts/node/deno-file-service.d.ts +17 -0
- package/ts/node/deno-file-service.d.ts.map +1 -0
- package/ts/node/deno-file-service.js +65 -0
- package/ts/node/deno-file-service.js.map +1 -0
- package/ts/node/deno-sys-abstraction.d.ts +22 -0
- package/ts/node/deno-sys-abstraction.d.ts.map +1 -0
- package/ts/node/deno-sys-abstraction.js +101 -0
- package/ts/node/deno-sys-abstraction.js.map +1 -0
- package/ts/node/index.d.ts +5 -0
- package/ts/node/index.d.ts.map +1 -0
- package/ts/node/index.js +5 -0
- package/ts/node/index.js.map +1 -0
- package/ts/node/mock-file-service.d.ts +11 -0
- package/ts/node/mock-file-service.d.ts.map +1 -0
- package/ts/node/mock-file-service.js +34 -0
- package/ts/node/mock-file-service.js.map +1 -0
- package/ts/node/mock-file-service.test.d.ts +2 -0
- package/ts/node/mock-file-service.test.d.ts.map +1 -0
- package/ts/node/mock-file-service.test.js +31 -0
- package/ts/node/mock-file-service.test.js.map +1 -0
- package/ts/node/node-file-service.d.ts +16 -0
- package/ts/node/node-file-service.d.ts.map +1 -0
- package/ts/node/node-file-service.js +71 -0
- package/ts/node/node-file-service.js.map +1 -0
- package/ts/node/node-sys-abstraction.d.ts +22 -0
- package/ts/node/node-sys-abstraction.d.ts.map +1 -0
- package/ts/node/node-sys-abstraction.js +99 -0
- package/ts/node/node-sys-abstraction.js.map +1 -0
- package/ts/node/node-sys-abstraction.test.d.ts +2 -0
- package/ts/node/node-sys-abstraction.test.d.ts.map +1 -0
- package/ts/node/node-sys-abstraction.test.js +87 -0
- package/ts/node/node-sys-abstraction.test.js.map +1 -0
- package/ts/option.d.ts +25 -0
- package/ts/option.d.ts.map +1 -0
- package/ts/option.js +47 -0
- package/ts/option.js.map +1 -0
- package/ts/resolve-once.d.ts +46 -0
- package/ts/resolve-once.d.ts.map +1 -0
- package/ts/resolve-once.js +152 -0
- package/ts/resolve-once.js.map +1 -0
- package/ts/resolve-once.test.d.ts +2 -0
- package/ts/resolve-once.test.d.ts.map +1 -0
- package/ts/resolve-once.test.js +283 -0
- package/ts/resolve-once.test.js.map +1 -0
- package/ts/result.d.ts +34 -0
- package/ts/result.d.ts.map +1 -0
- package/ts/result.js +85 -0
- package/ts/result.js.map +1 -0
- package/ts/result.test.d.ts +2 -0
- package/ts/result.test.d.ts.map +1 -0
- package/ts/result.test.js +79 -0
- package/ts/result.test.js.map +1 -0
- package/ts/runtime.d.ts +8 -0
- package/ts/runtime.d.ts.map +1 -0
- package/ts/runtime.js +26 -0
- package/ts/runtime.js.map +1 -0
- package/ts/sys-abstraction.d.ts +36 -0
- package/ts/sys-abstraction.d.ts.map +1 -0
- package/ts/sys-abstraction.js +31 -0
- package/ts/sys-abstraction.js.map +1 -0
- package/ts/sys-env.d.ts +48 -0
- package/ts/sys-env.d.ts.map +1 -0
- package/ts/sys-env.js +176 -0
- package/ts/sys-env.js.map +1 -0
- package/ts/sys-env.test.d.ts +2 -0
- package/ts/sys-env.test.d.ts.map +1 -0
- package/ts/sys-env.test.js +51 -0
- package/ts/sys-env.test.js.map +1 -0
- package/ts/test/log-write-stream.d.ts +27 -0
- package/ts/test/log-write-stream.d.ts.map +1 -0
- package/ts/test/log-write-stream.js +74 -0
- package/ts/test/log-write-stream.js.map +1 -0
- package/ts/test/mock-logger.d.ts +14 -0
- package/ts/test/mock-logger.d.ts.map +1 -0
- package/ts/test/mock-logger.js +29 -0
- package/ts/test/mock-logger.js.map +1 -0
- package/ts/test/mock-logger.test.d.ts +2 -0
- package/ts/test/mock-logger.test.d.ts.map +1 -0
- package/ts/test/mock-logger.test.js +63 -0
- package/ts/test/mock-logger.test.js.map +1 -0
- package/ts/test/test-exit-handler.d.ts +2 -0
- package/ts/test/test-exit-handler.d.ts.map +1 -0
- package/ts/test/test-exit-handler.js +57 -0
- package/ts/test/test-exit-handler.js.map +1 -0
- package/ts/time.d.ts +13 -0
- package/ts/time.d.ts.map +1 -0
- package/ts/time.js +14 -0
- package/ts/time.js.map +1 -0
- package/ts/tracer.d.ts +59 -0
- package/ts/tracer.d.ts.map +1 -0
- package/ts/tracer.js +148 -0
- package/ts/tracer.js.map +1 -0
- package/ts/tracer.test.d.ts +2 -0
- package/ts/tracer.test.d.ts.map +1 -0
- package/ts/tracer.test.js +311 -0
- package/ts/tracer.test.js.map +1 -0
- package/ts/txt-en-decoder.d.ts +10 -0
- package/ts/txt-en-decoder.d.ts.map +1 -0
- package/ts/txt-en-decoder.js +15 -0
- package/ts/txt-en-decoder.js.map +1 -0
- package/ts/uri.d.ts +67 -0
- package/ts/uri.d.ts.map +1 -0
- package/ts/uri.js +283 -0
- package/ts/uri.js.map +1 -0
- package/ts/uri.test.d.ts +2 -0
- package/ts/uri.test.d.ts.map +1 -0
- package/ts/uri.test.js +119 -0
- package/ts/uri.test.js.map +1 -0
- package/ts/utils/console-write-stream.d.ts +21 -0
- package/ts/utils/console-write-stream.d.ts.map +1 -0
- package/ts/utils/console-write-stream.js +62 -0
- package/ts/utils/console-write-stream.js.map +1 -0
- package/ts/utils/fanout-write-stream.d.ts +12 -0
- package/ts/utils/fanout-write-stream.d.ts.map +1 -0
- package/ts/utils/fanout-write-stream.js +24 -0
- package/ts/utils/fanout-write-stream.js.map +1 -0
- package/ts/utils/index.d.ts +7 -0
- package/ts/utils/index.d.ts.map +1 -0
- package/ts/utils/index.js +7 -0
- package/ts/utils/index.js.map +1 -0
- package/ts/utils/rebuffer.d.ts +3 -0
- package/ts/utils/rebuffer.d.ts.map +1 -0
- package/ts/utils/rebuffer.js +60 -0
- package/ts/utils/rebuffer.js.map +1 -0
- package/ts/utils/rebuffer.test.d.ts +2 -0
- package/ts/utils/rebuffer.test.d.ts.map +1 -0
- package/ts/utils/rebuffer.test.js +77 -0
- package/ts/utils/rebuffer.test.js.map +1 -0
- package/ts/utils/stream-map.d.ts +9 -0
- package/ts/utils/stream-map.d.ts.map +1 -0
- package/ts/utils/stream-map.js +62 -0
- package/ts/utils/stream-map.js.map +1 -0
- package/ts/utils/stream-map.test.d.ts +2 -0
- package/ts/utils/stream-map.test.d.ts.map +1 -0
- package/ts/utils/stream-map.test.js +87 -0
- package/ts/utils/stream-map.test.js.map +1 -0
- package/ts/utils/stream-test-helper.d.ts +17 -0
- package/ts/utils/stream-test-helper.d.ts.map +1 -0
- package/ts/utils/stream-test-helper.js +37 -0
- package/ts/utils/stream-test-helper.js.map +1 -0
- package/ts/utils/stream2string.d.ts +3 -0
- package/ts/utils/stream2string.d.ts.map +1 -0
- package/ts/utils/stream2string.js +48 -0
- package/ts/utils/stream2string.js.map +1 -0
- package/ts/utils/stream2string.test.d.ts +2 -0
- package/ts/utils/stream2string.test.d.ts.map +1 -0
- package/ts/utils/stream2string.test.js +29 -0
- package/ts/utils/stream2string.test.js.map +1 -0
- package/ts/utils/string2stream.d.ts +4 -0
- package/ts/utils/string2stream.d.ts.map +1 -0
- package/ts/utils/string2stream.js +13 -0
- package/ts/utils/string2stream.js.map +1 -0
- package/ts/utils/string2stream.test.d.ts +2 -0
- package/ts/utils/string2stream.test.d.ts.map +1 -0
- package/ts/utils/string2stream.test.js +6 -0
- package/ts/utils/string2stream.test.js.map +1 -0
- package/ts/version.d.ts +2 -0
- package/ts/version.d.ts.map +1 -0
- package/ts/version.js +4 -0
- package/ts/version.js.map +1 -0
- package/ts/web/index.d.ts +2 -0
- package/ts/web/index.d.ts.map +1 -0
- package/ts/web/index.js +2 -0
- package/ts/web/index.js.map +1 -0
- package/ts/web/web-sys-abstraction.d.ts +4 -0
- package/ts/web/web-sys-abstraction.d.ts.map +1 -0
- package/ts/web/web-sys-abstraction.js +64 -0
- package/ts/web/web-sys-abstraction.js.map +1 -0
- package/txt-en-decoder-CZYJUju2.d.cts +11 -0
- package/txt-en-decoder-CZYJUju2.d.ts +11 -0
- package/utils/index.cjs +341 -0
- package/utils/index.cjs.map +1 -0
- package/utils/index.d.cts +2 -0
- package/utils/index.d.ts +2 -0
- package/utils/index.js +32 -0
- package/utils/index.js.map +1 -0
- package/web/index.cjs +593 -0
- package/web/index.cjs.map +1 -0
- package/web/index.d.cts +6 -0
- package/web/index.d.ts +6 -0
- package/web/index.js +9 -0
- package/web/index.js.map +1 -0
@@ -0,0 +1,311 @@
|
|
1
|
+
import {
|
2
|
+
Utf8EnDecoderSingleton,
|
3
|
+
__export
|
4
|
+
} from "./chunk-GES3MUGV.js";
|
5
|
+
|
6
|
+
// src/utils/index.ts
|
7
|
+
var utils_exports = {};
|
8
|
+
__export(utils_exports, {
|
9
|
+
ConsoleWriterStream: () => ConsoleWriterStream,
|
10
|
+
ConsoleWriterStreamDefaultWriter: () => ConsoleWriterStreamDefaultWriter,
|
11
|
+
FanoutWriteStream: () => FanoutWriteStream,
|
12
|
+
array2stream: () => array2stream,
|
13
|
+
devnull: () => devnull,
|
14
|
+
rebuffer: () => rebuffer,
|
15
|
+
rebufferArray: () => rebufferArray,
|
16
|
+
stream2array: () => stream2array,
|
17
|
+
stream2string: () => stream2string,
|
18
|
+
stream2uint8array: () => stream2uint8array,
|
19
|
+
streamMap: () => streamMap,
|
20
|
+
string2stream: () => string2stream,
|
21
|
+
uint8array2stream: () => uint8array2stream
|
22
|
+
});
|
23
|
+
|
24
|
+
// src/utils/stream-map.ts
|
25
|
+
function streamMap(s, sm) {
|
26
|
+
const state = { reader: s.getReader(), streamMap: sm, idx: 0 };
|
27
|
+
return new ReadableStream({
|
28
|
+
async pull(controller) {
|
29
|
+
const { done, value } = await state.reader.read();
|
30
|
+
if (done) {
|
31
|
+
if (state.streamMap.Close) {
|
32
|
+
state.streamMap.Close();
|
33
|
+
}
|
34
|
+
controller.close();
|
35
|
+
return;
|
36
|
+
}
|
37
|
+
const promiseOrU = state.streamMap.Map(value, state.idx++);
|
38
|
+
let mapped;
|
39
|
+
if (promiseOrU instanceof Promise || typeof promiseOrU.then === "function") {
|
40
|
+
mapped = await promiseOrU;
|
41
|
+
} else {
|
42
|
+
mapped = promiseOrU;
|
43
|
+
}
|
44
|
+
controller.enqueue(mapped);
|
45
|
+
}
|
46
|
+
});
|
47
|
+
}
|
48
|
+
async function devnull(a) {
|
49
|
+
const reader = a.getReader();
|
50
|
+
let cnt = 0;
|
51
|
+
while (true) {
|
52
|
+
const { done } = await reader.read();
|
53
|
+
if (done) {
|
54
|
+
break;
|
55
|
+
}
|
56
|
+
cnt++;
|
57
|
+
}
|
58
|
+
return cnt;
|
59
|
+
}
|
60
|
+
function array2stream(a) {
|
61
|
+
let i = 0;
|
62
|
+
return new ReadableStream({
|
63
|
+
pull(controller) {
|
64
|
+
if (i >= a.length) {
|
65
|
+
controller.close();
|
66
|
+
return;
|
67
|
+
}
|
68
|
+
controller.enqueue(a[i]);
|
69
|
+
i++;
|
70
|
+
}
|
71
|
+
});
|
72
|
+
}
|
73
|
+
async function stream2array(a) {
|
74
|
+
const ret = [];
|
75
|
+
const reader = a.getReader();
|
76
|
+
while (true) {
|
77
|
+
const { done, value } = await reader.read();
|
78
|
+
if (done) {
|
79
|
+
break;
|
80
|
+
}
|
81
|
+
ret.push(value);
|
82
|
+
}
|
83
|
+
return ret;
|
84
|
+
}
|
85
|
+
|
86
|
+
// src/utils/rebuffer.ts
|
87
|
+
async function rebufferArray(a, chunkSize) {
|
88
|
+
return stream2array(rebuffer(array2stream(a), chunkSize));
|
89
|
+
}
|
90
|
+
function reChunk(cs, chunkSize) {
|
91
|
+
const len = cs.reduce((acc, v) => acc + v.length, 0);
|
92
|
+
const last = cs[cs.length - 1];
|
93
|
+
const lastOfs = len - last.length;
|
94
|
+
const rest = last.subarray(chunkSize - lastOfs);
|
95
|
+
cs[cs.length - 1] = last.subarray(0, chunkSize - lastOfs);
|
96
|
+
const chunk = new Uint8Array(chunkSize);
|
97
|
+
let ofs = 0;
|
98
|
+
for (const c of cs) {
|
99
|
+
chunk.set(c, ofs);
|
100
|
+
ofs += c.length;
|
101
|
+
}
|
102
|
+
return { rest, chunk };
|
103
|
+
}
|
104
|
+
function pump(ps, controller, next) {
|
105
|
+
ps.reader.read().then(({ done, value }) => {
|
106
|
+
if (done) {
|
107
|
+
if (ps.tmpLen > 0) {
|
108
|
+
controller.enqueue(reChunk(ps.tmp, ps.tmpLen).chunk);
|
109
|
+
}
|
110
|
+
controller.close();
|
111
|
+
next();
|
112
|
+
return;
|
113
|
+
}
|
114
|
+
if (ps.tmpLen + value.length > ps.chunkSize) {
|
115
|
+
ps.tmp.push(value);
|
116
|
+
const res = reChunk(ps.tmp, ps.chunkSize);
|
117
|
+
controller.enqueue(res.chunk);
|
118
|
+
ps.tmp = [res.rest];
|
119
|
+
ps.tmpLen = res.rest.length;
|
120
|
+
next();
|
121
|
+
return;
|
122
|
+
} else if (value.length) {
|
123
|
+
ps.tmp.push(value);
|
124
|
+
ps.tmpLen += value.length;
|
125
|
+
}
|
126
|
+
pump(ps, controller, next);
|
127
|
+
});
|
128
|
+
}
|
129
|
+
function rebuffer(a, chunkSize) {
|
130
|
+
const state = {
|
131
|
+
reader: a.getReader(),
|
132
|
+
tmp: [],
|
133
|
+
tmpLen: 0,
|
134
|
+
chunkSize
|
135
|
+
};
|
136
|
+
return new ReadableStream({
|
137
|
+
async pull(controller) {
|
138
|
+
return new Promise((resolve) => {
|
139
|
+
pump(state, controller, resolve);
|
140
|
+
});
|
141
|
+
}
|
142
|
+
});
|
143
|
+
}
|
144
|
+
|
145
|
+
// src/utils/stream2string.ts
|
146
|
+
async function stream2string(stream, maxSize) {
|
147
|
+
if (!stream) {
|
148
|
+
return Promise.resolve("");
|
149
|
+
}
|
150
|
+
const reader = stream.getReader();
|
151
|
+
let res = "";
|
152
|
+
const decoder = new TextDecoder();
|
153
|
+
let rSize = 0;
|
154
|
+
while (typeof maxSize === "undefined" || rSize < maxSize) {
|
155
|
+
try {
|
156
|
+
const read = await reader.read();
|
157
|
+
if (read.done) {
|
158
|
+
break;
|
159
|
+
}
|
160
|
+
if (maxSize && rSize + read.value.length > maxSize) {
|
161
|
+
read.value = read.value.slice(0, maxSize - rSize);
|
162
|
+
}
|
163
|
+
const block = decoder.decode(read.value, { stream: true });
|
164
|
+
rSize += read.value.length;
|
165
|
+
res += block;
|
166
|
+
} catch (err) {
|
167
|
+
return Promise.reject(err);
|
168
|
+
}
|
169
|
+
}
|
170
|
+
return Promise.resolve(res);
|
171
|
+
}
|
172
|
+
async function stream2uint8array(stream) {
|
173
|
+
if (!stream) {
|
174
|
+
return Promise.resolve(new Uint8Array());
|
175
|
+
}
|
176
|
+
const reader = stream.getReader();
|
177
|
+
let res = new Uint8Array();
|
178
|
+
while (1) {
|
179
|
+
try {
|
180
|
+
const { done, value } = await reader.read();
|
181
|
+
if (done) {
|
182
|
+
break;
|
183
|
+
}
|
184
|
+
res = new Uint8Array([...res, ...value]);
|
185
|
+
} catch (err) {
|
186
|
+
return Promise.reject(err);
|
187
|
+
}
|
188
|
+
}
|
189
|
+
return Promise.resolve(res);
|
190
|
+
}
|
191
|
+
|
192
|
+
// src/utils/string2stream.ts
|
193
|
+
function string2stream(str, ende = Utf8EnDecoderSingleton()) {
|
194
|
+
return uint8array2stream(ende.encode(str));
|
195
|
+
}
|
196
|
+
function uint8array2stream(str) {
|
197
|
+
return new ReadableStream({
|
198
|
+
start(controller) {
|
199
|
+
controller.enqueue(str);
|
200
|
+
controller.close();
|
201
|
+
}
|
202
|
+
});
|
203
|
+
}
|
204
|
+
|
205
|
+
// src/utils/console-write-stream.ts
|
206
|
+
var ConsoleWriterStreamDefaultWriter = class {
|
207
|
+
constructor(stream) {
|
208
|
+
this.stream = stream;
|
209
|
+
this.desiredSize = null;
|
210
|
+
this.decoder = new TextDecoder();
|
211
|
+
this._stream = stream;
|
212
|
+
this.ready = Promise.resolve(void 0);
|
213
|
+
this.closed = Promise.resolve(void 0);
|
214
|
+
}
|
215
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
216
|
+
abort(reason) {
|
217
|
+
throw new Error("Method not implemented.");
|
218
|
+
}
|
219
|
+
async close() {
|
220
|
+
}
|
221
|
+
releaseLock() {
|
222
|
+
this._stream.locked = false;
|
223
|
+
this.ready = Promise.resolve(void 0);
|
224
|
+
this.closed = Promise.resolve(void 0);
|
225
|
+
}
|
226
|
+
async write(chunk) {
|
227
|
+
const str = this.decoder.decode(chunk).trimEnd();
|
228
|
+
let output = "log";
|
229
|
+
try {
|
230
|
+
const decode = JSON.parse(str);
|
231
|
+
output = decode.level;
|
232
|
+
} catch (e) {
|
233
|
+
}
|
234
|
+
switch (output) {
|
235
|
+
case "error":
|
236
|
+
console.error(str);
|
237
|
+
break;
|
238
|
+
case "warn":
|
239
|
+
console.warn(str);
|
240
|
+
break;
|
241
|
+
default:
|
242
|
+
console.log(str);
|
243
|
+
}
|
244
|
+
}
|
245
|
+
};
|
246
|
+
var ConsoleWriterStream = class {
|
247
|
+
constructor() {
|
248
|
+
this.locked = false;
|
249
|
+
}
|
250
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
251
|
+
abort(reason) {
|
252
|
+
throw new Error("Method not implemented.");
|
253
|
+
}
|
254
|
+
async close() {
|
255
|
+
return;
|
256
|
+
}
|
257
|
+
getWriter() {
|
258
|
+
if (this.locked) {
|
259
|
+
throw new Error("Stream is locked");
|
260
|
+
}
|
261
|
+
this.locked = true;
|
262
|
+
if (!this._writer) {
|
263
|
+
this._writer = new ConsoleWriterStreamDefaultWriter(this);
|
264
|
+
}
|
265
|
+
return this._writer;
|
266
|
+
}
|
267
|
+
};
|
268
|
+
|
269
|
+
// src/utils/fanout-write-stream.ts
|
270
|
+
var FanoutWriteStream = class {
|
271
|
+
constructor(writers) {
|
272
|
+
this.desiredSize = null;
|
273
|
+
this._writers = writers;
|
274
|
+
this.ready = Promise.all(this._writers.map((w) => w.ready)).then(() => void 0);
|
275
|
+
this.closed = Promise.all(this._writers.map((w) => w.closed)).then(() => void 0);
|
276
|
+
}
|
277
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
278
|
+
abort(reason) {
|
279
|
+
return Promise.all(this._writers.map((w) => w.abort(reason))).then(() => {
|
280
|
+
});
|
281
|
+
}
|
282
|
+
close() {
|
283
|
+
return Promise.all(this._writers.map((w) => w.close())).then(() => {
|
284
|
+
});
|
285
|
+
}
|
286
|
+
releaseLock() {
|
287
|
+
this._writers.map((w) => w.releaseLock());
|
288
|
+
}
|
289
|
+
write(chunk) {
|
290
|
+
return Promise.all(this._writers.map((w) => w.write(chunk))).then(() => {
|
291
|
+
});
|
292
|
+
}
|
293
|
+
};
|
294
|
+
|
295
|
+
export {
|
296
|
+
ConsoleWriterStreamDefaultWriter,
|
297
|
+
ConsoleWriterStream,
|
298
|
+
FanoutWriteStream,
|
299
|
+
streamMap,
|
300
|
+
devnull,
|
301
|
+
array2stream,
|
302
|
+
stream2array,
|
303
|
+
rebufferArray,
|
304
|
+
rebuffer,
|
305
|
+
stream2string,
|
306
|
+
stream2uint8array,
|
307
|
+
string2stream,
|
308
|
+
uint8array2stream,
|
309
|
+
utils_exports
|
310
|
+
};
|
311
|
+
//# sourceMappingURL=chunk-7KFVMTOS.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/utils/index.ts","../../src/utils/stream-map.ts","../../src/utils/rebuffer.ts","../../src/utils/stream2string.ts","../../src/utils/string2stream.ts","../../src/utils/console-write-stream.ts","../../src/utils/fanout-write-stream.ts"],"sourcesContent":["export * from \"./rebuffer.js\";\nexport * from \"./stream-map.js\";\nexport * from \"./stream2string.js\";\nexport * from \"./string2stream.js\";\nexport * from \"./console-write-stream.js\";\nexport * from \"./fanout-write-stream.js\";\n","export interface StreamMap<T, U> {\n Map(s: T, idx: number): U | Promise<U>;\n readonly Close?: () => void;\n}\nexport function streamMap<T, U>(s: ReadableStream<T>, sm: StreamMap<T, U>): ReadableStream<U> {\n const state = { reader: s.getReader(), streamMap: sm, idx: 0 };\n return new ReadableStream<U>({\n async pull(controller): Promise<void> {\n const { done, value } = await state.reader.read();\n if (done) {\n if (state.streamMap.Close) {\n state.streamMap.Close();\n }\n controller.close();\n return;\n }\n const promiseOrU = state.streamMap.Map(value, state.idx++);\n let mapped: U;\n if (promiseOrU instanceof Promise || typeof (promiseOrU as { then: () => void }).then === \"function\") {\n mapped = await promiseOrU;\n } else {\n mapped = promiseOrU;\n }\n controller.enqueue(mapped);\n },\n });\n}\n\nexport async function devnull<T>(a: ReadableStream<T>): Promise<number> {\n const reader = a.getReader();\n let cnt = 0;\n while (true) {\n const { done } = await reader.read();\n if (done) {\n break;\n }\n cnt++;\n }\n return cnt;\n}\n\nexport function array2stream<T>(a: T[]): ReadableStream<T> {\n let i = 0;\n return new ReadableStream<T>({\n pull(controller): void {\n if (i >= a.length) {\n controller.close();\n return;\n }\n controller.enqueue(a[i]);\n i++;\n },\n });\n}\n\nexport async function stream2array<T>(a: ReadableStream<T>): Promise<T[]> {\n const ret: T[] = [];\n const reader = a.getReader();\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n ret.push(value);\n }\n return ret;\n}\n","import { array2stream, stream2array } from \"./stream-map.js\";\n\ninterface ReChunkResult {\n readonly rest: Uint8Array;\n readonly chunk: Uint8Array;\n}\n\nexport async function rebufferArray(a: Uint8Array[], chunkSize: number): Promise<Uint8Array[]> {\n return stream2array(rebuffer(array2stream(a), chunkSize));\n}\n\nfunction reChunk(cs: Uint8Array[], chunkSize: number): ReChunkResult {\n const len = cs.reduce((acc, v) => acc + v.length, 0);\n const last = cs[cs.length - 1];\n const lastOfs = len - last.length;\n // console.log(\"reChunk\", len, lastOfs, last.length, chunkSize, chunkSize - lastOfs)\n const rest = last.subarray(chunkSize - lastOfs);\n cs[cs.length - 1] = last.subarray(0, chunkSize - lastOfs);\n const chunk = new Uint8Array(chunkSize);\n let ofs = 0;\n for (const c of cs) {\n chunk.set(c, ofs);\n ofs += c.length;\n }\n return { rest, chunk };\n}\n\ninterface pumpState {\n readonly reader: ReadableStreamDefaultReader<Uint8Array>;\n tmp: Uint8Array[];\n tmpLen: number;\n readonly chunkSize: number;\n}\n\nfunction pump(ps: pumpState, controller: ReadableStreamDefaultController<Uint8Array>, next: () => void): void {\n ps.reader.read().then(({ done, value }) => {\n if (done) {\n if (ps.tmpLen > 0) {\n controller.enqueue(reChunk(ps.tmp, ps.tmpLen).chunk);\n }\n controller.close();\n next();\n return;\n }\n if (ps.tmpLen + value.length > ps.chunkSize) {\n ps.tmp.push(value);\n const res = reChunk(ps.tmp, ps.chunkSize);\n controller.enqueue(res.chunk);\n ps.tmp = [res.rest];\n ps.tmpLen = res.rest.length;\n next();\n return;\n } else if (value.length) {\n ps.tmp.push(value);\n ps.tmpLen += value.length;\n }\n pump(ps, controller, next);\n });\n}\n\nexport function rebuffer(a: ReadableStream<Uint8Array>, chunkSize: number): ReadableStream<Uint8Array> {\n const state: pumpState = {\n reader: a.getReader(),\n tmp: [],\n tmpLen: 0,\n chunkSize,\n };\n return new ReadableStream<Uint8Array>({\n async pull(controller): Promise<void> {\n return new Promise<void>((resolve) => {\n pump(state, controller, resolve);\n });\n },\n });\n}\n","export async function stream2string(stream?: ReadableStream<Uint8Array> | null, maxSize?: number): Promise<string> {\n if (!stream) {\n return Promise.resolve(\"\");\n }\n const reader = stream.getReader();\n let res = \"\";\n const decoder = new TextDecoder();\n let rSize = 0;\n while (typeof maxSize === \"undefined\" || rSize < maxSize) {\n try {\n const read = await reader.read();\n if (read.done) {\n break;\n }\n if (maxSize && rSize + read.value.length > maxSize) {\n read.value = read.value.slice(0, maxSize - rSize);\n }\n const block = decoder.decode(read.value, { stream: true });\n rSize += read.value.length;\n res += block;\n } catch (err) {\n return Promise.reject(err);\n }\n }\n return Promise.resolve(res);\n}\n\nexport async function stream2uint8array(stream?: ReadableStream<Uint8Array> | null): Promise<Uint8Array> {\n if (!stream) {\n return Promise.resolve(new Uint8Array());\n }\n const reader = stream.getReader();\n let res = new Uint8Array();\n // eslint-disable-next-line no-constant-condition\n while (1) {\n try {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n res = new Uint8Array([...res, ...value]);\n } catch (err) {\n return Promise.reject(err);\n }\n }\n return Promise.resolve(res);\n}\n","import { TxtEnDecoder, Utf8EnDecoderSingleton } from \"../txt-en-decoder.js\";\n\nexport function string2stream(str: string, ende: TxtEnDecoder = Utf8EnDecoderSingleton()): ReadableStream<Uint8Array> {\n return uint8array2stream(ende.encode(str));\n}\n\nexport function uint8array2stream(str: Uint8Array): ReadableStream<Uint8Array> {\n return new ReadableStream<Uint8Array>({\n start(controller): void {\n controller.enqueue(str);\n controller.close();\n },\n });\n}\n","export class ConsoleWriterStreamDefaultWriter implements WritableStreamDefaultWriter<Uint8Array> {\n readonly desiredSize: number | null = null;\n readonly decoder: TextDecoder = new TextDecoder();\n\n closed: Promise<undefined>;\n ready: Promise<undefined>;\n readonly _stream: ConsoleWriterStream;\n\n constructor(private stream: ConsoleWriterStream) {\n this._stream = stream;\n this.ready = Promise.resolve(undefined);\n this.closed = Promise.resolve(undefined);\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any\n abort(reason?: any): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n async close(): Promise<void> {\n // noop\n }\n releaseLock(): void {\n this._stream.locked = false;\n this.ready = Promise.resolve(undefined);\n this.closed = Promise.resolve(undefined);\n }\n async write(chunk?: Uint8Array | undefined): Promise<void> {\n const str = this.decoder.decode(chunk).trimEnd();\n let output = \"log\";\n try {\n const decode = JSON.parse(str);\n output = decode.level;\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (e) {\n /* noop */\n }\n switch (output) {\n case \"error\":\n // eslint-disable-next-line no-console\n console.error(str);\n break;\n case \"warn\":\n // eslint-disable-next-line no-console\n console.warn(str);\n break;\n default:\n // eslint-disable-next-line no-console\n console.log(str);\n }\n }\n}\n\nexport class ConsoleWriterStream implements WritableStream<Uint8Array> {\n locked = false;\n _writer?: WritableStreamDefaultWriter<Uint8Array>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars\n abort(reason?: any): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n async close(): Promise<void> {\n return;\n }\n getWriter(): WritableStreamDefaultWriter<Uint8Array> {\n if (this.locked) {\n throw new Error(\"Stream is locked\");\n }\n this.locked = true;\n if (!this._writer) {\n this._writer = new ConsoleWriterStreamDefaultWriter(this);\n }\n return this._writer;\n }\n}\n","export class FanoutWriteStream implements WritableStreamDefaultWriter<Uint8Array> {\n readonly _writers: WritableStreamDefaultWriter<Uint8Array>[];\n readonly ready: Promise<undefined>;\n readonly closed: Promise<undefined>;\n readonly desiredSize: number | null = null;\n constructor(writers: WritableStreamDefaultWriter<Uint8Array>[]) {\n this._writers = writers;\n this.ready = Promise.all(this._writers.map((w) => w.ready)).then(() => undefined);\n this.closed = Promise.all(this._writers.map((w) => w.closed)).then(() => undefined);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n abort(reason?: any): Promise<void> {\n return Promise.all(this._writers.map((w) => w.abort(reason))).then(() => {\n /* do nothing */\n });\n }\n close(): Promise<void> {\n return Promise.all(this._writers.map((w) => w.close())).then(() => {\n /* do nothing */\n });\n }\n releaseLock(): void {\n this._writers.map((w) => w.releaseLock());\n }\n\n write(chunk?: Uint8Array | undefined): Promise<void> {\n return Promise.all(this._writers.map((w) => w.write(chunk))).then(() => {\n /* do nothing */\n });\n }\n}\n"],"mappings":";;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIO,SAAS,UAAgB,GAAsB,IAAwC;AAC5F,QAAM,QAAQ,EAAE,QAAQ,EAAE,UAAU,GAAG,WAAW,IAAI,KAAK,EAAE;AAC7D,SAAO,IAAI,eAAkB;AAAA,IAC3B,MAAM,KAAK,YAA2B;AACpC,YAAM,EAAE,MAAM,MAAM,IAAI,MAAM,MAAM,OAAO,KAAK;AAChD,UAAI,MAAM;AACR,YAAI,MAAM,UAAU,OAAO;AACzB,gBAAM,UAAU,MAAM;AAAA,QACxB;AACA,mBAAW,MAAM;AACjB;AAAA,MACF;AACA,YAAM,aAAa,MAAM,UAAU,IAAI,OAAO,MAAM,KAAK;AACzD,UAAI;AACJ,UAAI,sBAAsB,WAAW,OAAQ,WAAoC,SAAS,YAAY;AACpG,iBAAS,MAAM;AAAA,MACjB,OAAO;AACL,iBAAS;AAAA,MACX;AACA,iBAAW,QAAQ,MAAM;AAAA,IAC3B;AAAA,EACF,CAAC;AACH;AAEA,eAAsB,QAAW,GAAuC;AACtE,QAAM,SAAS,EAAE,UAA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,SAAK,QAAQ,QAAQ,IAAI,KAAK,SAAS,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,MAAM,MAAS;AAChF,SAAK,SAAS,QAAQ,IAAI,KAAK,SAAS,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,MAAM,MAAS;AAAA,EACpF;AAAA;AAAA,EAGA,MAAM,QAA6B;AACjC,WAAO,QAAQ,IAAI,KAAK,SAAS,IAAI,CAAC,MAAM,EAAE,MAAM,MAAM,CAAC,CAAC,EAAE,KAAK,MAAM;AAAA,IAEzE,CAAC;AAAA,EACH;AAAA,EACA,QAAuB;AACrB,WAAO,QAAQ,IAAI,KAAK,SAAS,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,KAAK,MAAM;AAAA,IAEnE,CAAC;AAAA,EACH;AAAA,EACA,cAAoB;AAClB,SAAK,SAAS,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC;AAAA,EAC1C;AAAA,EAEA,MAAM,OAA+C;AACnD,WAAO,QAAQ,IAAI,KAAK,SAAS,IAAI,CAAC,MAAM,EAAE,MAAM,KAAK,CAAC,CAAC,EAAE,KAAK,MAAM;AAAA,IAExE,CAAC;AAAA,EACH;AACF;","names":[]}
|
@@ -0,0 +1,92 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __defProps = Object.defineProperties;
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
7
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
|
8
|
+
var __typeError = (msg) => {
|
9
|
+
throw TypeError(msg);
|
10
|
+
};
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
12
|
+
var __spreadValues = (a, b) => {
|
13
|
+
for (var prop in b || (b = {}))
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
16
|
+
if (__getOwnPropSymbols)
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
18
|
+
if (__propIsEnum.call(b, prop))
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
20
|
+
}
|
21
|
+
return a;
|
22
|
+
};
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
24
|
+
var __export = (target, all) => {
|
25
|
+
for (var name in all)
|
26
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
27
|
+
};
|
28
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
29
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
30
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
31
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
32
|
+
var __await = function(promise, isYieldStar) {
|
33
|
+
this[0] = promise;
|
34
|
+
this[1] = isYieldStar;
|
35
|
+
};
|
36
|
+
var __yieldStar = (value) => {
|
37
|
+
var obj = value[__knownSymbol("asyncIterator")], isAwait = false, method, it = {};
|
38
|
+
if (obj == null) {
|
39
|
+
obj = value[__knownSymbol("iterator")]();
|
40
|
+
method = (k) => it[k] = (x) => obj[k](x);
|
41
|
+
} else {
|
42
|
+
obj = obj.call(value);
|
43
|
+
method = (k) => it[k] = (v) => {
|
44
|
+
if (isAwait) {
|
45
|
+
isAwait = false;
|
46
|
+
if (k === "throw") throw v;
|
47
|
+
return v;
|
48
|
+
}
|
49
|
+
isAwait = true;
|
50
|
+
return {
|
51
|
+
done: false,
|
52
|
+
value: new __await(new Promise((resolve) => {
|
53
|
+
var x = obj[k](v);
|
54
|
+
if (!(x instanceof Object)) __typeError("Object expected");
|
55
|
+
resolve(x);
|
56
|
+
}), 1)
|
57
|
+
};
|
58
|
+
};
|
59
|
+
}
|
60
|
+
return it[__knownSymbol("iterator")] = () => it, method("next"), "throw" in obj ? method("throw") : it.throw = (x) => {
|
61
|
+
throw x;
|
62
|
+
}, "return" in obj && method("return"), it;
|
63
|
+
};
|
64
|
+
|
65
|
+
// src/txt-en-decoder.ts
|
66
|
+
var encoder = new TextEncoder();
|
67
|
+
var decoder = new TextDecoder();
|
68
|
+
var Utf8EnDecoder = class {
|
69
|
+
encode(str) {
|
70
|
+
return encoder.encode(str);
|
71
|
+
}
|
72
|
+
decode(data) {
|
73
|
+
return decoder.decode(data);
|
74
|
+
}
|
75
|
+
};
|
76
|
+
var utf8EnDecoder = new Utf8EnDecoder();
|
77
|
+
function Utf8EnDecoderSingleton() {
|
78
|
+
return utf8EnDecoder;
|
79
|
+
}
|
80
|
+
|
81
|
+
export {
|
82
|
+
__spreadValues,
|
83
|
+
__spreadProps,
|
84
|
+
__export,
|
85
|
+
__privateGet,
|
86
|
+
__privateAdd,
|
87
|
+
__privateSet,
|
88
|
+
__yieldStar,
|
89
|
+
Utf8EnDecoder,
|
90
|
+
Utf8EnDecoderSingleton
|
91
|
+
};
|
92
|
+
//# sourceMappingURL=chunk-GES3MUGV.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/txt-en-decoder.ts"],"sourcesContent":["export interface TxtEnDecoder {\n encode(str: string): Uint8Array;\n decode(data: Uint8Array): string;\n}\n\nconst encoder = new TextEncoder();\nconst decoder = new TextDecoder();\n\nexport class Utf8EnDecoder implements TxtEnDecoder {\n encode(str: string): Uint8Array {\n return encoder.encode(str);\n }\n decode(data: Uint8Array): string {\n return decoder.decode(data);\n }\n}\n\nconst utf8EnDecoder = new Utf8EnDecoder();\nexport function Utf8EnDecoderSingleton(): TxtEnDecoder {\n return utf8EnDecoder;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAM,UAAU,IAAI,YAAY;AAChC,IAAM,UAAU,IAAI,YAAY;AAEzB,IAAM,gBAAN,MAA4C;AAAA,EACjD,OAAO,KAAyB;AAC9B,WAAO,QAAQ,OAAO,GAAG;AAAA,EAC3B;AAAA,EACA,OAAO,MAA0B;AAC/B,WAAO,QAAQ,OAAO,IAAI;AAAA,EAC5B;AACF;AAEA,IAAM,gBAAgB,IAAI,cAAc;AACjC,SAAS,yBAAuC;AACrD,SAAO;AACT;","names":[]}
|