@adviser/cement 0.2.27 → 0.2.29
Sign up to get free protection for your applications and to get access to all the features.
- package/{base-sys-abstraction-C9WW3w57.d.cts → base-sys-abstraction-BkEiLHl0.d.ts} +8 -4
- package/{base-sys-abstraction-C9WW3w57.d.ts → base-sys-abstraction-Qj7pkY1N.d.cts} +8 -4
- package/{chunk-OXD3YZZ7.js → chunk-7KFVMTOS.js} +3 -47
- package/chunk-7KFVMTOS.js.map +1 -0
- package/{chunk-P5RXA4C4.js → chunk-GES3MUGV.js} +24 -27
- package/{chunk-LCPYQVWT.js.map → chunk-GES3MUGV.js.map} +1 -1
- package/{chunk-YDIUMYIE.js → chunk-Q65HLCNL.js} +8 -7
- package/chunk-Q65HLCNL.js.map +1 -0
- package/{chunk-DPIL5UIL.js → chunk-WMMUXBDX.js} +6 -2
- package/chunk-WMMUXBDX.js.map +1 -0
- package/{index-Dhb2fQiw.d.cts → index-Q3phXzYr.d.cts} +2 -21
- package/{index-CcsGcehs.d.ts → index-tIGZMHTc.d.ts} +2 -21
- package/index.cjs +265 -7343
- package/index.cjs.map +1 -1
- package/index.d.cts +73 -12
- package/index.d.ts +73 -12
- package/index.js +218 -7265
- package/index.js.map +1 -1
- package/node/index.cjs +220 -39
- package/node/index.cjs.map +1 -1
- package/node/index.d.cts +22 -4
- package/node/index.d.ts +22 -4
- package/node/index.js +201 -25
- package/node/index.js.map +1 -1
- package/package.json +23 -12
- package/src/LICENSE +201 -0
- package/src/README.md +39 -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/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/utils/index.cjs +0 -42
- package/utils/index.cjs.map +1 -1
- package/utils/index.d.cts +1 -2
- package/utils/index.d.ts +1 -2
- package/utils/index.js +2 -7
- package/web/index.cjs +25 -7
- package/web/index.cjs.map +1 -1
- package/web/index.d.cts +2 -1
- package/web/index.d.ts +2 -1
- package/web/index.js +3 -3
- package/chunk-DPIL5UIL.js.map +0 -1
- package/chunk-LCPYQVWT.js +0 -21
- package/chunk-OXD3YZZ7.js.map +0 -1
- package/chunk-P5RXA4C4.js.map +0 -1
- package/chunk-YDIUMYIE.js.map +0 -1
package/node/index.cjs
CHANGED
@@ -37,8 +37,11 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
37
37
|
// src/node/index.ts
|
38
38
|
var node_exports = {};
|
39
39
|
__export(node_exports, {
|
40
|
-
|
40
|
+
DenoExitServiceImpl: () => DenoExitServiceImpl,
|
41
|
+
DenoSysAbstraction: () => DenoSysAbstraction,
|
42
|
+
DenoSystemService: () => DenoSystemService,
|
41
43
|
MockFileService: () => MockFileService,
|
44
|
+
NodeExitServiceImpl: () => NodeExitServiceImpl,
|
42
45
|
NodeFileService: () => NodeFileService,
|
43
46
|
NodeSysAbstraction: () => NodeSysAbstraction,
|
44
47
|
NodeSystemService: () => NodeSystemService
|
@@ -48,6 +51,7 @@ module.exports = __toCommonJS(node_exports);
|
|
48
51
|
// src/node/node-file-service.ts
|
49
52
|
var import_node_path = __toESM(require("path"), 1);
|
50
53
|
var import_node_fs = __toESM(require("fs"), 1);
|
54
|
+
var import_node_process = __toESM(require("process"), 1);
|
51
55
|
|
52
56
|
// src/txt-en-decoder.ts
|
53
57
|
var encoder = new TextEncoder();
|
@@ -67,16 +71,17 @@ function Utf8EnDecoderSingleton() {
|
|
67
71
|
|
68
72
|
// src/node/node-file-service.ts
|
69
73
|
var NodeFileService = class {
|
70
|
-
constructor(baseDir =
|
74
|
+
constructor(baseDir = import_node_process.default.cwd()) {
|
71
75
|
this.baseDir = this.abs(baseDir);
|
72
76
|
}
|
73
|
-
nodeImport(fname) {
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
}
|
77
|
+
// nodeImport(fname: string): string {
|
78
|
+
// // console.log('nodeImport:'+ fname);
|
79
|
+
// if (path.isAbsolute(fname)) {
|
80
|
+
// return fname;
|
81
|
+
// } else {
|
82
|
+
// return "./" + path.normalize(fname);
|
83
|
+
// }
|
84
|
+
// }
|
80
85
|
readFileString(fname) {
|
81
86
|
return import_node_fs.default.promises.readFile(fname, { encoding: "utf-8" });
|
82
87
|
}
|
@@ -92,7 +97,7 @@ var NodeFileService = class {
|
|
92
97
|
relative(from, to) {
|
93
98
|
if (to === void 0) {
|
94
99
|
to = from;
|
95
|
-
from =
|
100
|
+
from = import_node_process.default.cwd();
|
96
101
|
}
|
97
102
|
const ret = import_node_path.default.relative(from, to);
|
98
103
|
return ret;
|
@@ -101,7 +106,7 @@ var NodeFileService = class {
|
|
101
106
|
if (import_node_path.default.isAbsolute(fname)) {
|
102
107
|
return fname;
|
103
108
|
} else {
|
104
|
-
const cwd =
|
109
|
+
const cwd = import_node_process.default.cwd();
|
105
110
|
return import_node_path.default.resolve(cwd, fname);
|
106
111
|
}
|
107
112
|
}
|
@@ -153,9 +158,9 @@ var SysTime = class extends Time {
|
|
153
158
|
return /* @__PURE__ */ new Date();
|
154
159
|
}
|
155
160
|
Sleep(duration) {
|
156
|
-
return new Promise((
|
161
|
+
return new Promise((resolve2) => {
|
157
162
|
setTimeout(() => {
|
158
|
-
|
163
|
+
resolve2();
|
159
164
|
}, duration);
|
160
165
|
});
|
161
166
|
}
|
@@ -240,32 +245,33 @@ var IdService = class {
|
|
240
245
|
}
|
241
246
|
}
|
242
247
|
};
|
243
|
-
var decoder2 = new TextDecoder();
|
244
248
|
var BaseSysAbstraction = class {
|
245
249
|
constructor(params) {
|
246
250
|
this._time = new SysTime();
|
251
|
+
this._idService = new IdService();
|
252
|
+
this._randomService = new RandomService("random" /* RANDOM */);
|
253
|
+
this._fileSystem = params.FileSystem;
|
254
|
+
this._systemService = params.SystemService;
|
255
|
+
this._txtEnDe = params.TxtEnDecoder;
|
256
|
+
const decoder2 = this._txtEnDe;
|
247
257
|
this._stdout = new WritableStream({
|
248
258
|
write(chunk) {
|
249
|
-
return new Promise((
|
259
|
+
return new Promise((resolve2) => {
|
250
260
|
const decoded = decoder2.decode(chunk);
|
251
261
|
console.log(decoded.trimEnd());
|
252
|
-
|
262
|
+
resolve2();
|
253
263
|
});
|
254
264
|
}
|
255
265
|
});
|
256
266
|
this._stderr = new WritableStream({
|
257
267
|
write(chunk) {
|
258
|
-
return new Promise((
|
268
|
+
return new Promise((resolve2) => {
|
259
269
|
const decoded = decoder2.decode(chunk);
|
260
270
|
console.error(decoded.trimEnd());
|
261
|
-
|
271
|
+
resolve2();
|
262
272
|
});
|
263
273
|
}
|
264
274
|
});
|
265
|
-
this._idService = new IdService();
|
266
|
-
this._randomService = new RandomService("random" /* RANDOM */);
|
267
|
-
this._fileSystem = params.FileSystem;
|
268
|
-
this._systemService = params.SystemService;
|
269
275
|
}
|
270
276
|
};
|
271
277
|
var WrapperSysAbstraction = class {
|
@@ -335,8 +341,8 @@ var Future = class {
|
|
335
341
|
__privateAdd(this, _rejectFn, () => {
|
336
342
|
throw new Error("This Promise is not working as expected.");
|
337
343
|
});
|
338
|
-
__privateSet(this, _promise, new Promise((
|
339
|
-
__privateSet(this, _resolveFn,
|
344
|
+
__privateSet(this, _promise, new Promise((resolve2, reject) => {
|
345
|
+
__privateSet(this, _resolveFn, resolve2);
|
340
346
|
__privateSet(this, _rejectFn, reject);
|
341
347
|
}));
|
342
348
|
}
|
@@ -605,7 +611,8 @@ var EnvImpl = class {
|
|
605
611
|
};
|
606
612
|
|
607
613
|
// src/node/node-sys-abstraction.ts
|
608
|
-
var
|
614
|
+
var import_node_process2 = __toESM(require("process"), 1);
|
615
|
+
var NodeExitServiceImpl = class {
|
609
616
|
constructor() {
|
610
617
|
this._exitHandlers = [];
|
611
618
|
this.invoked = false;
|
@@ -624,25 +631,25 @@ var ExitServiceImpl = class {
|
|
624
631
|
}
|
625
632
|
}
|
626
633
|
};
|
627
|
-
|
634
|
+
import_node_process2.default.on("unhandledRejection", (reason, p) => {
|
628
635
|
this.exit(19);
|
629
636
|
});
|
630
|
-
|
637
|
+
import_node_process2.default.on("uncaughtException", (error) => {
|
631
638
|
this.exit(18);
|
632
639
|
});
|
633
|
-
|
640
|
+
import_node_process2.default.on("close", () => {
|
634
641
|
this.exit(0);
|
635
642
|
});
|
636
|
-
|
643
|
+
import_node_process2.default.on("exit", () => {
|
637
644
|
this.exit(0);
|
638
645
|
});
|
639
|
-
|
646
|
+
import_node_process2.default.on("SIGQUIT", () => {
|
640
647
|
this.exit(3);
|
641
648
|
});
|
642
|
-
|
649
|
+
import_node_process2.default.on("SIGINT", () => {
|
643
650
|
this.exit(2);
|
644
651
|
});
|
645
|
-
|
652
|
+
import_node_process2.default.on("SIGTERM", () => {
|
646
653
|
this.exit(9);
|
647
654
|
});
|
648
655
|
}
|
@@ -651,23 +658,23 @@ var ExitServiceImpl = class {
|
|
651
658
|
}
|
652
659
|
exit(code) {
|
653
660
|
this._handleExit().then(() => {
|
654
|
-
|
661
|
+
import_node_process2.default.exit(code);
|
655
662
|
}).catch((err) => {
|
656
663
|
console.error("ExitService: failed to handle exit", err);
|
657
|
-
|
664
|
+
import_node_process2.default.exit(code);
|
658
665
|
});
|
659
666
|
}
|
660
667
|
};
|
661
668
|
var _NodeSystemService = class _NodeSystemService {
|
662
669
|
constructor() {
|
663
|
-
this._exitService = new
|
670
|
+
this._exitService = new NodeExitServiceImpl();
|
664
671
|
this._exitService.injectExitHandlers(_NodeSystemService._exitHandlers);
|
665
672
|
}
|
666
673
|
Env() {
|
667
674
|
return envFactory();
|
668
675
|
}
|
669
676
|
Args() {
|
670
|
-
return
|
677
|
+
return import_node_process2.default.argv;
|
671
678
|
}
|
672
679
|
OnExit(hdl) {
|
673
680
|
const id = crypto.randomUUID();
|
@@ -689,6 +696,7 @@ var my = void 0;
|
|
689
696
|
function NodeSysAbstraction(param) {
|
690
697
|
if (!my) {
|
691
698
|
my = new BaseSysAbstraction({
|
699
|
+
TxtEnDecoder: (param == null ? void 0 : param.TxtEnDecoder) || Utf8EnDecoderSingleton(),
|
692
700
|
FileSystem: new NodeFileService(),
|
693
701
|
SystemService: new NodeSystemService()
|
694
702
|
});
|
@@ -696,6 +704,176 @@ function NodeSysAbstraction(param) {
|
|
696
704
|
return new WrapperSysAbstraction(my, param);
|
697
705
|
}
|
698
706
|
|
707
|
+
// src/node/deno-sys-abstraction.ts
|
708
|
+
var process3 = __toESM(require("process"), 1);
|
709
|
+
|
710
|
+
// src/node/deno-file-service.ts
|
711
|
+
var path2 = __toESM(require("path"), 1);
|
712
|
+
var Deno = globalThis.Deno;
|
713
|
+
var DenoFileService = class {
|
714
|
+
constructor(baseDir = Deno.cwd(), txtEnde = Utf8EnDecoderSingleton()) {
|
715
|
+
this.baseDir = this.abs(baseDir);
|
716
|
+
this.txtEnde = txtEnde;
|
717
|
+
}
|
718
|
+
// nodeImport(fname: string): string {
|
719
|
+
// // console.log('nodeImport:'+ fname);
|
720
|
+
// if (path.isAbsolute(fname)) {
|
721
|
+
// return fname;
|
722
|
+
// } else {
|
723
|
+
// return "./" + path.normalize(fname);
|
724
|
+
// }
|
725
|
+
// }
|
726
|
+
async readFileString(fname) {
|
727
|
+
return this.txtEnde.decode(await Deno.readFile(fname));
|
728
|
+
}
|
729
|
+
dirname(fname) {
|
730
|
+
return path2.dirname(fname);
|
731
|
+
}
|
732
|
+
basename(fname) {
|
733
|
+
return path2.basename(fname);
|
734
|
+
}
|
735
|
+
join(...paths) {
|
736
|
+
return path2.join(...paths);
|
737
|
+
}
|
738
|
+
relative(from, to) {
|
739
|
+
if (to === void 0) {
|
740
|
+
to = from;
|
741
|
+
from = Deno.cwd();
|
742
|
+
}
|
743
|
+
const ret = path2.relative(from, to);
|
744
|
+
return ret;
|
745
|
+
}
|
746
|
+
abs(fname) {
|
747
|
+
if (path2.isAbsolute(fname)) {
|
748
|
+
return fname;
|
749
|
+
} else {
|
750
|
+
const cwd = Deno.cwd();
|
751
|
+
return path2.resolve(cwd, fname);
|
752
|
+
}
|
753
|
+
}
|
754
|
+
isAbsolute(fname) {
|
755
|
+
return path2.isAbsolute(fname);
|
756
|
+
}
|
757
|
+
async writeFileString(fname, content, ende = Utf8EnDecoderSingleton()) {
|
758
|
+
const o = await this.create(fname);
|
759
|
+
const wr = o.stream.getWriter();
|
760
|
+
await wr.write(ende.encode(content));
|
761
|
+
await wr.close();
|
762
|
+
}
|
763
|
+
async create(fname) {
|
764
|
+
let oName = fname;
|
765
|
+
if (!path2.isAbsolute(fname)) {
|
766
|
+
oName = this.abs(fname);
|
767
|
+
}
|
768
|
+
const base = path2.dirname(oName);
|
769
|
+
await Deno.mkdir(base, { recursive: true });
|
770
|
+
const out = await Deno.open(oName, {
|
771
|
+
write: true,
|
772
|
+
create: true,
|
773
|
+
truncate: true
|
774
|
+
});
|
775
|
+
return {
|
776
|
+
name: oName,
|
777
|
+
stream: out
|
778
|
+
};
|
779
|
+
}
|
780
|
+
};
|
781
|
+
|
782
|
+
// src/node/deno-sys-abstraction.ts
|
783
|
+
var Deno2 = globalThis.Deno;
|
784
|
+
var DenoExitServiceImpl = class {
|
785
|
+
constructor() {
|
786
|
+
this._exitHandlers = [];
|
787
|
+
this.invoked = false;
|
788
|
+
this._handleExit = async () => {
|
789
|
+
if (this.invoked) {
|
790
|
+
return;
|
791
|
+
}
|
792
|
+
this.invoked = true;
|
793
|
+
for (const h of this._exitHandlers) {
|
794
|
+
try {
|
795
|
+
const ret = h.hdl();
|
796
|
+
if (typeof ret.then === "function") {
|
797
|
+
await ret;
|
798
|
+
}
|
799
|
+
} finally {
|
800
|
+
}
|
801
|
+
}
|
802
|
+
};
|
803
|
+
globalThis.addEventListener("unhandledrejection", (e) => {
|
804
|
+
e.preventDefault();
|
805
|
+
this.exit(19);
|
806
|
+
});
|
807
|
+
globalThis.addEventListener("error", () => {
|
808
|
+
this.exit(19);
|
809
|
+
});
|
810
|
+
globalThis.addEventListener("uncaughtException", () => {
|
811
|
+
this.exit(19);
|
812
|
+
});
|
813
|
+
globalThis.addEventListener("unload", () => {
|
814
|
+
this.exit(0);
|
815
|
+
});
|
816
|
+
Deno2.addSignalListener("SIGQUIT", () => {
|
817
|
+
this.exit(3);
|
818
|
+
});
|
819
|
+
Deno2.addSignalListener("SIGINT", () => {
|
820
|
+
this.exit(2);
|
821
|
+
});
|
822
|
+
Deno2.addSignalListener("SIGTERM", () => {
|
823
|
+
this.exit(9);
|
824
|
+
});
|
825
|
+
}
|
826
|
+
injectExitHandlers(hdls) {
|
827
|
+
this._exitHandlers = hdls;
|
828
|
+
}
|
829
|
+
exit(code) {
|
830
|
+
this._handleExit().then(() => {
|
831
|
+
Deno2.exit(code);
|
832
|
+
}).catch((err) => {
|
833
|
+
console.error("ExitService: failed to handle exit", err);
|
834
|
+
Deno2.exit(code);
|
835
|
+
});
|
836
|
+
}
|
837
|
+
};
|
838
|
+
var _DenoSystemService = class _DenoSystemService {
|
839
|
+
constructor() {
|
840
|
+
this._exitService = new DenoExitServiceImpl();
|
841
|
+
this._exitService.injectExitHandlers(_DenoSystemService._exitHandlers);
|
842
|
+
}
|
843
|
+
Env() {
|
844
|
+
return envFactory();
|
845
|
+
}
|
846
|
+
Args() {
|
847
|
+
return process3.argv;
|
848
|
+
}
|
849
|
+
OnExit(hdl) {
|
850
|
+
const id = crypto.randomUUID();
|
851
|
+
_DenoSystemService._exitHandlers.push({ hdl, id });
|
852
|
+
return () => {
|
853
|
+
const idx = _DenoSystemService._exitHandlers.findIndex((h) => h.id === id);
|
854
|
+
if (idx >= 0) {
|
855
|
+
_DenoSystemService._exitHandlers.splice(idx, 1);
|
856
|
+
}
|
857
|
+
};
|
858
|
+
}
|
859
|
+
Exit(code) {
|
860
|
+
this._exitService.exit(code);
|
861
|
+
}
|
862
|
+
};
|
863
|
+
_DenoSystemService._exitHandlers = [];
|
864
|
+
var DenoSystemService = _DenoSystemService;
|
865
|
+
var my2 = void 0;
|
866
|
+
function DenoSysAbstraction(param) {
|
867
|
+
if (!my2) {
|
868
|
+
my2 = new BaseSysAbstraction({
|
869
|
+
TxtEnDecoder: (param == null ? void 0 : param.TxtEnDecoder) || Utf8EnDecoderSingleton(),
|
870
|
+
FileSystem: new DenoFileService(),
|
871
|
+
SystemService: new DenoSystemService()
|
872
|
+
});
|
873
|
+
}
|
874
|
+
return new WrapperSysAbstraction(my2, param);
|
875
|
+
}
|
876
|
+
|
699
877
|
// src/node/mock-file-service.ts
|
700
878
|
var MockFileService = class extends NodeFileService {
|
701
879
|
constructor() {
|
@@ -716,12 +894,12 @@ var MockFileService = class extends NodeFileService {
|
|
716
894
|
};
|
717
895
|
this.files[oName] = fc;
|
718
896
|
this.files[fname] = fc;
|
719
|
-
const
|
897
|
+
const decoder2 = new TextDecoder();
|
720
898
|
return {
|
721
899
|
name: oName,
|
722
900
|
stream: new WritableStream({
|
723
901
|
write(chunk) {
|
724
|
-
fc.content = fc.content +
|
902
|
+
fc.content = fc.content + decoder2.decode(chunk);
|
725
903
|
},
|
726
904
|
close() {
|
727
905
|
},
|
@@ -734,8 +912,11 @@ var MockFileService = class extends NodeFileService {
|
|
734
912
|
};
|
735
913
|
// Annotate the CommonJS export names for ESM import in node:
|
736
914
|
0 && (module.exports = {
|
737
|
-
|
915
|
+
DenoExitServiceImpl,
|
916
|
+
DenoSysAbstraction,
|
917
|
+
DenoSystemService,
|
738
918
|
MockFileService,
|
919
|
+
NodeExitServiceImpl,
|
739
920
|
NodeFileService,
|
740
921
|
NodeSysAbstraction,
|
741
922
|
NodeSystemService
|
package/node/index.cjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/node/index.ts","../../../src/node/node-file-service.ts","../../../src/txt-en-decoder.ts","../../../src/time.ts","../../../src/base-sys-abstraction.ts","../../../src/future.ts","../../../src/resolve-once.ts","../../../src/sys-env.ts","../../../src/node/node-sys-abstraction.ts","../../../src/node/mock-file-service.ts"],"sourcesContent":["export * from \"./node-file-service\";\nexport * from \"./node-sys-abstraction\";\nexport * from \"./mock-file-service\";\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport { FileService, NamedWritableStream } from \"../file-service\";\nimport { Utf8EnDecoderSingleton } from \"../txt-en-decoder\";\n\nexport class NodeFileService implements FileService {\n readonly baseDir: string;\n constructor(baseDir: string = process.cwd()) {\n this.baseDir = this.abs(baseDir);\n }\n\n nodeImport(fname: string): string {\n // console.log('nodeImport:'+ fname);\n if (path.isAbsolute(fname)) {\n return fname;\n } else {\n return \"./\" + path.normalize(fname);\n }\n }\n\n readFileString(fname: string): Promise<string> {\n return fs.promises.readFile(fname, { encoding: \"utf-8\" });\n }\n\n dirname(fname: string): string {\n return path.dirname(fname);\n }\n basename(fname: string): string {\n return path.basename(fname);\n }\n\n join(...paths: string[]): string {\n return path.join(...paths);\n }\n\n relative(from: string, to?: string): string {\n if (to === undefined) {\n to = from;\n from = process.cwd();\n }\n const ret = path.relative(from, to);\n // console.log('relative:'+ from + \" -> \" + to + \"= \" + ret);\n return ret;\n }\n\n abs(fname: string): string {\n if (path.isAbsolute(fname)) {\n return fname;\n } else {\n const cwd = process.cwd();\n return path.resolve(cwd, fname);\n }\n }\n\n isAbsolute(fname: string): boolean {\n return path.isAbsolute(fname);\n }\n\n async writeFileString(fname: string, content: string, ende = Utf8EnDecoderSingleton()): Promise<void> {\n const o = await this.create(fname);\n const wr = o.stream.getWriter();\n await wr.write(ende.encode(content));\n await wr.close();\n }\n\n async create(fname: string): Promise<NamedWritableStream> {\n let oName = fname;\n if (!path.isAbsolute(fname)) {\n oName = this.abs(fname);\n }\n\n const base = path.dirname(oName);\n await fs.promises.mkdir(base, { recursive: true });\n const out = fs.createWriteStream(oName);\n return {\n name: oName,\n stream: new WritableStream<Uint8Array>({\n write(chunk) {\n out.write(chunk);\n },\n close() {\n out.close();\n },\n abort() {\n throw new Error(\"not implemented\");\n },\n }),\n };\n }\n}\n","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","export abstract class Time {\n abstract Now(add?: number): Date;\n abstract Sleep(duration: Duration): Promise<void>;\n TimeSince(start: Date): Duration {\n const now = this.Now();\n return now.getTime() - start.getTime();\n }\n}\n\nexport type Duration = number;\n\nexport enum TimeUnits {\n Microsecond = 1,\n // eslint-disable-next-line @typescript-eslint/prefer-literal-enum-member\n Second = 1000 * Microsecond,\n // eslint-disable-next-line @typescript-eslint/prefer-literal-enum-member\n Minute = 60 * Second,\n // eslint-disable-next-line @typescript-eslint/prefer-literal-enum-member\n Hour = 60 * Minute,\n}\n","import { FileService } from \"./file-service\";\nimport { TimeMode, RandomMode, IDMode, SystemService, VoidFunc, SysAbstraction } from \"./sys-abstraction\";\nimport { Time } from \"./time\";\n\nexport class SysTime extends Time {\n Now(): Date {\n return new Date();\n }\n Sleep(duration: number): Promise<void> {\n return new Promise((resolve) => {\n setTimeout(() => {\n resolve();\n }, duration);\n });\n }\n}\n\nexport class ConstTime extends Time {\n Now(): Date {\n return new Date(2021, 1, 1, 0, 0, 0, 0);\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n Sleep(duration: number): Promise<void> {\n return Promise.resolve();\n }\n}\n\nexport class StepTime extends Time {\n _step: Date;\n readonly _start: Date;\n constructor() {\n super();\n this._step = new ConstTime().Now();\n this._start = this._step;\n }\n Now(steps = 1): Date {\n // if (this._step.getTime() === 0) {\n // this._step = new ConstTime().Now();\n // return this._step;\n // }\n for (let i = 0; steps > 0 && i < steps; i++) {\n this._step = new Date(this._step.getTime() + 1000);\n }\n if (steps < 1) {\n this._step = new Date(this._start.getTime() + steps * -1000);\n }\n // this._step = new Date(this._step.getTime() + 1000);\n return this._step;\n }\n Sleep(duration: number): Promise<void> {\n this._step = new Date(this._step.getTime() + duration);\n return Promise.resolve();\n }\n}\n\nexport function TimeFactory(timeMode: TimeMode): Time {\n switch (timeMode) {\n case TimeMode.REAL:\n return new SysTime();\n case TimeMode.CONST:\n return new ConstTime();\n case TimeMode.STEP:\n return new StepTime();\n }\n return new SysTime();\n}\n\nexport class RandomService {\n readonly _mode: RandomMode;\n _step = 0;\n constructor(mode: RandomMode) {\n this._mode = mode;\n }\n Random0ToValue(value: number): number {\n switch (this._mode) {\n case RandomMode.CONST:\n return 0.5 * value;\n case RandomMode.STEP:\n this._step += 0.0001;\n return this._step * value;\n case RandomMode.RANDOM:\n return Math.random() * value;\n default:\n throw new Error(\"Unknown RandomMode\");\n }\n }\n}\n\nexport class IdService {\n readonly _mode: IDMode;\n _step = 0;\n constructor(mode?: IDMode) {\n if (!mode) {\n mode = IDMode.UUID;\n }\n this._mode = mode;\n }\n NextId(): string {\n switch (this._mode) {\n case IDMode.UUID:\n return crypto.randomUUID();\n case IDMode.CONST:\n return \"VeryUniqueID\";\n case IDMode.STEP:\n return `STEPId-${this._step++}`;\n default:\n throw new Error(\"Unknown IDMode\");\n }\n }\n}\n\nexport interface BaseSysAbstractionParams {\n readonly FileSystem: FileService;\n readonly SystemService: SystemService;\n}\n\nexport interface ExitHandler {\n readonly hdl: VoidFunc;\n readonly id: string;\n}\n\nexport interface ExitService {\n injectExitHandlers(hdls: ExitHandler[]): void;\n exit(code: number): void;\n}\n\nconst decoder = new TextDecoder();\nexport class BaseSysAbstraction {\n readonly _time = new SysTime();\n readonly _stdout = new WritableStream({\n write(chunk) {\n return new Promise((resolve) => {\n const decoded = decoder.decode(chunk);\n // eslint-disable-next-line no-console\n console.log(decoded.trimEnd());\n resolve();\n });\n },\n });\n readonly _stderr = new WritableStream({\n write(chunk) {\n return new Promise((resolve) => {\n const decoded = decoder.decode(chunk);\n // eslint-disable-next-line no-console\n console.error(decoded.trimEnd());\n resolve();\n });\n },\n });\n\n readonly _idService = new IdService();\n readonly _randomService = new RandomService(RandomMode.RANDOM);\n readonly _fileSystem: FileService;\n readonly _systemService: SystemService;\n\n constructor(params: BaseSysAbstractionParams) {\n this._fileSystem = params.FileSystem;\n this._systemService = params.SystemService;\n }\n}\n\nexport interface WrapperSysAbstractionParams {\n readonly TimeMode?: TimeMode;\n readonly IdMode?: IDMode;\n readonly Stdout?: WritableStream<Uint8Array>;\n readonly Stderr?: WritableStream<Uint8Array>;\n readonly RandomMode?: RandomMode;\n readonly FileSystem?: FileService;\n readonly SystemService?: SystemService;\n}\n\nexport class WrapperSysAbstraction implements SysAbstraction {\n readonly _time: Time;\n readonly _stdout: WritableStream<Uint8Array>;\n readonly _stderr: WritableStream<Uint8Array>;\n readonly _idService: IdService;\n readonly _randomService: RandomService;\n readonly _fileSystem: FileService;\n readonly _systemService: SystemService;\n constructor(base: BaseSysAbstraction, params?: WrapperSysAbstractionParams) {\n this._time = base._time;\n this._stdout = base._stdout;\n this._stderr = base._stderr;\n this._idService = base._idService;\n this._randomService = base._randomService;\n this._fileSystem = base._fileSystem;\n this._systemService = base._systemService;\n if (params) {\n if (params.TimeMode) {\n this._time = TimeFactory(params.TimeMode);\n }\n if (params.Stdout) {\n this._stdout = params.Stdout;\n }\n if (params.Stderr) {\n this._stderr = params.Stderr;\n }\n if (params.IdMode) {\n this._idService = new IdService(params.IdMode);\n }\n if (params.RandomMode) {\n this._randomService = new RandomService(params.RandomMode);\n }\n if (params.FileSystem) {\n this._fileSystem = params.FileSystem;\n }\n if (params.SystemService) {\n this._systemService = params.SystemService;\n }\n }\n }\n Time(): Time {\n return this._time;\n }\n NextId(): string {\n return this._idService.NextId();\n }\n Random0ToValue(value: number): number {\n return this._randomService.Random0ToValue(value);\n }\n Stdout(): WritableStream {\n return this._stdout;\n }\n Stderr(): WritableStream {\n return this._stderr;\n }\n\n System(): SystemService {\n return this._systemService;\n }\n FileSystem(): FileService {\n return this._fileSystem;\n }\n}\n// export const BaseSysAbstraction = new BaseSysAbstractionImpl()\n","export class Future<T> {\n readonly #promise: Promise<T>;\n #resolveFn: (value: T) => void = () => {\n throw new Error(\"This Promise is not working as expected.\");\n };\n #rejectFn: (reason: unknown) => void = () => {\n throw new Error(\"This Promise is not working as expected.\");\n };\n\n constructor() {\n this.#promise = new Promise<T>((resolve, reject) => {\n this.#resolveFn = resolve;\n this.#rejectFn = reject;\n });\n }\n\n async asPromise(): Promise<T> {\n return this.#promise;\n }\n\n resolve(value: T) {\n this.#resolveFn(value);\n }\n reject(reason: unknown) {\n this.#rejectFn(reason);\n }\n}\n","import { Future } from \"./future\";\n\ninterface ResolveSeqItem<T, C> {\n readonly future: Future<T>;\n readonly fn: (c: C) => Promise<T>;\n readonly id?: number;\n}\n\nexport class ResolveSeq<T, C = void> {\n readonly ctx: C;\n constructor(ctx?: C) {\n this.ctx = ctx as C;\n }\n reset() {\n /* noop */\n }\n async _step(item?: ResolveSeqItem<T, C> | undefined) {\n if (!item) {\n // done\n return;\n }\n item\n .fn(this.ctx)\n .then((value) => item.future.resolve(value))\n .catch((e) => item.future.reject(e as Error))\n .finally(() => {\n this._seqFutures.shift();\n this._step(this._seqFutures[0]);\n });\n }\n readonly _seqFutures: ResolveSeqItem<T, C>[] = [];\n async add(fn: (c: C) => Promise<T>, id?: number): Promise<T> {\n const future = new Future<T>();\n this._seqFutures.push({ future, fn, id });\n if (this._seqFutures.length === 1) {\n this._step(this._seqFutures[0]);\n }\n return future.asPromise();\n }\n}\n\nexport class ResolveOnce<T, CTX = void> {\n _onceDone = false;\n readonly _onceFutures: Future<T>[] = [];\n _onceOk = false;\n _onceValue?: T;\n _onceError?: Error;\n _isPromise = false;\n\n readonly ctx: CTX;\n\n constructor(ctx?: CTX) {\n this.ctx = ctx as CTX;\n }\n\n get ready() {\n return this._onceDone;\n }\n\n reset() {\n this._onceDone = false;\n this._onceOk = false;\n this._onceValue = undefined;\n this._onceError = undefined;\n this._onceFutures.length = 0;\n }\n\n // T extends Option<infer U> ? U : T\n once<R>(fn: (c: CTX) => R): R {\n if (this._onceDone) {\n if (this._onceError) {\n if (this._isPromise) {\n return Promise.reject(this._onceError) as unknown as R;\n } else {\n throw this._onceError;\n }\n }\n if (this._onceOk) {\n if (this._isPromise) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return Promise.resolve(this._onceValue!) as unknown as R;\n } else {\n return this._onceValue as unknown as R;\n }\n }\n throw new Error(\"ResolveOnce.once impossible\");\n }\n const future = new Future<T>();\n this._onceFutures.push(future);\n if (this._onceFutures.length === 1) {\n const okFn = (value: T) => {\n this._onceValue = value;\n this._onceOk = true;\n this._onceDone = true;\n if (this._isPromise) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this._onceFutures.forEach((f) => f.resolve(this._onceValue!));\n }\n this._onceFutures.length = 0;\n };\n const catchFn = (e: Error) => {\n this._onceError = e as Error;\n this._onceOk = false;\n this._onceValue = undefined;\n this._onceDone = true;\n if (this._isPromise) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this._onceFutures.forEach((f) => f.reject(this._onceError!));\n }\n this._onceFutures.length = 0;\n };\n try {\n const ret = fn(this.ctx);\n if (typeof (ret as Promise<T>).then === \"function\") {\n this._isPromise = true;\n (ret as Promise<T>).then(okFn).catch(catchFn);\n } else {\n okFn(ret as unknown as T);\n }\n } catch (e) {\n catchFn(e as Error);\n }\n }\n if (this._isPromise) {\n return future.asPromise() as unknown as R;\n } else {\n // abit funky but i don't want to impl the return just once\n return this.once(fn);\n }\n }\n}\n\nexport class Keyed<T extends { reset: () => void }, K = string> {\n private readonly _map = new Map<K, T>();\n\n readonly factory: (key: K) => T;\n constructor(factory: (key: K) => T) {\n this.factory = factory;\n }\n\n async asyncGet(key: () => Promise<K>): Promise<T> {\n return this.get(await key());\n }\n\n get(key: K | (() => K)): T {\n if (typeof key === \"function\") {\n key = (key as () => K)();\n }\n let keyed = this._map.get(key);\n if (!keyed) {\n keyed = this.factory(key);\n this._map.set(key, keyed);\n }\n return keyed;\n }\n\n unget(key: K) {\n const keyed = this._map.get(key);\n keyed?.reset();\n this._map.delete(key);\n }\n\n reset() {\n this._map.forEach((keyed) => keyed.reset());\n this._map.clear();\n }\n}\n\nexport class KeyedResolvOnce<T, K = string> extends Keyed<ResolveOnce<T, K>, K> {\n constructor() {\n super((key) => new ResolveOnce<T, K>(key));\n }\n}\n\nexport class KeyedResolvSeq<T, K = string> extends Keyed<ResolveSeq<T, K>, K> {\n constructor() {\n super((key) => new ResolveSeq<T, K>(key));\n }\n}\n","import { ResolveOnce } from \"./resolve-once\";\n\nexport interface EnvMap {\n get(key: string): string | undefined;\n set(key: string, value?: string): void;\n delete(key: string): void;\n keys(): string[];\n}\nexport interface EnvActions extends EnvMap {\n active(): boolean;\n register(env: Env): Env;\n}\n\nclass NodeEnvActions implements EnvActions {\n readonly #node = globalThis as unknown as { process: { env: Record<string, string> } };\n\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor, @typescript-eslint/no-unused-vars\n constructor(opts: Partial<EnvFactoryOpts>) {\n // do nothing\n }\n\n register(env: Env): Env {\n return env;\n }\n\n active(): boolean {\n return typeof this.#node === \"object\" && typeof this.#node.process === \"object\" && typeof this.#node.process.env === \"object\";\n }\n readonly _env = this.active() ? this.#node.process.env : {};\n keys(): string[] {\n return Object.keys(this._env);\n }\n get(key: string): string | undefined {\n return this._env[key];\n }\n set(key: string, value?: string): void {\n if (value) {\n this._env[key] = value;\n }\n }\n delete(key: string): void {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._env[key];\n }\n}\n\nclass DenoEnvActions implements EnvActions {\n readonly #deno = globalThis as unknown as { Deno: { env: Map<string, string> } };\n\n get _env(): Map<string, string> {\n return this.#deno.Deno.env;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor, @typescript-eslint/no-unused-vars\n constructor(opts: Partial<EnvFactoryOpts>) {\n // do nothing\n }\n\n register(env: Env): Env {\n return env;\n }\n active(): boolean {\n return typeof this.#deno === \"object\" && typeof this.#deno.Deno === \"object\" && typeof this.#deno.Deno.env === \"object\";\n }\n keys(): string[] {\n return Array.from(this._env.keys());\n }\n get(key: string): string | undefined {\n return this._env.get(key);\n }\n set(key: string, value?: string): void {\n if (value) {\n this._env.set(key, value);\n }\n }\n delete(key: string): void {\n this._env.delete(key);\n }\n}\n\nexport class BrowserEnvActions implements EnvActions {\n readonly env = new Map<string, string>();\n readonly opts: Partial<EnvFactoryOpts>;\n constructor(opts: Partial<EnvFactoryOpts>) {\n this.opts = opts;\n }\n\n get(key: string): string | undefined {\n return this.env.get(key);\n }\n set(key: string, value?: string): void {\n if (value) {\n this.env.set(key, value);\n }\n }\n delete(key: string): void {\n this.env.delete(key);\n }\n keys(): string[] {\n return Array.from(this.env.keys());\n }\n active(): boolean {\n return true; // that should work on every runtime\n }\n\n register(env: Env): Env {\n const sym = Symbol.for(this.opts.symbol || \"CP_ENV\");\n const browser = globalThis as unknown as Record<symbol, Env>;\n browser[sym] = env;\n return env;\n }\n}\n\nexport interface EnvFactoryOpts {\n readonly symbol: string; // default \"CP_ENV\" used by BrowserEnvActions\n readonly presetEnv: Map<string, string>;\n}\n\ntype OnSetFn = (key: string, value?: string) => void;\nexport interface OnSetItem {\n readonly filter: Set<string>;\n readonly fn: OnSetFn;\n}\n\nexport interface Env extends EnvMap {\n onSet(fn: OnSetFn, ...filter: string[]): void;\n}\n\nconst _envFactory = new ResolveOnce<Env>();\nexport function envFactory(opts: Partial<EnvFactoryOpts> = {}): Env {\n return _envFactory.once(() => {\n const found = [new NodeEnvActions(opts), new DenoEnvActions(opts), new BrowserEnvActions(opts)].find((env) => env.active());\n if (!found) {\n throw new Error(\"SysContainer:envFactory: no env available\");\n }\n const ret = new EnvImpl(found, opts);\n found.register(ret);\n return ret;\n });\n}\n\nexport class EnvImpl implements Env {\n readonly _map: EnvMap;\n constructor(map: EnvMap, opts: Partial<EnvFactoryOpts> = {}) {\n this._map = map;\n this._updatePresets(opts.presetEnv);\n }\n _updatePresets(presetEnv?: Map<string, string>): void {\n if (!presetEnv) {\n return;\n }\n for (const [key, value] of presetEnv) {\n this._map.set(key, value);\n }\n }\n _applyOnSet(onSet: OnSetItem[], key?: string, value?: string): void {\n onSet.forEach((item) => {\n let keys: string[] = [];\n if (key) {\n keys = [key];\n } else {\n keys = this._map.keys();\n }\n keys\n .filter((k) => {\n if (item.filter.size === 0) {\n return true;\n }\n if (item.filter.has(k)) {\n return true;\n }\n return false;\n })\n .forEach((k) => {\n let v;\n if (!key && !value) {\n // init\n v = this._map.get(k);\n } else if (key && !value) {\n // del\n v = undefined;\n } else {\n // set\n v = value;\n }\n item.fn(k, v);\n });\n });\n }\n readonly _onSet: OnSetItem[] = [];\n keys(): string[] {\n return this._map.keys();\n }\n // filter is not set all sets passed\n onSet(fn: OnSetFn, ...filter: string[]): void {\n const item: OnSetItem = { filter: new Set(filter), fn };\n this._onSet.push(item);\n this._applyOnSet([item]);\n }\n get(key: string): string | undefined {\n return this._map.get(key);\n }\n set(key: string, value?: string): void {\n if (!value) {\n return;\n }\n this._map.set(key, value);\n this._applyOnSet(this._onSet, key, value);\n }\n delete(key: string): void {\n this._map.delete(key);\n this._applyOnSet(this._onSet, key);\n }\n}\n\n// export const envImpl = new EnvImpl();\n","import { SysAbstraction, SystemService, VoidFunc } from \"../sys-abstraction\";\nimport {\n BaseSysAbstraction,\n ExitHandler,\n ExitService,\n WrapperSysAbstraction,\n WrapperSysAbstractionParams,\n} from \"../base-sys-abstraction\";\nimport { NodeFileService } from \"./node-file-service\";\nimport { envFactory } from \"../sys-env\";\n\nexport class ExitServiceImpl implements ExitService {\n constructor() {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n process.on(\"unhandledRejection\", (reason: string, p: Promise<unknown>) => {\n this.exit(19);\n });\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n process.on(\"uncaughtException\", (error: Error) => {\n this.exit(18);\n });\n process.on(\"close\", () => {\n this.exit(0);\n });\n process.on(\"exit\", () => {\n this.exit(0);\n });\n process.on(\"SIGQUIT\", () => {\n this.exit(3);\n });\n process.on(\"SIGINT\", () => {\n this.exit(2);\n });\n process.on(\"SIGTERM\", () => {\n this.exit(9);\n });\n }\n _exitHandlers: ExitHandler[] = [];\n injectExitHandlers(hdls: ExitHandler[]): void {\n // console.log(\"ExitService: injecting exit handlers\", hdls)\n this._exitHandlers = hdls;\n }\n invoked = false;\n readonly _handleExit = async (): Promise<void> => {\n if (this.invoked) {\n // console.error(\"ExitService: already invoked\");\n return;\n }\n this.invoked = true;\n for (const h of this._exitHandlers) {\n try {\n // console.log(`ExitService: calling handler ${h.id}`)\n const ret = h.hdl();\n // console.log(`ExitService: called handler ${h.id}`, ret)\n if (typeof (ret as Promise<void>).then === \"function\") {\n await ret;\n }\n } finally {\n // ignore\n }\n }\n };\n\n exit(code: number): void {\n // console.log(\"ExitService: exit called\", code)\n this._handleExit()\n .then(() => {\n process.exit(code);\n })\n .catch((err) => {\n // eslint-disable-next-line no-console\n console.error(\"ExitService: failed to handle exit\", err);\n process.exit(code);\n });\n }\n}\n\nexport class NodeSystemService implements SystemService {\n static readonly _exitHandlers: ExitHandler[] = [];\n readonly _exitService: ExitService = new ExitServiceImpl();\n constructor() {\n this._exitService.injectExitHandlers(NodeSystemService._exitHandlers);\n }\n\n Env() {\n return envFactory();\n }\n\n Args() {\n return process.argv;\n }\n\n OnExit(hdl: VoidFunc): VoidFunc {\n const id = crypto.randomUUID();\n NodeSystemService._exitHandlers.push({ hdl, id });\n return () => {\n const idx = NodeSystemService._exitHandlers.findIndex((h) => h.id === id);\n if (idx >= 0) {\n NodeSystemService._exitHandlers.splice(idx, 1);\n }\n };\n }\n\n Exit(code: number): void {\n this._exitService.exit(code);\n }\n}\n\nlet my: BaseSysAbstraction | undefined = undefined;\nexport function NodeSysAbstraction(param?: WrapperSysAbstractionParams): SysAbstraction {\n if (!my) {\n my = new BaseSysAbstraction({\n FileSystem: new NodeFileService(),\n SystemService: new NodeSystemService(),\n });\n }\n return new WrapperSysAbstraction(my, param);\n}\n","import { NamedWritableStream } from \"../file-service\";\nimport { NodeFileService } from \"./node-file-service\";\n\nexport interface FileCollector {\n readonly name: string;\n content: string;\n}\n\nexport class MockFileService extends NodeFileService {\n readonly files = {} as Record<string, FileCollector>;\n\n // override abs(fname: string): string {\n // return this.join(\"/mock/\", fname);\n // }\n\n override async create(fname: string): Promise<NamedWritableStream> {\n let oName = fname;\n if (!this.isAbsolute(fname)) {\n oName = await this.abs(fname);\n }\n\n const fc = {\n name: oName,\n content: \"\",\n };\n this.files[oName] = fc;\n this.files[fname] = fc;\n const decoder = new TextDecoder();\n\n return {\n name: oName,\n stream: new WritableStream<Uint8Array>({\n write(chunk) {\n fc.content = fc.content + decoder.decode(chunk);\n },\n close() {\n // do nothing\n },\n abort() {\n throw new Error(\"not implemented\");\n },\n }),\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,uBAAiB;AACjB,qBAAe;;;ACIf,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;;;ADfO,IAAM,kBAAN,MAA6C;AAAA,EAElD,YAAY,UAAkB,QAAQ,IAAI,GAAG;AAC3C,SAAK,UAAU,KAAK,IAAI,OAAO;AAAA,EACjC;AAAA,EAEA,WAAW,OAAuB;AAEhC,QAAI,iBAAAA,QAAK,WAAW,KAAK,GAAG;AAC1B,aAAO;AAAA,IACT,OAAO;AACL,aAAO,OAAO,iBAAAA,QAAK,UAAU,KAAK;AAAA,IACpC;AAAA,EACF;AAAA,EAEA,eAAe,OAAgC;AAC7C,WAAO,eAAAC,QAAG,SAAS,SAAS,OAAO,EAAE,UAAU,QAAQ,CAAC;AAAA,EAC1D;AAAA,EAEA,QAAQ,OAAuB;AAC7B,WAAO,iBAAAD,QAAK,QAAQ,KAAK;AAAA,EA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AA,EAA9C;AAAA;AACL,SAAS,QAAQ,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMlB,MAAe,OAAO,OAA6C;AACjE,QAAI,QAAQ;AACZ,QAAI,CAAC,KAAK,WAAW,KAAK,GAAG;AAC3B,cAAQ,MAAM,KAAK,IAAI,KAAK;AAAA,IAC9B;AAEA,UAAM,KAAK;AAAA,MACT,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AACA,SAAK,MAAM,KAAK,IAAI;AACpB,SAAK,MAAM,KAAK,IAAI;AACpB,UAAMC,WAAU,IAAI,YAAY;AAEhC,WAAO;AAAA,MACL,MAAM;AAAA,MACN,QAAQ,IAAI,eAA2B;AAAA,QACrC,MAAM,OAAO;AACX,aAAG,UAAU,GAAG,UAAUA,SAAQ,OAAO,KAAK;AAAA,QAChD;AAAA,QACA,QAAQ;AAAA,QAER;AAAA,QACA,QAAQ;AACN,gBAAM,IAAI,MAAM,iBAAiB;AAAA,QACnC;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":["path","fs","decoder","decoder"]}
|
1
|
+
{"version":3,"sources":["../../../src/node/index.ts","../../../src/node/node-file-service.ts","../../../src/txt-en-decoder.ts","../../../src/time.ts","../../../src/base-sys-abstraction.ts","../../../src/future.ts","../../../src/resolve-once.ts","../../../src/sys-env.ts","../../../src/node/node-sys-abstraction.ts","../../../src/node/deno-sys-abstraction.ts","../../../src/node/deno-file-service.ts","../../../src/node/mock-file-service.ts"],"sourcesContent":["export * from \"./node-file-service.js\";\nexport * from \"./node-sys-abstraction.js\";\nexport * from \"./deno-sys-abstraction.js\";\nexport * from \"./mock-file-service.js\";\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport process from \"node:process\";\nimport { FileService, NamedWritableStream } from \"../file-service.js\";\nimport { TxtEnDecoder, Utf8EnDecoderSingleton } from \"../txt-en-decoder.js\";\n\nexport class NodeFileService implements FileService {\n readonly baseDir: string;\n constructor(baseDir: string = process.cwd()) {\n this.baseDir = this.abs(baseDir);\n }\n\n // nodeImport(fname: string): string {\n // // console.log('nodeImport:'+ fname);\n // if (path.isAbsolute(fname)) {\n // return fname;\n // } else {\n // return \"./\" + path.normalize(fname);\n // }\n // }\n\n readFileString(fname: string): Promise<string> {\n return fs.promises.readFile(fname, { encoding: \"utf-8\" });\n }\n\n dirname(fname: string): string {\n return path.dirname(fname);\n }\n basename(fname: string): string {\n return path.basename(fname);\n }\n\n join(...paths: string[]): string {\n return path.join(...paths);\n }\n\n relative(from: string, to?: string): string {\n if (to === undefined) {\n to = from;\n from = process.cwd();\n }\n const ret = path.relative(from, to);\n // console.log('relative:'+ from + \" -> \" + to + \"= \" + ret);\n return ret;\n }\n\n abs(fname: string): string {\n if (path.isAbsolute(fname)) {\n return fname;\n } else {\n const cwd = process.cwd();\n return path.resolve(cwd, fname);\n }\n }\n\n isAbsolute(fname: string): boolean {\n return path.isAbsolute(fname);\n }\n\n async writeFileString(fname: string, content: string, ende: TxtEnDecoder = Utf8EnDecoderSingleton()): Promise<void> {\n const o = await this.create(fname);\n const wr = o.stream.getWriter();\n await wr.write(ende.encode(content));\n await wr.close();\n }\n\n async create(fname: string): Promise<NamedWritableStream> {\n let oName = fname;\n if (!path.isAbsolute(fname)) {\n oName = this.abs(fname);\n }\n\n const base = path.dirname(oName);\n await fs.promises.mkdir(base, { recursive: true });\n const out = fs.createWriteStream(oName);\n return {\n name: oName,\n stream: new WritableStream<Uint8Array>({\n write(chunk): void {\n out.write(chunk);\n },\n close(): void {\n out.close();\n },\n abort(): void {\n throw new Error(\"not implemented\");\n },\n }),\n };\n }\n}\n","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","export abstract class Time {\n abstract Now(add?: number): Date;\n abstract Sleep(duration: Duration): Promise<void>;\n TimeSince(start: Date): Duration {\n const now = this.Now();\n return now.getTime() - start.getTime();\n }\n}\n\nexport type Duration = number;\n\nexport enum TimeUnits {\n Microsecond = 1,\n // eslint-disable-next-line @typescript-eslint/prefer-literal-enum-member\n Second = 1000 * Microsecond,\n // eslint-disable-next-line @typescript-eslint/prefer-literal-enum-member\n Minute = 60 * Second,\n // eslint-disable-next-line @typescript-eslint/prefer-literal-enum-member\n Hour = 60 * Minute,\n}\n","import { FileService } from \"./file-service.js\";\nimport { TimeMode, RandomMode, IDMode, SystemService, VoidFunc, SysAbstraction } from \"./sys-abstraction.js\";\nimport { Time } from \"./time.js\";\nimport { TxtEnDecoder } from \"./txt-en-decoder.js\";\n\nexport class SysTime extends Time {\n Now(): Date {\n return new Date();\n }\n Sleep(duration: number): Promise<void> {\n return new Promise((resolve) => {\n setTimeout(() => {\n resolve();\n }, duration);\n });\n }\n}\n\nexport class ConstTime extends Time {\n Now(): Date {\n return new Date(2021, 1, 1, 0, 0, 0, 0);\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n Sleep(duration: number): Promise<void> {\n return Promise.resolve();\n }\n}\n\nexport class StepTime extends Time {\n _step: Date;\n readonly _start: Date;\n constructor() {\n super();\n this._step = new ConstTime().Now();\n this._start = this._step;\n }\n Now(steps = 1): Date {\n // if (this._step.getTime() === 0) {\n // this._step = new ConstTime().Now();\n // return this._step;\n // }\n for (let i = 0; steps > 0 && i < steps; i++) {\n this._step = new Date(this._step.getTime() + 1000);\n }\n if (steps < 1) {\n this._step = new Date(this._start.getTime() + steps * -1000);\n }\n // this._step = new Date(this._step.getTime() + 1000);\n return this._step;\n }\n Sleep(duration: number): Promise<void> {\n this._step = new Date(this._step.getTime() + duration);\n return Promise.resolve();\n }\n}\n\nexport function TimeFactory(timeMode: TimeMode): Time {\n switch (timeMode) {\n case TimeMode.REAL:\n return new SysTime();\n case TimeMode.CONST:\n return new ConstTime();\n case TimeMode.STEP:\n return new StepTime();\n }\n return new SysTime();\n}\n\nexport class RandomService {\n readonly _mode: RandomMode;\n _step = 0;\n constructor(mode: RandomMode) {\n this._mode = mode;\n }\n Random0ToValue(value: number): number {\n switch (this._mode) {\n case RandomMode.CONST:\n return 0.5 * value;\n case RandomMode.STEP:\n this._step += 0.0001;\n return this._step * value;\n case RandomMode.RANDOM:\n return Math.random() * value;\n default:\n throw new Error(\"Unknown RandomMode\");\n }\n }\n}\n\nexport class IdService {\n readonly _mode: IDMode;\n _step = 0;\n constructor(mode?: IDMode) {\n if (!mode) {\n mode = IDMode.UUID;\n }\n this._mode = mode;\n }\n NextId(): string {\n switch (this._mode) {\n case IDMode.UUID:\n return crypto.randomUUID();\n case IDMode.CONST:\n return \"VeryUniqueID\";\n case IDMode.STEP:\n return `STEPId-${this._step++}`;\n default:\n throw new Error(\"Unknown IDMode\");\n }\n }\n}\n\nexport interface BaseSysAbstractionParams {\n readonly TxtEnDecoder: TxtEnDecoder;\n readonly FileSystem: FileService;\n readonly SystemService: SystemService;\n}\n\nexport interface ExitHandler {\n readonly hdl: VoidFunc;\n readonly id: string;\n}\n\nexport interface ExitService {\n injectExitHandlers(hdls: ExitHandler[]): void;\n exit(code: number): void;\n}\n\nexport class BaseSysAbstraction {\n readonly _time: SysTime = new SysTime();\n readonly _stdout: WritableStream;\n readonly _stderr: WritableStream;\n\n readonly _idService: IdService = new IdService();\n readonly _randomService: RandomService = new RandomService(RandomMode.RANDOM);\n readonly _fileSystem: FileService;\n readonly _systemService: SystemService;\n readonly _txtEnDe: TxtEnDecoder;\n\n constructor(params: BaseSysAbstractionParams) {\n this._fileSystem = params.FileSystem;\n this._systemService = params.SystemService;\n this._txtEnDe = params.TxtEnDecoder;\n const decoder = this._txtEnDe;\n this._stdout = new WritableStream({\n write(chunk): Promise<void> {\n return new Promise((resolve) => {\n const decoded = decoder.decode(chunk);\n // eslint-disable-next-line no-console\n console.log(decoded.trimEnd());\n resolve();\n });\n },\n });\n this._stderr = new WritableStream({\n write(chunk): Promise<void> {\n return new Promise((resolve) => {\n const decoded = decoder.decode(chunk);\n // eslint-disable-next-line no-console\n console.error(decoded.trimEnd());\n resolve();\n });\n },\n });\n }\n}\n\nexport interface WrapperSysAbstractionParams {\n readonly TimeMode?: TimeMode;\n readonly IdMode?: IDMode;\n readonly Stdout?: WritableStream<Uint8Array>;\n readonly Stderr?: WritableStream<Uint8Array>;\n readonly RandomMode?: RandomMode;\n readonly FileSystem?: FileService;\n readonly SystemService?: SystemService;\n readonly TxtEnDecoder?: TxtEnDecoder;\n}\n\nexport class WrapperSysAbstraction implements SysAbstraction {\n readonly _time: Time;\n readonly _stdout: WritableStream<Uint8Array>;\n readonly _stderr: WritableStream<Uint8Array>;\n readonly _idService: IdService;\n readonly _randomService: RandomService;\n readonly _fileSystem: FileService;\n readonly _systemService: SystemService;\n constructor(base: BaseSysAbstraction, params?: WrapperSysAbstractionParams) {\n this._time = base._time;\n this._stdout = base._stdout;\n this._stderr = base._stderr;\n this._idService = base._idService;\n this._randomService = base._randomService;\n this._fileSystem = base._fileSystem;\n this._systemService = base._systemService;\n if (params) {\n if (params.TimeMode) {\n this._time = TimeFactory(params.TimeMode);\n }\n if (params.Stdout) {\n this._stdout = params.Stdout;\n }\n if (params.Stderr) {\n this._stderr = params.Stderr;\n }\n if (params.IdMode) {\n this._idService = new IdService(params.IdMode);\n }\n if (params.RandomMode) {\n this._randomService = new RandomService(params.RandomMode);\n }\n if (params.FileSystem) {\n this._fileSystem = params.FileSystem;\n }\n if (params.SystemService) {\n this._systemService = params.SystemService;\n }\n }\n }\n Time(): Time {\n return this._time;\n }\n NextId(): string {\n return this._idService.NextId();\n }\n Random0ToValue(value: number): number {\n return this._randomService.Random0ToValue(value);\n }\n Stdout(): WritableStream {\n return this._stdout;\n }\n Stderr(): WritableStream {\n return this._stderr;\n }\n\n System(): SystemService {\n return this._systemService;\n }\n FileSystem(): FileService {\n return this._fileSystem;\n }\n}\n// export const BaseSysAbstraction = new BaseSysAbstractionImpl()\n","export class Future<T> {\n readonly #promise: Promise<T>;\n #resolveFn: (value: T) => void = () => {\n throw new Error(\"This Promise is not working as expected.\");\n };\n #rejectFn: (reason: unknown) => void = () => {\n throw new Error(\"This Promise is not working as expected.\");\n };\n\n constructor() {\n this.#promise = new Promise<T>((resolve, reject) => {\n this.#resolveFn = resolve;\n this.#rejectFn = reject;\n });\n }\n\n async asPromise(): Promise<T> {\n return this.#promise;\n }\n\n resolve(value: T): void {\n this.#resolveFn(value);\n }\n reject(reason: unknown): void {\n this.#rejectFn(reason);\n }\n}\n","import { Future } from \"./future.js\";\n\ninterface ResolveSeqItem<T, C> {\n readonly future: Future<T>;\n readonly fn: (c: C) => Promise<T>;\n readonly id?: number;\n}\n\nexport class ResolveSeq<T, C = void> {\n readonly ctx: C;\n constructor(ctx?: C) {\n this.ctx = ctx as C;\n }\n reset(): void {\n /* noop */\n }\n async _step(item?: ResolveSeqItem<T, C> | undefined): Promise<void> {\n if (!item) {\n // done\n return;\n }\n item\n .fn(this.ctx)\n .then((value) => item.future.resolve(value))\n .catch((e) => item.future.reject(e as Error))\n .finally(() => {\n this._seqFutures.shift();\n this._step(this._seqFutures[0]);\n });\n }\n readonly _seqFutures: ResolveSeqItem<T, C>[] = [];\n async add(fn: (c: C) => Promise<T>, id?: number): Promise<T> {\n const future = new Future<T>();\n this._seqFutures.push({ future, fn, id });\n if (this._seqFutures.length === 1) {\n this._step(this._seqFutures[0]);\n }\n return future.asPromise();\n }\n}\n\nexport class ResolveOnce<T, CTX = void> {\n _onceDone = false;\n readonly _onceFutures: Future<T>[] = [];\n _onceOk = false;\n _onceValue?: T;\n _onceError?: Error;\n _isPromise = false;\n\n readonly ctx: CTX;\n\n constructor(ctx?: CTX) {\n this.ctx = ctx as CTX;\n }\n\n get ready(): boolean {\n return this._onceDone;\n }\n\n reset(): void {\n this._onceDone = false;\n this._onceOk = false;\n this._onceValue = undefined;\n this._onceError = undefined;\n this._onceFutures.length = 0;\n }\n\n // T extends Option<infer U> ? U : T\n once<R>(fn: (c: CTX) => R): R {\n if (this._onceDone) {\n if (this._onceError) {\n if (this._isPromise) {\n return Promise.reject(this._onceError) as unknown as R;\n } else {\n throw this._onceError;\n }\n }\n if (this._onceOk) {\n if (this._isPromise) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return Promise.resolve(this._onceValue!) as unknown as R;\n } else {\n return this._onceValue as unknown as R;\n }\n }\n throw new Error(\"ResolveOnce.once impossible\");\n }\n const future = new Future<T>();\n this._onceFutures.push(future);\n if (this._onceFutures.length === 1) {\n const okFn = (value: T): void => {\n this._onceValue = value;\n this._onceOk = true;\n this._onceDone = true;\n if (this._isPromise) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this._onceFutures.forEach((f) => f.resolve(this._onceValue!));\n }\n this._onceFutures.length = 0;\n };\n const catchFn = (e: Error): void => {\n this._onceError = e as Error;\n this._onceOk = false;\n this._onceValue = undefined;\n this._onceDone = true;\n if (this._isPromise) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this._onceFutures.forEach((f) => f.reject(this._onceError!));\n }\n this._onceFutures.length = 0;\n };\n try {\n const ret = fn(this.ctx);\n if (typeof (ret as Promise<T>).then === \"function\") {\n this._isPromise = true;\n (ret as Promise<T>).then(okFn).catch(catchFn);\n } else {\n okFn(ret as unknown as T);\n }\n } catch (e) {\n catchFn(e as Error);\n }\n }\n if (this._isPromise) {\n return future.asPromise() as unknown as R;\n } else {\n // abit funky but i don't want to impl the return just once\n return this.once(fn);\n }\n }\n}\n\nexport class Keyed<T extends { reset: () => void }, K = string> {\n private readonly _map = new Map<K, T>();\n\n readonly factory: (key: K) => T;\n constructor(factory: (key: K) => T) {\n this.factory = factory;\n }\n\n async asyncGet(key: () => Promise<K>): Promise<T> {\n return this.get(await key());\n }\n\n get(key: K | (() => K)): T {\n if (typeof key === \"function\") {\n key = (key as () => K)();\n }\n let keyed = this._map.get(key);\n if (!keyed) {\n keyed = this.factory(key);\n this._map.set(key, keyed);\n }\n return keyed;\n }\n\n unget(key: K): void {\n const keyed = this._map.get(key);\n keyed?.reset();\n this._map.delete(key);\n }\n\n reset(): void {\n this._map.forEach((keyed) => keyed.reset());\n this._map.clear();\n }\n}\n\nexport class KeyedResolvOnce<T, K = string> extends Keyed<ResolveOnce<T, K>, K> {\n constructor() {\n super((key) => new ResolveOnce<T, K>(key));\n }\n}\n\nexport class KeyedResolvSeq<T, K = string> extends Keyed<ResolveSeq<T, K>, K> {\n constructor() {\n super((key) => new ResolveSeq<T, K>(key));\n }\n}\n","import { ResolveOnce } from \"./resolve-once.js\";\n\nexport interface EnvMap {\n get(key: string): string | undefined;\n set(key: string, value?: string): void;\n delete(key: string): void;\n keys(): string[];\n}\nexport interface EnvActions extends EnvMap {\n active(): boolean;\n register(env: Env): Env;\n}\n\nclass NodeEnvActions implements EnvActions {\n readonly #node = globalThis as unknown as { process: { env: Record<string, string> } };\n\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor, @typescript-eslint/no-unused-vars\n constructor(opts: Partial<EnvFactoryOpts>) {\n // do nothing\n }\n\n register(env: Env): Env {\n return env;\n }\n\n active(): boolean {\n return typeof this.#node === \"object\" && typeof this.#node.process === \"object\" && typeof this.#node.process.env === \"object\";\n }\n readonly _env = this.active() ? this.#node.process.env : {};\n keys(): string[] {\n return Object.keys(this._env);\n }\n get(key: string): string | undefined {\n return this._env[key];\n }\n set(key: string, value?: string): void {\n if (value) {\n this._env[key] = value;\n }\n }\n delete(key: string): void {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._env[key];\n }\n}\n\nclass DenoEnvActions implements EnvActions {\n readonly #deno = globalThis as unknown as { Deno: { env: Map<string, string> } };\n\n get _env(): Map<string, string> {\n return this.#deno.Deno.env;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor, @typescript-eslint/no-unused-vars\n constructor(opts: Partial<EnvFactoryOpts>) {\n // do nothing\n }\n\n register(env: Env): Env {\n return env;\n }\n active(): boolean {\n return typeof this.#deno === \"object\" && typeof this.#deno.Deno === \"object\" && typeof this.#deno.Deno.env === \"object\";\n }\n keys(): string[] {\n return Array.from(this._env.keys());\n }\n get(key: string): string | undefined {\n return this._env.get(key);\n }\n set(key: string, value?: string): void {\n if (value) {\n this._env.set(key, value);\n }\n }\n delete(key: string): void {\n this._env.delete(key);\n }\n}\n\nexport class BrowserEnvActions implements EnvActions {\n readonly env: Map<string, string> = new Map<string, string>();\n readonly opts: Partial<EnvFactoryOpts>;\n constructor(opts: Partial<EnvFactoryOpts>) {\n this.opts = opts;\n }\n\n get(key: string): string | undefined {\n return this.env.get(key);\n }\n set(key: string, value?: string): void {\n if (value) {\n this.env.set(key, value);\n }\n }\n delete(key: string): void {\n this.env.delete(key);\n }\n keys(): string[] {\n return Array.from(this.env.keys());\n }\n active(): boolean {\n return true; // that should work on every runtime\n }\n\n register(env: Env): Env {\n const sym = Symbol.for(this.opts.symbol || \"CP_ENV\");\n const browser = globalThis as unknown as Record<symbol, Env>;\n browser[sym] = env;\n return env;\n }\n}\n\nexport interface EnvFactoryOpts {\n readonly symbol: string; // default \"CP_ENV\" used by BrowserEnvActions\n readonly presetEnv: Map<string, string>;\n}\n\ntype OnSetFn = (key: string, value?: string) => void;\nexport interface OnSetItem {\n readonly filter: Set<string>;\n readonly fn: OnSetFn;\n}\n\nexport interface Env extends EnvMap {\n onSet(fn: OnSetFn, ...filter: string[]): void;\n}\n\nconst _envFactory = new ResolveOnce<Env>();\nexport function envFactory(opts: Partial<EnvFactoryOpts> = {}): Env {\n return _envFactory.once(() => {\n const found = [new NodeEnvActions(opts), new DenoEnvActions(opts), new BrowserEnvActions(opts)].find((env) => env.active());\n if (!found) {\n throw new Error(\"SysContainer:envFactory: no env available\");\n }\n const ret = new EnvImpl(found, opts);\n found.register(ret);\n return ret;\n });\n}\n\nexport class EnvImpl implements Env {\n readonly _map: EnvMap;\n constructor(map: EnvMap, opts: Partial<EnvFactoryOpts> = {}) {\n this._map = map;\n this._updatePresets(opts.presetEnv);\n }\n _updatePresets(presetEnv?: Map<string, string>): void {\n if (!presetEnv) {\n return;\n }\n for (const [key, value] of presetEnv) {\n this._map.set(key, value);\n }\n }\n _applyOnSet(onSet: OnSetItem[], key?: string, value?: string): void {\n onSet.forEach((item) => {\n let keys: string[] = [];\n if (key) {\n keys = [key];\n } else {\n keys = this._map.keys();\n }\n keys\n .filter((k) => {\n if (item.filter.size === 0) {\n return true;\n }\n if (item.filter.has(k)) {\n return true;\n }\n return false;\n })\n .forEach((k) => {\n let v;\n if (!key && !value) {\n // init\n v = this._map.get(k);\n } else if (key && !value) {\n // del\n v = undefined;\n } else {\n // set\n v = value;\n }\n item.fn(k, v);\n });\n });\n }\n readonly _onSet: OnSetItem[] = [];\n keys(): string[] {\n return this._map.keys();\n }\n // filter is not set all sets passed\n onSet(fn: OnSetFn, ...filter: string[]): void {\n const item: OnSetItem = { filter: new Set(filter), fn };\n this._onSet.push(item);\n this._applyOnSet([item]);\n }\n get(key: string): string | undefined {\n return this._map.get(key);\n }\n set(key: string, value?: string): void {\n if (!value) {\n return;\n }\n this._map.set(key, value);\n this._applyOnSet(this._onSet, key, value);\n }\n delete(key: string): void {\n this._map.delete(key);\n this._applyOnSet(this._onSet, key);\n }\n}\n\n// export const envImpl = new EnvImpl();\n","import { SysAbstraction, SystemService, VoidFunc } from \"../sys-abstraction.js\";\nimport {\n BaseSysAbstraction,\n ExitHandler,\n ExitService,\n WrapperSysAbstraction,\n WrapperSysAbstractionParams,\n} from \"../base-sys-abstraction.js\";\nimport { NodeFileService } from \"./node-file-service.js\";\nimport { Env, envFactory } from \"../sys-env.js\";\nimport { Utf8EnDecoderSingleton } from \"../txt-en-decoder.js\";\nimport process from \"node:process\";\n\nexport class NodeExitServiceImpl implements ExitService {\n constructor() {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n process.on(\"unhandledRejection\", (reason: string, p: Promise<unknown>) => {\n this.exit(19);\n });\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n process.on(\"uncaughtException\", (error: Error) => {\n this.exit(18);\n });\n process.on(\"close\", () => {\n this.exit(0);\n });\n process.on(\"exit\", () => {\n this.exit(0);\n });\n process.on(\"SIGQUIT\", () => {\n this.exit(3);\n });\n process.on(\"SIGINT\", () => {\n this.exit(2);\n });\n process.on(\"SIGTERM\", () => {\n this.exit(9);\n });\n }\n _exitHandlers: ExitHandler[] = [];\n injectExitHandlers(hdls: ExitHandler[]): void {\n // console.log(\"ExitService: injecting exit handlers\", hdls)\n this._exitHandlers = hdls;\n }\n invoked = false;\n readonly _handleExit = async (): Promise<void> => {\n if (this.invoked) {\n // console.error(\"ExitService: already invoked\");\n return;\n }\n this.invoked = true;\n for (const h of this._exitHandlers) {\n try {\n // console.log(`ExitService: calling handler ${h.id}`)\n const ret = h.hdl();\n // console.log(`ExitService: called handler ${h.id}`, ret)\n if (typeof (ret as Promise<void>).then === \"function\") {\n await ret;\n }\n } finally {\n // ignore\n }\n }\n };\n\n exit(code: number): void {\n // console.log(\"ExitService: exit called\", code)\n this._handleExit()\n .then(() => {\n process.exit(code);\n })\n .catch((err) => {\n // eslint-disable-next-line no-console\n console.error(\"ExitService: failed to handle exit\", err);\n process.exit(code);\n });\n }\n}\n\nexport class NodeSystemService implements SystemService {\n static readonly _exitHandlers: ExitHandler[] = [];\n readonly _exitService: ExitService = new NodeExitServiceImpl();\n constructor() {\n this._exitService.injectExitHandlers(NodeSystemService._exitHandlers);\n }\n\n Env(): Env {\n return envFactory();\n }\n\n Args(): string[] {\n return process.argv;\n }\n\n OnExit(hdl: VoidFunc): VoidFunc {\n const id = crypto.randomUUID();\n NodeSystemService._exitHandlers.push({ hdl, id });\n return () => {\n const idx = NodeSystemService._exitHandlers.findIndex((h) => h.id === id);\n if (idx >= 0) {\n NodeSystemService._exitHandlers.splice(idx, 1);\n }\n };\n }\n\n Exit(code: number): void {\n this._exitService.exit(code);\n }\n}\n\nlet my: BaseSysAbstraction | undefined = undefined;\nexport function NodeSysAbstraction(param?: WrapperSysAbstractionParams): SysAbstraction {\n if (!my) {\n my = new BaseSysAbstraction({\n TxtEnDecoder: param?.TxtEnDecoder || Utf8EnDecoderSingleton(),\n FileSystem: new NodeFileService(),\n SystemService: new NodeSystemService(),\n });\n }\n return new WrapperSysAbstraction(my, param);\n}\n","import { SysAbstraction, SystemService, VoidFunc } from \"../sys-abstraction.js\";\nimport {\n BaseSysAbstraction,\n ExitHandler,\n ExitService,\n WrapperSysAbstraction,\n WrapperSysAbstractionParams,\n} from \"../base-sys-abstraction.js\";\nimport { Env, envFactory } from \"../sys-env.js\";\nimport { Utf8EnDecoderSingleton } from \"../txt-en-decoder.js\";\nimport * as process from \"node:process\";\nimport { DenoFileService } from \"./deno-file-service.js\";\n\nconst Deno = (globalThis as unknown as { Deno: unknown }).Deno as {\n addSignalListener(sig: string, hdl: () => void): void;\n exit(code?: number): void;\n};\n\nexport class DenoExitServiceImpl implements ExitService {\n constructor() {\n globalThis.addEventListener(\"unhandledrejection\", (e) => {\n e.preventDefault();\n this.exit(19);\n });\n globalThis.addEventListener(\"error\", () => {\n this.exit(19);\n });\n globalThis.addEventListener(\"uncaughtException\", () => {\n this.exit(19);\n });\n\n // process.on(\"close\", () => {\n // this.exit(0);\n // });\n globalThis.addEventListener(\"unload\", () => {\n this.exit(0);\n // console.log('goodbye!');\n });\n\n // process.on(\"exit\", () => {\n // });\n Deno.addSignalListener(\"SIGQUIT\", () => {\n this.exit(3);\n });\n Deno.addSignalListener(\"SIGINT\", () => {\n this.exit(2);\n });\n Deno.addSignalListener(\"SIGTERM\", () => {\n this.exit(9);\n });\n }\n _exitHandlers: ExitHandler[] = [];\n injectExitHandlers(hdls: ExitHandler[]): void {\n // console.log(\"ExitService: injecting exit handlers\", hdls)\n this._exitHandlers = hdls;\n }\n invoked = false;\n readonly _handleExit = async (): Promise<void> => {\n if (this.invoked) {\n // console.error(\"ExitService: already invoked\");\n return;\n }\n this.invoked = true;\n for (const h of this._exitHandlers) {\n try {\n // console.log(`ExitService: calling handler ${h.id}`)\n const ret = h.hdl();\n // console.log(`ExitService: called handler ${h.id}`, ret)\n if (typeof (ret as Promise<void>).then === \"function\") {\n await ret;\n }\n } finally {\n // ignore\n }\n }\n };\n\n exit(code: number): void {\n // console.log(\"ExitService: exit called\", code)\n this._handleExit()\n .then(() => {\n Deno.exit(code);\n })\n .catch((err) => {\n // eslint-disable-next-line no-console\n console.error(\"ExitService: failed to handle exit\", err);\n Deno.exit(code);\n });\n }\n}\n\nexport class DenoSystemService implements SystemService {\n static readonly _exitHandlers: ExitHandler[] = [];\n readonly _exitService: ExitService = new DenoExitServiceImpl();\n constructor() {\n this._exitService.injectExitHandlers(DenoSystemService._exitHandlers);\n }\n\n Env(): Env {\n return envFactory();\n }\n\n Args(): string[] {\n return process.argv;\n }\n\n OnExit(hdl: VoidFunc): VoidFunc {\n const id = crypto.randomUUID();\n DenoSystemService._exitHandlers.push({ hdl, id });\n return () => {\n const idx = DenoSystemService._exitHandlers.findIndex((h) => h.id === id);\n if (idx >= 0) {\n DenoSystemService._exitHandlers.splice(idx, 1);\n }\n };\n }\n\n Exit(code: number): void {\n this._exitService.exit(code);\n }\n}\n\nlet my: BaseSysAbstraction | undefined = undefined;\nexport function DenoSysAbstraction(param?: WrapperSysAbstractionParams): SysAbstraction {\n if (!my) {\n my = new BaseSysAbstraction({\n TxtEnDecoder: param?.TxtEnDecoder || Utf8EnDecoderSingleton(),\n FileSystem: new DenoFileService(),\n SystemService: new DenoSystemService(),\n });\n }\n return new WrapperSysAbstraction(my, param);\n}\n","import { FileService, NamedWritableStream } from \"../file-service.js\";\nimport { TxtEnDecoder, Utf8EnDecoderSingleton } from \"../txt-en-decoder.js\";\nimport * as path from \"node:path\";\n\nconst Deno = (globalThis as unknown as { Deno: unknown }).Deno as {\n cwd(): string;\n readFile(fname: string): Promise<Uint8Array>;\n mkdir(base: string, options: { recursive: boolean }): Promise<void>;\n open(fname: string, options: { write: boolean; create: boolean; truncate: boolean }): Promise<WritableStream>;\n};\n\nexport class DenoFileService implements FileService {\n readonly baseDir: string;\n readonly txtEnde: TxtEnDecoder;\n constructor(baseDir: string = Deno.cwd(), txtEnde: TxtEnDecoder = Utf8EnDecoderSingleton()) {\n this.baseDir = this.abs(baseDir);\n this.txtEnde = txtEnde;\n }\n\n // nodeImport(fname: string): string {\n // // console.log('nodeImport:'+ fname);\n // if (path.isAbsolute(fname)) {\n // return fname;\n // } else {\n // return \"./\" + path.normalize(fname);\n // }\n // }\n\n async readFileString(fname: string): Promise<string> {\n return this.txtEnde.decode(await Deno.readFile(fname));\n }\n\n dirname(fname: string): string {\n return path.dirname(fname);\n }\n basename(fname: string): string {\n return path.basename(fname);\n }\n\n join(...paths: string[]): string {\n return path.join(...paths);\n }\n\n relative(from: string, to?: string): string {\n if (to === undefined) {\n to = from;\n from = Deno.cwd();\n }\n const ret = path.relative(from, to);\n // console.log('relative:'+ from + \" -> \" + to + \"= \" + ret);\n return ret;\n }\n\n abs(fname: string): string {\n if (path.isAbsolute(fname)) {\n return fname;\n } else {\n const cwd = Deno.cwd();\n return path.resolve(cwd, fname);\n }\n }\n\n isAbsolute(fname: string): boolean {\n return path.isAbsolute(fname);\n }\n\n async writeFileString(fname: string, content: string, ende = Utf8EnDecoderSingleton()): Promise<void> {\n const o = await this.create(fname);\n const wr = o.stream.getWriter();\n await wr.write(ende.encode(content));\n await wr.close();\n }\n\n async create(fname: string): Promise<NamedWritableStream> {\n let oName = fname;\n if (!path.isAbsolute(fname)) {\n oName = this.abs(fname);\n }\n\n const base = path.dirname(oName);\n await Deno.mkdir(base, { recursive: true });\n const out = await Deno.open(oName, {\n write: true,\n create: true,\n truncate: true,\n });\n return {\n name: oName,\n stream: out,\n };\n }\n}\n","import { NamedWritableStream } from \"../file-service.js\";\nimport { NodeFileService } from \"./node-file-service.js\";\n\nexport interface FileCollector {\n readonly name: string;\n content: string;\n}\n\nexport class MockFileService extends NodeFileService {\n readonly files = {} as Record<string, FileCollector>;\n\n // override abs(fname: string): string {\n // return this.join(\"/mock/\", fname);\n // }\n\n override async create(fname: string): Promise<NamedWritableStream> {\n let oName = fname;\n if (!this.isAbsolute(fname)) {\n oName = await this.abs(fname);\n }\n\n const fc = {\n name: oName,\n content: \"\",\n };\n this.files[oName] = fc;\n this.files[fname] = fc;\n const decoder = new TextDecoder();\n\n return {\n name: oName,\n stream: new WritableStream<Uint8Array>({\n write(chunk): void {\n fc.content = fc.content + decoder.decode(chunk);\n },\n close(): void {\n // do nothing\n },\n abort(): void {\n throw new Error(\"not implemented\");\n },\n }),\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,uBAAiB;AACjB,qBAAe;AACf,0BAAoB;;;ACGpB,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;;;ADdO,IAAM,kBAAN,MAA6C;AAAA,EAElD,YAAY,UAAkB,oBAAAA,QAAQ,IAAI,GAAG;AAC3C,SAAK,UAAU,KAAK,IAAI,OAAO;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,eAAe,OAAgC;AAC7C,WAAO,eAAAC,QAAG,SAAS,SAAS,OAAO,EAAE,UAAU,QAAQ,CAAC;AAAA,EAC1D;AAAA,EAEA,QAAQ,OAAuB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BACK,gBAA+B,CAAC;AAD3C,IAAM,oBAAN;AA+BP,IAAIC,MAAqC;AAClC,SAAS,mBAAmB,OAAqD;AACtF,MAAI,CAACA,KAAI;AACP,IAAAA,MAAK,IAAI,mBAAmB;AAAA,MAC1B,eAAc,+BAAO,iBAAgB,uBAAuB;AAAA,MAC5D,YAAY,IAAI,gBAAgB;AAAA,MAChC,eAAe,IAAI,kBAAkB;AAAA,IACvC,CAAC;AAAA,EACH;AACA,SAAO,IAAI,sBAAsBA,KAAI,KAAK;AAC5C;;;AE5HO,IAAM,kBAAN,cAA8B,gBAAgB;AAAA,EAA9C;AAAA;AACL,SAAS,QAAQ,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMlB,MAAe,OAAO,OAA6C;AACjE,QAAI,QAAQ;AACZ,QAAI,CAAC,KAAK,WAAW,KAAK,GAAG;AAC3B,cAAQ,MAAM,KAAK,IAAI,KAAK;AAAA,IAC9B;AAEA,UAAM,KAAK;AAAA,MACT,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AACA,SAAK,MAAM,KAAK,IAAI;AACpB,SAAK,MAAM,KAAK,IAAI;AACpB,UAAMC,WAAU,IAAI,YAAY;AAEhC,WAAO;AAAA,MACL,MAAM;AAAA,MACN,QAAQ,IAAI,eAA2B;AAAA,QACrC,MAAM,OAAa;AACjB,aAAG,UAAU,GAAG,UAAUA,SAAQ,OAAO,KAAK;AAAA,QAChD;AAAA,QACA,QAAc;AAAA,QAEd;AAAA,QACA,QAAc;AACZ,gBAAM,IAAI,MAAM,iBAAiB;AAAA,QACnC;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":["process","fs","path","resolve","decoder","resolve","import_node_process","process","process","path","Deno","my","decoder"]}
|