@adviser/cement 0.0.0-jsr-t1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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
package/node/index.cjs
ADDED
@@ -0,0 +1,924 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __typeError = (msg) => {
|
9
|
+
throw TypeError(msg);
|
10
|
+
};
|
11
|
+
var __export = (target, all) => {
|
12
|
+
for (var name in all)
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
14
|
+
};
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
17
|
+
for (let key of __getOwnPropNames(from))
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
20
|
+
}
|
21
|
+
return to;
|
22
|
+
};
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
29
|
+
mod
|
30
|
+
));
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
32
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
33
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
34
|
+
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);
|
35
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
36
|
+
|
37
|
+
// src/node/index.ts
|
38
|
+
var node_exports = {};
|
39
|
+
__export(node_exports, {
|
40
|
+
DenoExitServiceImpl: () => DenoExitServiceImpl,
|
41
|
+
DenoSysAbstraction: () => DenoSysAbstraction,
|
42
|
+
DenoSystemService: () => DenoSystemService,
|
43
|
+
MockFileService: () => MockFileService,
|
44
|
+
NodeExitServiceImpl: () => NodeExitServiceImpl,
|
45
|
+
NodeFileService: () => NodeFileService,
|
46
|
+
NodeSysAbstraction: () => NodeSysAbstraction,
|
47
|
+
NodeSystemService: () => NodeSystemService
|
48
|
+
});
|
49
|
+
module.exports = __toCommonJS(node_exports);
|
50
|
+
|
51
|
+
// src/node/node-file-service.ts
|
52
|
+
var import_node_path = __toESM(require("path"), 1);
|
53
|
+
var import_node_fs = __toESM(require("fs"), 1);
|
54
|
+
var import_node_process = __toESM(require("process"), 1);
|
55
|
+
|
56
|
+
// src/txt-en-decoder.ts
|
57
|
+
var encoder = new TextEncoder();
|
58
|
+
var decoder = new TextDecoder();
|
59
|
+
var Utf8EnDecoder = class {
|
60
|
+
encode(str) {
|
61
|
+
return encoder.encode(str);
|
62
|
+
}
|
63
|
+
decode(data) {
|
64
|
+
return decoder.decode(data);
|
65
|
+
}
|
66
|
+
};
|
67
|
+
var utf8EnDecoder = new Utf8EnDecoder();
|
68
|
+
function Utf8EnDecoderSingleton() {
|
69
|
+
return utf8EnDecoder;
|
70
|
+
}
|
71
|
+
|
72
|
+
// src/node/node-file-service.ts
|
73
|
+
var NodeFileService = class {
|
74
|
+
constructor(baseDir = import_node_process.default.cwd()) {
|
75
|
+
this.baseDir = this.abs(baseDir);
|
76
|
+
}
|
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
|
+
// }
|
85
|
+
readFileString(fname) {
|
86
|
+
return import_node_fs.default.promises.readFile(fname, { encoding: "utf-8" });
|
87
|
+
}
|
88
|
+
dirname(fname) {
|
89
|
+
return import_node_path.default.dirname(fname);
|
90
|
+
}
|
91
|
+
basename(fname) {
|
92
|
+
return import_node_path.default.basename(fname);
|
93
|
+
}
|
94
|
+
join(...paths) {
|
95
|
+
return import_node_path.default.join(...paths);
|
96
|
+
}
|
97
|
+
relative(from, to) {
|
98
|
+
if (to === void 0) {
|
99
|
+
to = from;
|
100
|
+
from = import_node_process.default.cwd();
|
101
|
+
}
|
102
|
+
const ret = import_node_path.default.relative(from, to);
|
103
|
+
return ret;
|
104
|
+
}
|
105
|
+
abs(fname) {
|
106
|
+
if (import_node_path.default.isAbsolute(fname)) {
|
107
|
+
return fname;
|
108
|
+
} else {
|
109
|
+
const cwd = import_node_process.default.cwd();
|
110
|
+
return import_node_path.default.resolve(cwd, fname);
|
111
|
+
}
|
112
|
+
}
|
113
|
+
isAbsolute(fname) {
|
114
|
+
return import_node_path.default.isAbsolute(fname);
|
115
|
+
}
|
116
|
+
async writeFileString(fname, content, ende = Utf8EnDecoderSingleton()) {
|
117
|
+
const o = await this.create(fname);
|
118
|
+
const wr = o.stream.getWriter();
|
119
|
+
await wr.write(ende.encode(content));
|
120
|
+
await wr.close();
|
121
|
+
}
|
122
|
+
async create(fname) {
|
123
|
+
let oName = fname;
|
124
|
+
if (!import_node_path.default.isAbsolute(fname)) {
|
125
|
+
oName = this.abs(fname);
|
126
|
+
}
|
127
|
+
const base = import_node_path.default.dirname(oName);
|
128
|
+
await import_node_fs.default.promises.mkdir(base, { recursive: true });
|
129
|
+
const out = import_node_fs.default.createWriteStream(oName);
|
130
|
+
return {
|
131
|
+
name: oName,
|
132
|
+
stream: new WritableStream({
|
133
|
+
write(chunk) {
|
134
|
+
out.write(chunk);
|
135
|
+
},
|
136
|
+
close() {
|
137
|
+
out.close();
|
138
|
+
},
|
139
|
+
abort() {
|
140
|
+
throw new Error("not implemented");
|
141
|
+
}
|
142
|
+
})
|
143
|
+
};
|
144
|
+
}
|
145
|
+
};
|
146
|
+
|
147
|
+
// src/time.ts
|
148
|
+
var Time = class {
|
149
|
+
TimeSince(start) {
|
150
|
+
const now = this.Now();
|
151
|
+
return now.getTime() - start.getTime();
|
152
|
+
}
|
153
|
+
};
|
154
|
+
|
155
|
+
// src/base-sys-abstraction.ts
|
156
|
+
var SysTime = class extends Time {
|
157
|
+
Now() {
|
158
|
+
return /* @__PURE__ */ new Date();
|
159
|
+
}
|
160
|
+
Sleep(duration) {
|
161
|
+
return new Promise((resolve2) => {
|
162
|
+
setTimeout(() => {
|
163
|
+
resolve2();
|
164
|
+
}, duration);
|
165
|
+
});
|
166
|
+
}
|
167
|
+
};
|
168
|
+
var ConstTime = class extends Time {
|
169
|
+
Now() {
|
170
|
+
return new Date(2021, 1, 1, 0, 0, 0, 0);
|
171
|
+
}
|
172
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
173
|
+
Sleep(duration) {
|
174
|
+
return Promise.resolve();
|
175
|
+
}
|
176
|
+
};
|
177
|
+
var StepTime = class extends Time {
|
178
|
+
constructor() {
|
179
|
+
super();
|
180
|
+
this._step = new ConstTime().Now();
|
181
|
+
this._start = this._step;
|
182
|
+
}
|
183
|
+
Now(steps = 1) {
|
184
|
+
for (let i = 0; steps > 0 && i < steps; i++) {
|
185
|
+
this._step = new Date(this._step.getTime() + 1e3);
|
186
|
+
}
|
187
|
+
if (steps < 1) {
|
188
|
+
this._step = new Date(this._start.getTime() + steps * -1e3);
|
189
|
+
}
|
190
|
+
return this._step;
|
191
|
+
}
|
192
|
+
Sleep(duration) {
|
193
|
+
this._step = new Date(this._step.getTime() + duration);
|
194
|
+
return Promise.resolve();
|
195
|
+
}
|
196
|
+
};
|
197
|
+
function TimeFactory(timeMode) {
|
198
|
+
switch (timeMode) {
|
199
|
+
case "real" /* REAL */:
|
200
|
+
return new SysTime();
|
201
|
+
case "const" /* CONST */:
|
202
|
+
return new ConstTime();
|
203
|
+
case "step" /* STEP */:
|
204
|
+
return new StepTime();
|
205
|
+
}
|
206
|
+
return new SysTime();
|
207
|
+
}
|
208
|
+
var RandomService = class {
|
209
|
+
constructor(mode) {
|
210
|
+
this._step = 0;
|
211
|
+
this._mode = mode;
|
212
|
+
}
|
213
|
+
Random0ToValue(value) {
|
214
|
+
switch (this._mode) {
|
215
|
+
case "const" /* CONST */:
|
216
|
+
return 0.5 * value;
|
217
|
+
case "step" /* STEP */:
|
218
|
+
this._step += 1e-4;
|
219
|
+
return this._step * value;
|
220
|
+
case "random" /* RANDOM */:
|
221
|
+
return Math.random() * value;
|
222
|
+
default:
|
223
|
+
throw new Error("Unknown RandomMode");
|
224
|
+
}
|
225
|
+
}
|
226
|
+
};
|
227
|
+
var IdService = class {
|
228
|
+
constructor(mode) {
|
229
|
+
this._step = 0;
|
230
|
+
if (!mode) {
|
231
|
+
mode = "uuid" /* UUID */;
|
232
|
+
}
|
233
|
+
this._mode = mode;
|
234
|
+
}
|
235
|
+
NextId() {
|
236
|
+
switch (this._mode) {
|
237
|
+
case "uuid" /* UUID */:
|
238
|
+
return crypto.randomUUID();
|
239
|
+
case "const" /* CONST */:
|
240
|
+
return "VeryUniqueID";
|
241
|
+
case "step" /* STEP */:
|
242
|
+
return `STEPId-${this._step++}`;
|
243
|
+
default:
|
244
|
+
throw new Error("Unknown IDMode");
|
245
|
+
}
|
246
|
+
}
|
247
|
+
};
|
248
|
+
var BaseSysAbstraction = class {
|
249
|
+
constructor(params) {
|
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;
|
257
|
+
this._stdout = new WritableStream({
|
258
|
+
write(chunk) {
|
259
|
+
return new Promise((resolve2) => {
|
260
|
+
const decoded = decoder2.decode(chunk);
|
261
|
+
console.log(decoded.trimEnd());
|
262
|
+
resolve2();
|
263
|
+
});
|
264
|
+
}
|
265
|
+
});
|
266
|
+
this._stderr = new WritableStream({
|
267
|
+
write(chunk) {
|
268
|
+
return new Promise((resolve2) => {
|
269
|
+
const decoded = decoder2.decode(chunk);
|
270
|
+
console.error(decoded.trimEnd());
|
271
|
+
resolve2();
|
272
|
+
});
|
273
|
+
}
|
274
|
+
});
|
275
|
+
}
|
276
|
+
};
|
277
|
+
var WrapperSysAbstraction = class {
|
278
|
+
constructor(base, params) {
|
279
|
+
this._time = base._time;
|
280
|
+
this._stdout = base._stdout;
|
281
|
+
this._stderr = base._stderr;
|
282
|
+
this._idService = base._idService;
|
283
|
+
this._randomService = base._randomService;
|
284
|
+
this._fileSystem = base._fileSystem;
|
285
|
+
this._systemService = base._systemService;
|
286
|
+
if (params) {
|
287
|
+
if (params.TimeMode) {
|
288
|
+
this._time = TimeFactory(params.TimeMode);
|
289
|
+
}
|
290
|
+
if (params.Stdout) {
|
291
|
+
this._stdout = params.Stdout;
|
292
|
+
}
|
293
|
+
if (params.Stderr) {
|
294
|
+
this._stderr = params.Stderr;
|
295
|
+
}
|
296
|
+
if (params.IdMode) {
|
297
|
+
this._idService = new IdService(params.IdMode);
|
298
|
+
}
|
299
|
+
if (params.RandomMode) {
|
300
|
+
this._randomService = new RandomService(params.RandomMode);
|
301
|
+
}
|
302
|
+
if (params.FileSystem) {
|
303
|
+
this._fileSystem = params.FileSystem;
|
304
|
+
}
|
305
|
+
if (params.SystemService) {
|
306
|
+
this._systemService = params.SystemService;
|
307
|
+
}
|
308
|
+
}
|
309
|
+
}
|
310
|
+
Time() {
|
311
|
+
return this._time;
|
312
|
+
}
|
313
|
+
NextId() {
|
314
|
+
return this._idService.NextId();
|
315
|
+
}
|
316
|
+
Random0ToValue(value) {
|
317
|
+
return this._randomService.Random0ToValue(value);
|
318
|
+
}
|
319
|
+
Stdout() {
|
320
|
+
return this._stdout;
|
321
|
+
}
|
322
|
+
Stderr() {
|
323
|
+
return this._stderr;
|
324
|
+
}
|
325
|
+
System() {
|
326
|
+
return this._systemService;
|
327
|
+
}
|
328
|
+
FileSystem() {
|
329
|
+
return this._fileSystem;
|
330
|
+
}
|
331
|
+
};
|
332
|
+
|
333
|
+
// src/future.ts
|
334
|
+
var _promise, _resolveFn, _rejectFn;
|
335
|
+
var Future = class {
|
336
|
+
constructor() {
|
337
|
+
__privateAdd(this, _promise);
|
338
|
+
__privateAdd(this, _resolveFn, () => {
|
339
|
+
throw new Error("This Promise is not working as expected.");
|
340
|
+
});
|
341
|
+
__privateAdd(this, _rejectFn, () => {
|
342
|
+
throw new Error("This Promise is not working as expected.");
|
343
|
+
});
|
344
|
+
__privateSet(this, _promise, new Promise((resolve2, reject) => {
|
345
|
+
__privateSet(this, _resolveFn, resolve2);
|
346
|
+
__privateSet(this, _rejectFn, reject);
|
347
|
+
}));
|
348
|
+
}
|
349
|
+
async asPromise() {
|
350
|
+
return __privateGet(this, _promise);
|
351
|
+
}
|
352
|
+
resolve(value) {
|
353
|
+
__privateGet(this, _resolveFn).call(this, value);
|
354
|
+
}
|
355
|
+
reject(reason) {
|
356
|
+
__privateGet(this, _rejectFn).call(this, reason);
|
357
|
+
}
|
358
|
+
};
|
359
|
+
_promise = new WeakMap();
|
360
|
+
_resolveFn = new WeakMap();
|
361
|
+
_rejectFn = new WeakMap();
|
362
|
+
|
363
|
+
// src/resolve-once.ts
|
364
|
+
var ResolveOnce = class {
|
365
|
+
constructor(ctx) {
|
366
|
+
this._onceDone = false;
|
367
|
+
this._onceFutures = [];
|
368
|
+
this._onceOk = false;
|
369
|
+
this._isPromise = false;
|
370
|
+
this.ctx = ctx;
|
371
|
+
}
|
372
|
+
get ready() {
|
373
|
+
return this._onceDone;
|
374
|
+
}
|
375
|
+
reset() {
|
376
|
+
this._onceDone = false;
|
377
|
+
this._onceOk = false;
|
378
|
+
this._onceValue = void 0;
|
379
|
+
this._onceError = void 0;
|
380
|
+
this._onceFutures.length = 0;
|
381
|
+
}
|
382
|
+
// T extends Option<infer U> ? U : T
|
383
|
+
once(fn) {
|
384
|
+
if (this._onceDone) {
|
385
|
+
if (this._onceError) {
|
386
|
+
if (this._isPromise) {
|
387
|
+
return Promise.reject(this._onceError);
|
388
|
+
} else {
|
389
|
+
throw this._onceError;
|
390
|
+
}
|
391
|
+
}
|
392
|
+
if (this._onceOk) {
|
393
|
+
if (this._isPromise) {
|
394
|
+
return Promise.resolve(this._onceValue);
|
395
|
+
} else {
|
396
|
+
return this._onceValue;
|
397
|
+
}
|
398
|
+
}
|
399
|
+
throw new Error("ResolveOnce.once impossible");
|
400
|
+
}
|
401
|
+
const future = new Future();
|
402
|
+
this._onceFutures.push(future);
|
403
|
+
if (this._onceFutures.length === 1) {
|
404
|
+
const okFn = (value) => {
|
405
|
+
this._onceValue = value;
|
406
|
+
this._onceOk = true;
|
407
|
+
this._onceDone = true;
|
408
|
+
if (this._isPromise) {
|
409
|
+
this._onceFutures.forEach((f) => f.resolve(this._onceValue));
|
410
|
+
}
|
411
|
+
this._onceFutures.length = 0;
|
412
|
+
};
|
413
|
+
const catchFn = (e) => {
|
414
|
+
this._onceError = e;
|
415
|
+
this._onceOk = false;
|
416
|
+
this._onceValue = void 0;
|
417
|
+
this._onceDone = true;
|
418
|
+
if (this._isPromise) {
|
419
|
+
this._onceFutures.forEach((f) => f.reject(this._onceError));
|
420
|
+
}
|
421
|
+
this._onceFutures.length = 0;
|
422
|
+
};
|
423
|
+
try {
|
424
|
+
const ret = fn(this.ctx);
|
425
|
+
if (typeof ret.then === "function") {
|
426
|
+
this._isPromise = true;
|
427
|
+
ret.then(okFn).catch(catchFn);
|
428
|
+
} else {
|
429
|
+
okFn(ret);
|
430
|
+
}
|
431
|
+
} catch (e) {
|
432
|
+
catchFn(e);
|
433
|
+
}
|
434
|
+
}
|
435
|
+
if (this._isPromise) {
|
436
|
+
return future.asPromise();
|
437
|
+
} else {
|
438
|
+
return this.once(fn);
|
439
|
+
}
|
440
|
+
}
|
441
|
+
};
|
442
|
+
|
443
|
+
// src/sys-env.ts
|
444
|
+
var _node;
|
445
|
+
var NodeEnvActions = class {
|
446
|
+
// eslint-disable-next-line @typescript-eslint/no-useless-constructor, @typescript-eslint/no-unused-vars
|
447
|
+
constructor(opts) {
|
448
|
+
__privateAdd(this, _node, globalThis);
|
449
|
+
this._env = this.active() ? __privateGet(this, _node).process.env : {};
|
450
|
+
}
|
451
|
+
register(env) {
|
452
|
+
return env;
|
453
|
+
}
|
454
|
+
active() {
|
455
|
+
return typeof __privateGet(this, _node) === "object" && typeof __privateGet(this, _node).process === "object" && typeof __privateGet(this, _node).process.env === "object";
|
456
|
+
}
|
457
|
+
keys() {
|
458
|
+
return Object.keys(this._env);
|
459
|
+
}
|
460
|
+
get(key) {
|
461
|
+
return this._env[key];
|
462
|
+
}
|
463
|
+
set(key, value) {
|
464
|
+
if (value) {
|
465
|
+
this._env[key] = value;
|
466
|
+
}
|
467
|
+
}
|
468
|
+
delete(key) {
|
469
|
+
delete this._env[key];
|
470
|
+
}
|
471
|
+
};
|
472
|
+
_node = new WeakMap();
|
473
|
+
var _deno;
|
474
|
+
var DenoEnvActions = class {
|
475
|
+
// eslint-disable-next-line @typescript-eslint/no-useless-constructor, @typescript-eslint/no-unused-vars
|
476
|
+
constructor(opts) {
|
477
|
+
__privateAdd(this, _deno, globalThis);
|
478
|
+
}
|
479
|
+
get _env() {
|
480
|
+
return __privateGet(this, _deno).Deno.env;
|
481
|
+
}
|
482
|
+
register(env) {
|
483
|
+
return env;
|
484
|
+
}
|
485
|
+
active() {
|
486
|
+
return typeof __privateGet(this, _deno) === "object" && typeof __privateGet(this, _deno).Deno === "object" && typeof __privateGet(this, _deno).Deno.env === "object";
|
487
|
+
}
|
488
|
+
keys() {
|
489
|
+
return Array.from(this._env.keys());
|
490
|
+
}
|
491
|
+
get(key) {
|
492
|
+
return this._env.get(key);
|
493
|
+
}
|
494
|
+
set(key, value) {
|
495
|
+
if (value) {
|
496
|
+
this._env.set(key, value);
|
497
|
+
}
|
498
|
+
}
|
499
|
+
delete(key) {
|
500
|
+
this._env.delete(key);
|
501
|
+
}
|
502
|
+
};
|
503
|
+
_deno = new WeakMap();
|
504
|
+
var BrowserEnvActions = class {
|
505
|
+
constructor(opts) {
|
506
|
+
this.env = /* @__PURE__ */ new Map();
|
507
|
+
this.opts = opts;
|
508
|
+
}
|
509
|
+
get(key) {
|
510
|
+
return this.env.get(key);
|
511
|
+
}
|
512
|
+
set(key, value) {
|
513
|
+
if (value) {
|
514
|
+
this.env.set(key, value);
|
515
|
+
}
|
516
|
+
}
|
517
|
+
delete(key) {
|
518
|
+
this.env.delete(key);
|
519
|
+
}
|
520
|
+
keys() {
|
521
|
+
return Array.from(this.env.keys());
|
522
|
+
}
|
523
|
+
active() {
|
524
|
+
return true;
|
525
|
+
}
|
526
|
+
register(env) {
|
527
|
+
const sym = Symbol.for(this.opts.symbol || "CP_ENV");
|
528
|
+
const browser = globalThis;
|
529
|
+
browser[sym] = env;
|
530
|
+
return env;
|
531
|
+
}
|
532
|
+
};
|
533
|
+
var _envFactory = new ResolveOnce();
|
534
|
+
function envFactory(opts = {}) {
|
535
|
+
return _envFactory.once(() => {
|
536
|
+
const found = [new NodeEnvActions(opts), new DenoEnvActions(opts), new BrowserEnvActions(opts)].find((env) => env.active());
|
537
|
+
if (!found) {
|
538
|
+
throw new Error("SysContainer:envFactory: no env available");
|
539
|
+
}
|
540
|
+
const ret = new EnvImpl(found, opts);
|
541
|
+
found.register(ret);
|
542
|
+
return ret;
|
543
|
+
});
|
544
|
+
}
|
545
|
+
var EnvImpl = class {
|
546
|
+
constructor(map, opts = {}) {
|
547
|
+
this._onSet = [];
|
548
|
+
this._map = map;
|
549
|
+
this._updatePresets(opts.presetEnv);
|
550
|
+
}
|
551
|
+
_updatePresets(presetEnv) {
|
552
|
+
if (!presetEnv) {
|
553
|
+
return;
|
554
|
+
}
|
555
|
+
for (const [key, value] of presetEnv) {
|
556
|
+
this._map.set(key, value);
|
557
|
+
}
|
558
|
+
}
|
559
|
+
_applyOnSet(onSet, key, value) {
|
560
|
+
onSet.forEach((item) => {
|
561
|
+
let keys = [];
|
562
|
+
if (key) {
|
563
|
+
keys = [key];
|
564
|
+
} else {
|
565
|
+
keys = this._map.keys();
|
566
|
+
}
|
567
|
+
keys.filter((k) => {
|
568
|
+
if (item.filter.size === 0) {
|
569
|
+
return true;
|
570
|
+
}
|
571
|
+
if (item.filter.has(k)) {
|
572
|
+
return true;
|
573
|
+
}
|
574
|
+
return false;
|
575
|
+
}).forEach((k) => {
|
576
|
+
let v;
|
577
|
+
if (!key && !value) {
|
578
|
+
v = this._map.get(k);
|
579
|
+
} else if (key && !value) {
|
580
|
+
v = void 0;
|
581
|
+
} else {
|
582
|
+
v = value;
|
583
|
+
}
|
584
|
+
item.fn(k, v);
|
585
|
+
});
|
586
|
+
});
|
587
|
+
}
|
588
|
+
keys() {
|
589
|
+
return this._map.keys();
|
590
|
+
}
|
591
|
+
// filter is not set all sets passed
|
592
|
+
onSet(fn, ...filter) {
|
593
|
+
const item = { filter: new Set(filter), fn };
|
594
|
+
this._onSet.push(item);
|
595
|
+
this._applyOnSet([item]);
|
596
|
+
}
|
597
|
+
get(key) {
|
598
|
+
return this._map.get(key);
|
599
|
+
}
|
600
|
+
set(key, value) {
|
601
|
+
if (!value) {
|
602
|
+
return;
|
603
|
+
}
|
604
|
+
this._map.set(key, value);
|
605
|
+
this._applyOnSet(this._onSet, key, value);
|
606
|
+
}
|
607
|
+
delete(key) {
|
608
|
+
this._map.delete(key);
|
609
|
+
this._applyOnSet(this._onSet, key);
|
610
|
+
}
|
611
|
+
};
|
612
|
+
|
613
|
+
// src/node/node-sys-abstraction.ts
|
614
|
+
var import_node_process2 = __toESM(require("process"), 1);
|
615
|
+
var NodeExitServiceImpl = class {
|
616
|
+
constructor() {
|
617
|
+
this._exitHandlers = [];
|
618
|
+
this.invoked = false;
|
619
|
+
this._handleExit = async () => {
|
620
|
+
if (this.invoked) {
|
621
|
+
return;
|
622
|
+
}
|
623
|
+
this.invoked = true;
|
624
|
+
for (const h of this._exitHandlers) {
|
625
|
+
try {
|
626
|
+
const ret = h.hdl();
|
627
|
+
if (typeof ret.then === "function") {
|
628
|
+
await ret;
|
629
|
+
}
|
630
|
+
} finally {
|
631
|
+
}
|
632
|
+
}
|
633
|
+
};
|
634
|
+
import_node_process2.default.on("unhandledRejection", (reason, p) => {
|
635
|
+
this.exit(19);
|
636
|
+
});
|
637
|
+
import_node_process2.default.on("uncaughtException", (error) => {
|
638
|
+
this.exit(18);
|
639
|
+
});
|
640
|
+
import_node_process2.default.on("close", () => {
|
641
|
+
this.exit(0);
|
642
|
+
});
|
643
|
+
import_node_process2.default.on("exit", () => {
|
644
|
+
this.exit(0);
|
645
|
+
});
|
646
|
+
import_node_process2.default.on("SIGQUIT", () => {
|
647
|
+
this.exit(3);
|
648
|
+
});
|
649
|
+
import_node_process2.default.on("SIGINT", () => {
|
650
|
+
this.exit(2);
|
651
|
+
});
|
652
|
+
import_node_process2.default.on("SIGTERM", () => {
|
653
|
+
this.exit(9);
|
654
|
+
});
|
655
|
+
}
|
656
|
+
injectExitHandlers(hdls) {
|
657
|
+
this._exitHandlers = hdls;
|
658
|
+
}
|
659
|
+
exit(code) {
|
660
|
+
this._handleExit().then(() => {
|
661
|
+
import_node_process2.default.exit(code);
|
662
|
+
}).catch((err) => {
|
663
|
+
console.error("ExitService: failed to handle exit", err);
|
664
|
+
import_node_process2.default.exit(code);
|
665
|
+
});
|
666
|
+
}
|
667
|
+
};
|
668
|
+
var _NodeSystemService = class _NodeSystemService {
|
669
|
+
constructor() {
|
670
|
+
this._exitService = new NodeExitServiceImpl();
|
671
|
+
this._exitService.injectExitHandlers(_NodeSystemService._exitHandlers);
|
672
|
+
}
|
673
|
+
Env() {
|
674
|
+
return envFactory();
|
675
|
+
}
|
676
|
+
Args() {
|
677
|
+
return import_node_process2.default.argv;
|
678
|
+
}
|
679
|
+
OnExit(hdl) {
|
680
|
+
const id = crypto.randomUUID();
|
681
|
+
_NodeSystemService._exitHandlers.push({ hdl, id });
|
682
|
+
return () => {
|
683
|
+
const idx = _NodeSystemService._exitHandlers.findIndex((h) => h.id === id);
|
684
|
+
if (idx >= 0) {
|
685
|
+
_NodeSystemService._exitHandlers.splice(idx, 1);
|
686
|
+
}
|
687
|
+
};
|
688
|
+
}
|
689
|
+
Exit(code) {
|
690
|
+
this._exitService.exit(code);
|
691
|
+
}
|
692
|
+
};
|
693
|
+
_NodeSystemService._exitHandlers = [];
|
694
|
+
var NodeSystemService = _NodeSystemService;
|
695
|
+
var my = void 0;
|
696
|
+
function NodeSysAbstraction(param) {
|
697
|
+
if (!my) {
|
698
|
+
my = new BaseSysAbstraction({
|
699
|
+
TxtEnDecoder: (param == null ? void 0 : param.TxtEnDecoder) || Utf8EnDecoderSingleton(),
|
700
|
+
FileSystem: new NodeFileService(),
|
701
|
+
SystemService: new NodeSystemService()
|
702
|
+
});
|
703
|
+
}
|
704
|
+
return new WrapperSysAbstraction(my, param);
|
705
|
+
}
|
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
|
+
|
877
|
+
// src/node/mock-file-service.ts
|
878
|
+
var MockFileService = class extends NodeFileService {
|
879
|
+
constructor() {
|
880
|
+
super(...arguments);
|
881
|
+
this.files = {};
|
882
|
+
}
|
883
|
+
// override abs(fname: string): string {
|
884
|
+
// return this.join("/mock/", fname);
|
885
|
+
// }
|
886
|
+
async create(fname) {
|
887
|
+
let oName = fname;
|
888
|
+
if (!this.isAbsolute(fname)) {
|
889
|
+
oName = await this.abs(fname);
|
890
|
+
}
|
891
|
+
const fc = {
|
892
|
+
name: oName,
|
893
|
+
content: ""
|
894
|
+
};
|
895
|
+
this.files[oName] = fc;
|
896
|
+
this.files[fname] = fc;
|
897
|
+
const decoder2 = new TextDecoder();
|
898
|
+
return {
|
899
|
+
name: oName,
|
900
|
+
stream: new WritableStream({
|
901
|
+
write(chunk) {
|
902
|
+
fc.content = fc.content + decoder2.decode(chunk);
|
903
|
+
},
|
904
|
+
close() {
|
905
|
+
},
|
906
|
+
abort() {
|
907
|
+
throw new Error("not implemented");
|
908
|
+
}
|
909
|
+
})
|
910
|
+
};
|
911
|
+
}
|
912
|
+
};
|
913
|
+
// Annotate the CommonJS export names for ESM import in node:
|
914
|
+
0 && (module.exports = {
|
915
|
+
DenoExitServiceImpl,
|
916
|
+
DenoSysAbstraction,
|
917
|
+
DenoSystemService,
|
918
|
+
MockFileService,
|
919
|
+
NodeExitServiceImpl,
|
920
|
+
NodeFileService,
|
921
|
+
NodeSysAbstraction,
|
922
|
+
NodeSystemService
|
923
|
+
});
|
924
|
+
//# sourceMappingURL=index.cjs.map
|