@adviser/cement 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- package/base_sys_abstraction-BCdXJHNa.d.ts +21 -0
- package/base_sys_abstraction-BYZvxqsW.d.cts +21 -0
- package/chunk-J2IM7FHM.js +65 -0
- package/chunk-J2IM7FHM.js.map +1 -0
- package/chunk-MWAFFTM4.js +82 -0
- package/chunk-MWAFFTM4.js.map +1 -0
- package/chunk-PZTL4UNG.js +233 -0
- package/chunk-PZTL4UNG.js.map +1 -0
- package/index.cjs +987 -0
- package/index.cjs.map +1 -0
- package/index.d.cts +196 -0
- package/index.d.ts +196 -11
- package/index.js +611 -26
- package/index.js.map +1 -1
- package/node/index.cjs +436 -0
- package/node/index.cjs.map +1 -0
- package/node/index.d.cts +47 -0
- package/node/index.d.ts +47 -4
- package/node/index.js +215 -17
- package/node/index.js.map +1 -1
- package/package.json +34 -8
- package/sys_abstraction-CjljYIkv.d.cts +65 -0
- package/sys_abstraction-CjljYIkv.d.ts +65 -0
- package/utils/index.cjs +270 -0
- package/utils/index.cjs.map +1 -0
- package/utils/index.d.cts +33 -0
- package/utils/index.d.ts +33 -6
- package/utils/index.js +232 -20
- package/utils/index.js.map +1 -1
- package/web/index.cjs +286 -0
- package/web/index.cjs.map +1 -0
- package/web/index.d.cts +6 -0
- package/web/index.d.ts +6 -2
- package/web/index.js +7 -16
- package/web/index.js.map +1 -1
- package/base_sys_abstraction.d.ts +0 -79
- package/base_sys_abstraction.d.ts.map +0 -1
- package/base_sys_abstraction.js +0 -186
- package/base_sys_abstraction.js.map +0 -1
- package/base_sys_abstraction.test.d.ts +0 -2
- package/base_sys_abstraction.test.d.ts.map +0 -1
- package/base_sys_abstraction.test.js +0 -77
- package/base_sys_abstraction.test.js.map +0 -1
- package/file_service.d.ts +0 -18
- package/file_service.d.ts.map +0 -1
- package/file_service.js +0 -3
- package/file_service.js.map +0 -1
- package/future.d.ts +0 -8
- package/future.d.ts.map +0 -1
- package/future.js +0 -42
- package/future.js.map +0 -1
- package/future.test.d.ts +0 -2
- package/future.test.d.ts.map +0 -1
- package/future.test.js +0 -30
- package/future.test.js.map +0 -1
- package/index.d.ts.map +0 -1
- package/logger.d.ts +0 -36
- package/logger.d.ts.map +0 -1
- package/logger.js +0 -11
- package/logger.js.map +0 -1
- package/logger.test.d.ts +0 -2
- package/logger.test.d.ts.map +0 -1
- package/logger.test.js +0 -372
- package/logger.test.js.map +0 -1
- package/logger_impl.d.ts +0 -64
- package/logger_impl.d.ts.map +0 -1
- package/logger_impl.js +0 -331
- package/logger_impl.js.map +0 -1
- package/node/index.d.ts.map +0 -1
- package/node/mock_file_service.d.ts +0 -11
- package/node/mock_file_service.d.ts.map +0 -1
- package/node/mock_file_service.js +0 -38
- package/node/mock_file_service.js.map +0 -1
- package/node/mock_file_service.test.d.ts +0 -2
- package/node/mock_file_service.test.d.ts.map +0 -1
- package/node/mock_file_service.test.js +0 -19
- package/node/mock_file_service.test.js.map +0 -1
- package/node/node_file_service.d.ts +0 -16
- package/node/node_file_service.d.ts.map +0 -1
- package/node/node_file_service.js +0 -84
- package/node/node_file_service.js.map +0 -1
- package/node/node_sys_abstraction.d.ts +0 -21
- package/node/node_sys_abstraction.d.ts.map +0 -1
- package/node/node_sys_abstraction.js +0 -101
- package/node/node_sys_abstraction.js.map +0 -1
- package/node/node_sys_abstraction.test.d.ts +0 -2
- package/node/node_sys_abstraction.test.d.ts.map +0 -1
- package/node/node_sys_abstraction.test.js +0 -57
- package/node/node_sys_abstraction.test.js.map +0 -1
- package/option.d.ts +0 -25
- package/option.d.ts.map +0 -1
- package/option.js +0 -53
- package/option.js.map +0 -1
- package/result.d.ts +0 -31
- package/result.d.ts.map +0 -1
- package/result.js +0 -69
- package/result.js.map +0 -1
- package/result.test.d.ts +0 -2
- package/result.test.d.ts.map +0 -1
- package/result.test.js +0 -39
- package/result.test.js.map +0 -1
- package/sys_abstraction.d.ts +0 -35
- package/sys_abstraction.d.ts.map +0 -1
- package/sys_abstraction.js +0 -35
- package/sys_abstraction.js.map +0 -1
- package/test/log_collector.d.ts +0 -22
- package/test/log_collector.d.ts.map +0 -1
- package/test/log_collector.js +0 -66
- package/test/log_collector.js.map +0 -1
- package/test/mock_logger.d.ts +0 -13
- package/test/mock_logger.d.ts.map +0 -1
- package/test/mock_logger.js +0 -30
- package/test/mock_logger.js.map +0 -1
- package/test/mock_logger.test.d.ts +0 -2
- package/test/mock_logger.test.d.ts.map +0 -1
- package/test/mock_logger.test.js +0 -49
- package/test/mock_logger.test.js.map +0 -1
- package/test/test-exit-handler.d.ts +0 -1
- package/test/test-exit-handler.d.ts.map +0 -1
- package/test/test-exit-handler.js +0 -76
- package/test/test-exit-handler.js.map +0 -1
- package/time.d.ts +0 -13
- package/time.d.ts.map +0 -1
- package/time.js +0 -18
- package/time.js.map +0 -1
- package/utils/index.d.ts.map +0 -1
- package/utils/rebuffer.d.ts +0 -3
- package/utils/rebuffer.d.ts.map +0 -1
- package/utils/rebuffer.js +0 -65
- package/utils/rebuffer.js.map +0 -1
- package/utils/rebuffer.test.d.ts +0 -2
- package/utils/rebuffer.test.d.ts.map +0 -1
- package/utils/rebuffer.test.js +0 -79
- package/utils/rebuffer.test.js.map +0 -1
- package/utils/stream2string.d.ts +0 -3
- package/utils/stream2string.d.ts.map +0 -1
- package/utils/stream2string.js +0 -53
- package/utils/stream2string.js.map +0 -1
- package/utils/stream2string.test.d.ts +0 -2
- package/utils/stream2string.test.d.ts.map +0 -1
- package/utils/stream2string.test.js +0 -31
- package/utils/stream2string.test.js.map +0 -1
- package/utils/stream_map.d.ts +0 -9
- package/utils/stream_map.d.ts.map +0 -1
- package/utils/stream_map.js +0 -67
- package/utils/stream_map.js.map +0 -1
- package/utils/stream_map.test.d.ts +0 -2
- package/utils/stream_map.test.d.ts.map +0 -1
- package/utils/stream_map.test.js +0 -89
- package/utils/stream_map.test.js.map +0 -1
- package/utils/stream_test_helper.d.ts +0 -15
- package/utils/stream_test_helper.d.ts.map +0 -1
- package/utils/stream_test_helper.js +0 -42
- package/utils/stream_test_helper.js.map +0 -1
- package/utils/string2stream.d.ts +0 -3
- package/utils/string2stream.d.ts.map +0 -1
- package/utils/string2stream.js +0 -18
- package/utils/string2stream.js.map +0 -1
- package/utils/string2stream.test.d.ts +0 -2
- package/utils/string2stream.test.d.ts.map +0 -1
- package/utils/string2stream.test.js +0 -9
- package/utils/string2stream.test.js.map +0 -1
- package/web/index.d.ts.map +0 -1
- package/web/web_sys_abstraction.d.ts +0 -4
- package/web/web_sys_abstraction.d.ts.map +0 -1
- package/web/web_sys_abstraction.js +0 -65
- package/web/web_sys_abstraction.js.map +0 -1
package/node/index.js
CHANGED
@@ -1,20 +1,218 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
import {
|
2
|
+
BaseSysAbstraction,
|
3
|
+
WrapperSysAbstraction
|
4
|
+
} from "../chunk-PZTL4UNG.js";
|
5
|
+
import "../chunk-J2IM7FHM.js";
|
6
|
+
|
7
|
+
// src/node/node_file_service.ts
|
8
|
+
import path from "node:path";
|
9
|
+
import fs from "node:fs";
|
10
|
+
var NodeFileService = class {
|
11
|
+
constructor(baseDir = process.cwd()) {
|
12
|
+
this.baseDir = this.abs(baseDir);
|
13
|
+
}
|
14
|
+
nodeImport(fname) {
|
15
|
+
if (path.isAbsolute(fname)) {
|
16
|
+
return fname;
|
17
|
+
} else {
|
18
|
+
return "./" + path.normalize(fname);
|
7
19
|
}
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
20
|
+
}
|
21
|
+
readFileString(fname) {
|
22
|
+
return fs.promises.readFile(fname, { encoding: "utf-8" });
|
23
|
+
}
|
24
|
+
dirname(fname) {
|
25
|
+
return path.dirname(fname);
|
26
|
+
}
|
27
|
+
basename(fname) {
|
28
|
+
return path.basename(fname);
|
29
|
+
}
|
30
|
+
join(...paths) {
|
31
|
+
return path.join(...paths);
|
32
|
+
}
|
33
|
+
relative(from, to) {
|
34
|
+
if (to === void 0) {
|
35
|
+
to = from;
|
36
|
+
from = process.cwd();
|
37
|
+
}
|
38
|
+
const ret = path.relative(from, to);
|
39
|
+
return ret;
|
40
|
+
}
|
41
|
+
abs(fname) {
|
42
|
+
if (path.isAbsolute(fname)) {
|
43
|
+
return fname;
|
44
|
+
} else {
|
45
|
+
const cwd = process.cwd();
|
46
|
+
return path.resolve(cwd, fname);
|
47
|
+
}
|
48
|
+
}
|
49
|
+
isAbsolute(fname) {
|
50
|
+
return path.isAbsolute(fname);
|
51
|
+
}
|
52
|
+
async writeFileString(fname, content) {
|
53
|
+
const o = await this.create(fname);
|
54
|
+
const wr = o.stream.getWriter();
|
55
|
+
await wr.write(new TextEncoder().encode(content));
|
56
|
+
await wr.close();
|
57
|
+
}
|
58
|
+
async create(fname) {
|
59
|
+
let oName = fname;
|
60
|
+
if (!path.isAbsolute(fname)) {
|
61
|
+
oName = this.abs(fname);
|
62
|
+
}
|
63
|
+
const base = path.dirname(oName);
|
64
|
+
await fs.promises.mkdir(base, { recursive: true });
|
65
|
+
const out = fs.createWriteStream(oName);
|
66
|
+
return {
|
67
|
+
name: oName,
|
68
|
+
stream: new WritableStream({
|
69
|
+
write(chunk) {
|
70
|
+
out.write(chunk);
|
71
|
+
},
|
72
|
+
close() {
|
73
|
+
out.close();
|
74
|
+
},
|
75
|
+
abort() {
|
76
|
+
throw new Error("not implemented");
|
77
|
+
}
|
78
|
+
})
|
79
|
+
};
|
80
|
+
}
|
81
|
+
};
|
82
|
+
|
83
|
+
// src/node/node_sys_abstraction.ts
|
84
|
+
var ExitServiceImpl = class {
|
85
|
+
constructor() {
|
86
|
+
this._exitHandlers = [];
|
87
|
+
this.invoked = false;
|
88
|
+
this._handleExit = async () => {
|
89
|
+
if (this.invoked) {
|
90
|
+
return;
|
91
|
+
}
|
92
|
+
this.invoked = true;
|
93
|
+
for (const h of this._exitHandlers) {
|
94
|
+
try {
|
95
|
+
const ret = h.hdl();
|
96
|
+
if (typeof ret.then === "function") {
|
97
|
+
await ret;
|
98
|
+
}
|
99
|
+
} finally {
|
100
|
+
}
|
101
|
+
}
|
102
|
+
};
|
103
|
+
process.on("unhandledRejection", (reason, p) => {
|
104
|
+
this.exit(19);
|
105
|
+
});
|
106
|
+
process.on("uncaughtException", (error) => {
|
107
|
+
this.exit(18);
|
108
|
+
});
|
109
|
+
process.on("close", () => {
|
110
|
+
this.exit(0);
|
111
|
+
});
|
112
|
+
process.on("exit", () => {
|
113
|
+
this.exit(0);
|
114
|
+
});
|
115
|
+
process.on("SIGQUIT", () => {
|
116
|
+
this.exit(3);
|
117
|
+
});
|
118
|
+
process.on("SIGINT", () => {
|
119
|
+
this.exit(2);
|
120
|
+
});
|
121
|
+
process.on("SIGTERM", () => {
|
122
|
+
this.exit(9);
|
123
|
+
});
|
124
|
+
}
|
125
|
+
injectExitHandlers(hdls) {
|
126
|
+
this._exitHandlers = hdls;
|
127
|
+
}
|
128
|
+
exit(code) {
|
129
|
+
this._handleExit().then(() => {
|
130
|
+
process.exit(code);
|
131
|
+
}).catch((err) => {
|
132
|
+
console.error("ExitService: failed to handle exit", err);
|
133
|
+
process.exit(code);
|
134
|
+
});
|
135
|
+
}
|
136
|
+
};
|
137
|
+
var _NodeSystemService = class _NodeSystemService {
|
138
|
+
constructor() {
|
139
|
+
this._exitService = new ExitServiceImpl();
|
140
|
+
this._exitService.injectExitHandlers(_NodeSystemService._exitHandlers);
|
141
|
+
}
|
142
|
+
Env() {
|
143
|
+
return process.env;
|
144
|
+
}
|
145
|
+
Args() {
|
146
|
+
return process.argv;
|
147
|
+
}
|
148
|
+
OnExit(hdl) {
|
149
|
+
const id = crypto.randomUUID();
|
150
|
+
_NodeSystemService._exitHandlers.push({ hdl, id });
|
151
|
+
return () => {
|
152
|
+
const idx = _NodeSystemService._exitHandlers.findIndex((h) => h.id === id);
|
153
|
+
if (idx >= 0) {
|
154
|
+
_NodeSystemService._exitHandlers.splice(idx, 1);
|
155
|
+
}
|
156
|
+
};
|
157
|
+
}
|
158
|
+
Exit(code) {
|
159
|
+
this._exitService.exit(code);
|
160
|
+
}
|
161
|
+
};
|
162
|
+
_NodeSystemService._exitHandlers = [];
|
163
|
+
var NodeSystemService = _NodeSystemService;
|
164
|
+
var my = void 0;
|
165
|
+
function NodeSysAbstraction(param) {
|
166
|
+
if (!my) {
|
167
|
+
my = new BaseSysAbstraction({
|
168
|
+
FileSystem: new NodeFileService(),
|
169
|
+
SystemService: new NodeSystemService()
|
170
|
+
});
|
171
|
+
}
|
172
|
+
return new WrapperSysAbstraction(my, param);
|
173
|
+
}
|
174
|
+
|
175
|
+
// src/node/mock_file_service.ts
|
176
|
+
var MockFileService = class extends NodeFileService {
|
177
|
+
constructor() {
|
178
|
+
super(...arguments);
|
179
|
+
this.files = {};
|
180
|
+
}
|
181
|
+
// override abs(fname: string): string {
|
182
|
+
// return this.join("/mock/", fname);
|
183
|
+
// }
|
184
|
+
async create(fname) {
|
185
|
+
let oName = fname;
|
186
|
+
if (!this.isAbsolute(fname)) {
|
187
|
+
oName = await this.abs(fname);
|
188
|
+
}
|
189
|
+
const fc = {
|
190
|
+
name: oName,
|
191
|
+
content: ""
|
192
|
+
};
|
193
|
+
this.files[oName] = fc;
|
194
|
+
this.files[fname] = fc;
|
195
|
+
const decoder = new TextDecoder();
|
196
|
+
return {
|
197
|
+
name: oName,
|
198
|
+
stream: new WritableStream({
|
199
|
+
write(chunk) {
|
200
|
+
fc.content = fc.content + decoder.decode(chunk);
|
201
|
+
},
|
202
|
+
close() {
|
203
|
+
},
|
204
|
+
abort() {
|
205
|
+
throw new Error("not implemented");
|
206
|
+
}
|
207
|
+
})
|
208
|
+
};
|
209
|
+
}
|
210
|
+
};
|
211
|
+
export {
|
212
|
+
ExitServiceImpl,
|
213
|
+
MockFileService,
|
214
|
+
NodeFileService,
|
215
|
+
NodeSysAbstraction,
|
216
|
+
NodeSystemService
|
15
217
|
};
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
__exportStar(require("./node_file_service"), exports);
|
18
|
-
__exportStar(require("./node_sys_abstraction"), exports);
|
19
|
-
__exportStar(require("./mock_file_service"), exports);
|
20
218
|
//# sourceMappingURL=index.js.map
|
package/node/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,yDAAuC;AACvC,sDAAoC"}
|
1
|
+
{"version":3,"sources":["../../../src/node/node_file_service.ts","../../../src/node/node_sys_abstraction.ts","../../../src/node/mock_file_service.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs\";\nimport { FileService, NamedWritableStream } from \"../file_service\";\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): Promise<void> {\n const o = await this.create(fname);\n const wr = o.stream.getWriter();\n await wr.write(new TextEncoder().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","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\";\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 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 process.env as Record<string, string>;\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,OAAO,UAAU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AK,IAAI,mBAAmB;AAAA,MAC1B,YAAY,IAAI,gBAAgB;AAAA,MAChC,eAAe,IAAI,kBAAkB;AAAA,IACvC,CAAC;AAAA,EACH;AACA,SAAO,IAAI,sBAAsB,IAAI,KAAK;AAC5C;;;AC3GO,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,UAAM,UAAU,IAAI,YAAY;AAEhC,WAAO;AAAA,MACL,MAAM;AAAA,MACN,QAAQ,IAAI,eAA2B;AAAA,QACrC,MAAM,OAAO;AACX,aAAG,UAAU,GAAG,UAAU,QAAQ,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":[]}
|
package/package.json
CHANGED
@@ -1,9 +1,31 @@
|
|
1
1
|
{
|
2
2
|
"name": "@adviser/cement",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.12",
|
4
4
|
"description": "better try/catch/finally handling",
|
5
|
-
"
|
5
|
+
"main": "index.js",
|
6
6
|
"type": "module",
|
7
|
+
"exports": {
|
8
|
+
".": {
|
9
|
+
"require": "./index.cjs",
|
10
|
+
"import": "./index.js",
|
11
|
+
"types": "./index.d.ts"
|
12
|
+
},
|
13
|
+
"./web": {
|
14
|
+
"require": "./web/index.cjs",
|
15
|
+
"import": "./web/index.js",
|
16
|
+
"types": "./web/index.d.ts"
|
17
|
+
},
|
18
|
+
"./utils": {
|
19
|
+
"require": "./utils/index.cjs",
|
20
|
+
"import": "./utils/index.js",
|
21
|
+
"types": "./utils/index.d.ts"
|
22
|
+
},
|
23
|
+
"./node": {
|
24
|
+
"require": "./node/index.cjs",
|
25
|
+
"import": "./node/index.js",
|
26
|
+
"types": "./node/index.d.ts"
|
27
|
+
}
|
28
|
+
},
|
7
29
|
"keywords": [],
|
8
30
|
"author": "Meno Abels <meno.abels@adviser.com>",
|
9
31
|
"license": "AFL-2.0",
|
@@ -21,21 +43,25 @@
|
|
21
43
|
"prettier": "^3.2.5",
|
22
44
|
"ts-jest": "^29.1.2",
|
23
45
|
"tsx": "^4.15.2",
|
24
|
-
"typescript
|
25
|
-
"typescript": "^
|
46
|
+
"typescript": "^5.4.3",
|
47
|
+
"typescript-eslint": "^7.13.0"
|
26
48
|
},
|
27
49
|
"engines": {
|
28
50
|
"node": ">=16"
|
29
51
|
},
|
52
|
+
"dependencies": {
|
53
|
+
"tsup": "^8.1.0"
|
54
|
+
},
|
30
55
|
"scripts": {
|
31
56
|
"clean": "rm -rf dist node_modules",
|
32
|
-
"build": "pnpm run build:js",
|
33
|
-
"build:
|
57
|
+
"build": "pnpm run build:tsc; pnpm run build:js",
|
58
|
+
"build:tsc": "tsc",
|
59
|
+
"build:js": "tsup --out-dir dist/pkg src/index.ts src/*/index.ts --sourcemap --format cjs,esm --dts --clean --external node:fs --external node:path",
|
34
60
|
"test": "pnpm run test:js",
|
35
61
|
"test:js": "jest",
|
36
|
-
"pubdir": "pnpm run build; rm -rf pubdir ; mkdir -p pubdir; cp -pr ../.gitignore package.json ../README.md ../LICENSE pubdir/; cd dist ; cp -pr .
|
62
|
+
"pubdir": "pnpm run build; rm -rf pubdir ; mkdir -p pubdir; cp -pr ../.gitignore package.json ../README.md ../LICENSE pubdir/; cd dist/pkg ; cp -pr . ../../pubdir/",
|
37
63
|
"presmoke": "pnpm run pubdir ; cd pubdir ; pnpm pack",
|
38
|
-
"smoke": "cd smoke; rm -f package.json; pnpm init ; pnpm install -f ../pubdir/adviser-cement-*.tgz; npx tsx ./smoke.ts",
|
64
|
+
"smoke": "cd smoke; rm -f package.json; pnpm init ; pnpm install -f ../pubdir/adviser-cement-*.tgz; npx tsx ./smoke.ts; deno run --allow-read ./smoke.ts",
|
39
65
|
"lint": "eslint .",
|
40
66
|
"prettier": "prettier ."
|
41
67
|
}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
interface NamedWritableStream {
|
2
|
+
readonly name: string;
|
3
|
+
readonly stream: WritableStream<Uint8Array>;
|
4
|
+
}
|
5
|
+
interface FileService {
|
6
|
+
readonly baseDir: string;
|
7
|
+
create(fname: string): Promise<NamedWritableStream>;
|
8
|
+
readFileString(fname: string): Promise<string>;
|
9
|
+
writeFileString(fname: string, content: string): Promise<void>;
|
10
|
+
abs(fname: string): string;
|
11
|
+
join(...paths: string[]): string;
|
12
|
+
relative(from: string, to?: string): string;
|
13
|
+
dirname(fname: string): string;
|
14
|
+
basename(fname: string): string;
|
15
|
+
nodeImport(fname: string): string;
|
16
|
+
isAbsolute(fname: string): boolean;
|
17
|
+
}
|
18
|
+
|
19
|
+
declare abstract class Time {
|
20
|
+
abstract Now(): Date;
|
21
|
+
abstract Sleep(duration: Duration): Promise<void>;
|
22
|
+
TimeSince(start: Date): Duration;
|
23
|
+
}
|
24
|
+
type Duration = number;
|
25
|
+
declare enum TimeUnits {
|
26
|
+
Microsecond = 1,
|
27
|
+
Second = 1000,
|
28
|
+
Minute = 60000,
|
29
|
+
Hour = 3600000
|
30
|
+
}
|
31
|
+
|
32
|
+
declare enum TimeMode {
|
33
|
+
REAL = "real",
|
34
|
+
CONST = "const",
|
35
|
+
STEP = "step"
|
36
|
+
}
|
37
|
+
declare enum RandomMode {
|
38
|
+
CONST = "const",
|
39
|
+
STEP = "step",
|
40
|
+
RANDOM = "random"
|
41
|
+
}
|
42
|
+
declare enum IDMode {
|
43
|
+
UUID = "uuid",
|
44
|
+
CONST = "const",
|
45
|
+
STEP = "step"
|
46
|
+
}
|
47
|
+
declare function String2TimeMode(s?: string): TimeMode;
|
48
|
+
type VoidFunc = () => void | Promise<void>;
|
49
|
+
interface SystemService {
|
50
|
+
Env(): Record<string, string>;
|
51
|
+
Args(): string[];
|
52
|
+
OnExit(hdl: VoidFunc): VoidFunc;
|
53
|
+
Exit(code: number): void;
|
54
|
+
}
|
55
|
+
interface SysAbstraction {
|
56
|
+
Time(): Time;
|
57
|
+
Stdout(): WritableStream<Uint8Array>;
|
58
|
+
Stderr(): WritableStream<Uint8Array>;
|
59
|
+
NextId(): string;
|
60
|
+
Random0ToValue(value: number): number;
|
61
|
+
System(): SystemService;
|
62
|
+
FileSystem(): FileService;
|
63
|
+
}
|
64
|
+
|
65
|
+
export { type Duration as D, type FileService as F, IDMode as I, type NamedWritableStream as N, RandomMode as R, type SysAbstraction as S, TimeMode as T, type VoidFunc as V, String2TimeMode as a, type SystemService as b, Time as c, TimeUnits as d };
|
@@ -0,0 +1,65 @@
|
|
1
|
+
interface NamedWritableStream {
|
2
|
+
readonly name: string;
|
3
|
+
readonly stream: WritableStream<Uint8Array>;
|
4
|
+
}
|
5
|
+
interface FileService {
|
6
|
+
readonly baseDir: string;
|
7
|
+
create(fname: string): Promise<NamedWritableStream>;
|
8
|
+
readFileString(fname: string): Promise<string>;
|
9
|
+
writeFileString(fname: string, content: string): Promise<void>;
|
10
|
+
abs(fname: string): string;
|
11
|
+
join(...paths: string[]): string;
|
12
|
+
relative(from: string, to?: string): string;
|
13
|
+
dirname(fname: string): string;
|
14
|
+
basename(fname: string): string;
|
15
|
+
nodeImport(fname: string): string;
|
16
|
+
isAbsolute(fname: string): boolean;
|
17
|
+
}
|
18
|
+
|
19
|
+
declare abstract class Time {
|
20
|
+
abstract Now(): Date;
|
21
|
+
abstract Sleep(duration: Duration): Promise<void>;
|
22
|
+
TimeSince(start: Date): Duration;
|
23
|
+
}
|
24
|
+
type Duration = number;
|
25
|
+
declare enum TimeUnits {
|
26
|
+
Microsecond = 1,
|
27
|
+
Second = 1000,
|
28
|
+
Minute = 60000,
|
29
|
+
Hour = 3600000
|
30
|
+
}
|
31
|
+
|
32
|
+
declare enum TimeMode {
|
33
|
+
REAL = "real",
|
34
|
+
CONST = "const",
|
35
|
+
STEP = "step"
|
36
|
+
}
|
37
|
+
declare enum RandomMode {
|
38
|
+
CONST = "const",
|
39
|
+
STEP = "step",
|
40
|
+
RANDOM = "random"
|
41
|
+
}
|
42
|
+
declare enum IDMode {
|
43
|
+
UUID = "uuid",
|
44
|
+
CONST = "const",
|
45
|
+
STEP = "step"
|
46
|
+
}
|
47
|
+
declare function String2TimeMode(s?: string): TimeMode;
|
48
|
+
type VoidFunc = () => void | Promise<void>;
|
49
|
+
interface SystemService {
|
50
|
+
Env(): Record<string, string>;
|
51
|
+
Args(): string[];
|
52
|
+
OnExit(hdl: VoidFunc): VoidFunc;
|
53
|
+
Exit(code: number): void;
|
54
|
+
}
|
55
|
+
interface SysAbstraction {
|
56
|
+
Time(): Time;
|
57
|
+
Stdout(): WritableStream<Uint8Array>;
|
58
|
+
Stderr(): WritableStream<Uint8Array>;
|
59
|
+
NextId(): string;
|
60
|
+
Random0ToValue(value: number): number;
|
61
|
+
System(): SystemService;
|
62
|
+
FileSystem(): FileService;
|
63
|
+
}
|
64
|
+
|
65
|
+
export { type Duration as D, type FileService as F, IDMode as I, type NamedWritableStream as N, RandomMode as R, type SysAbstraction as S, TimeMode as T, type VoidFunc as V, String2TimeMode as a, type SystemService as b, Time as c, TimeUnits as d };
|