@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.
Files changed (167) hide show
  1. package/base_sys_abstraction-BCdXJHNa.d.ts +21 -0
  2. package/base_sys_abstraction-BYZvxqsW.d.cts +21 -0
  3. package/chunk-J2IM7FHM.js +65 -0
  4. package/chunk-J2IM7FHM.js.map +1 -0
  5. package/chunk-MWAFFTM4.js +82 -0
  6. package/chunk-MWAFFTM4.js.map +1 -0
  7. package/chunk-PZTL4UNG.js +233 -0
  8. package/chunk-PZTL4UNG.js.map +1 -0
  9. package/index.cjs +987 -0
  10. package/index.cjs.map +1 -0
  11. package/index.d.cts +196 -0
  12. package/index.d.ts +196 -11
  13. package/index.js +611 -26
  14. package/index.js.map +1 -1
  15. package/node/index.cjs +436 -0
  16. package/node/index.cjs.map +1 -0
  17. package/node/index.d.cts +47 -0
  18. package/node/index.d.ts +47 -4
  19. package/node/index.js +215 -17
  20. package/node/index.js.map +1 -1
  21. package/package.json +34 -8
  22. package/sys_abstraction-CjljYIkv.d.cts +65 -0
  23. package/sys_abstraction-CjljYIkv.d.ts +65 -0
  24. package/utils/index.cjs +270 -0
  25. package/utils/index.cjs.map +1 -0
  26. package/utils/index.d.cts +33 -0
  27. package/utils/index.d.ts +33 -6
  28. package/utils/index.js +232 -20
  29. package/utils/index.js.map +1 -1
  30. package/web/index.cjs +286 -0
  31. package/web/index.cjs.map +1 -0
  32. package/web/index.d.cts +6 -0
  33. package/web/index.d.ts +6 -2
  34. package/web/index.js +7 -16
  35. package/web/index.js.map +1 -1
  36. package/base_sys_abstraction.d.ts +0 -79
  37. package/base_sys_abstraction.d.ts.map +0 -1
  38. package/base_sys_abstraction.js +0 -186
  39. package/base_sys_abstraction.js.map +0 -1
  40. package/base_sys_abstraction.test.d.ts +0 -2
  41. package/base_sys_abstraction.test.d.ts.map +0 -1
  42. package/base_sys_abstraction.test.js +0 -77
  43. package/base_sys_abstraction.test.js.map +0 -1
  44. package/file_service.d.ts +0 -18
  45. package/file_service.d.ts.map +0 -1
  46. package/file_service.js +0 -3
  47. package/file_service.js.map +0 -1
  48. package/future.d.ts +0 -8
  49. package/future.d.ts.map +0 -1
  50. package/future.js +0 -42
  51. package/future.js.map +0 -1
  52. package/future.test.d.ts +0 -2
  53. package/future.test.d.ts.map +0 -1
  54. package/future.test.js +0 -30
  55. package/future.test.js.map +0 -1
  56. package/index.d.ts.map +0 -1
  57. package/logger.d.ts +0 -36
  58. package/logger.d.ts.map +0 -1
  59. package/logger.js +0 -11
  60. package/logger.js.map +0 -1
  61. package/logger.test.d.ts +0 -2
  62. package/logger.test.d.ts.map +0 -1
  63. package/logger.test.js +0 -372
  64. package/logger.test.js.map +0 -1
  65. package/logger_impl.d.ts +0 -64
  66. package/logger_impl.d.ts.map +0 -1
  67. package/logger_impl.js +0 -331
  68. package/logger_impl.js.map +0 -1
  69. package/node/index.d.ts.map +0 -1
  70. package/node/mock_file_service.d.ts +0 -11
  71. package/node/mock_file_service.d.ts.map +0 -1
  72. package/node/mock_file_service.js +0 -38
  73. package/node/mock_file_service.js.map +0 -1
  74. package/node/mock_file_service.test.d.ts +0 -2
  75. package/node/mock_file_service.test.d.ts.map +0 -1
  76. package/node/mock_file_service.test.js +0 -19
  77. package/node/mock_file_service.test.js.map +0 -1
  78. package/node/node_file_service.d.ts +0 -16
  79. package/node/node_file_service.d.ts.map +0 -1
  80. package/node/node_file_service.js +0 -84
  81. package/node/node_file_service.js.map +0 -1
  82. package/node/node_sys_abstraction.d.ts +0 -21
  83. package/node/node_sys_abstraction.d.ts.map +0 -1
  84. package/node/node_sys_abstraction.js +0 -101
  85. package/node/node_sys_abstraction.js.map +0 -1
  86. package/node/node_sys_abstraction.test.d.ts +0 -2
  87. package/node/node_sys_abstraction.test.d.ts.map +0 -1
  88. package/node/node_sys_abstraction.test.js +0 -57
  89. package/node/node_sys_abstraction.test.js.map +0 -1
  90. package/option.d.ts +0 -25
  91. package/option.d.ts.map +0 -1
  92. package/option.js +0 -53
  93. package/option.js.map +0 -1
  94. package/result.d.ts +0 -31
  95. package/result.d.ts.map +0 -1
  96. package/result.js +0 -69
  97. package/result.js.map +0 -1
  98. package/result.test.d.ts +0 -2
  99. package/result.test.d.ts.map +0 -1
  100. package/result.test.js +0 -39
  101. package/result.test.js.map +0 -1
  102. package/sys_abstraction.d.ts +0 -35
  103. package/sys_abstraction.d.ts.map +0 -1
  104. package/sys_abstraction.js +0 -35
  105. package/sys_abstraction.js.map +0 -1
  106. package/test/log_collector.d.ts +0 -22
  107. package/test/log_collector.d.ts.map +0 -1
  108. package/test/log_collector.js +0 -66
  109. package/test/log_collector.js.map +0 -1
  110. package/test/mock_logger.d.ts +0 -13
  111. package/test/mock_logger.d.ts.map +0 -1
  112. package/test/mock_logger.js +0 -30
  113. package/test/mock_logger.js.map +0 -1
  114. package/test/mock_logger.test.d.ts +0 -2
  115. package/test/mock_logger.test.d.ts.map +0 -1
  116. package/test/mock_logger.test.js +0 -49
  117. package/test/mock_logger.test.js.map +0 -1
  118. package/test/test-exit-handler.d.ts +0 -1
  119. package/test/test-exit-handler.d.ts.map +0 -1
  120. package/test/test-exit-handler.js +0 -76
  121. package/test/test-exit-handler.js.map +0 -1
  122. package/time.d.ts +0 -13
  123. package/time.d.ts.map +0 -1
  124. package/time.js +0 -18
  125. package/time.js.map +0 -1
  126. package/utils/index.d.ts.map +0 -1
  127. package/utils/rebuffer.d.ts +0 -3
  128. package/utils/rebuffer.d.ts.map +0 -1
  129. package/utils/rebuffer.js +0 -65
  130. package/utils/rebuffer.js.map +0 -1
  131. package/utils/rebuffer.test.d.ts +0 -2
  132. package/utils/rebuffer.test.d.ts.map +0 -1
  133. package/utils/rebuffer.test.js +0 -79
  134. package/utils/rebuffer.test.js.map +0 -1
  135. package/utils/stream2string.d.ts +0 -3
  136. package/utils/stream2string.d.ts.map +0 -1
  137. package/utils/stream2string.js +0 -53
  138. package/utils/stream2string.js.map +0 -1
  139. package/utils/stream2string.test.d.ts +0 -2
  140. package/utils/stream2string.test.d.ts.map +0 -1
  141. package/utils/stream2string.test.js +0 -31
  142. package/utils/stream2string.test.js.map +0 -1
  143. package/utils/stream_map.d.ts +0 -9
  144. package/utils/stream_map.d.ts.map +0 -1
  145. package/utils/stream_map.js +0 -67
  146. package/utils/stream_map.js.map +0 -1
  147. package/utils/stream_map.test.d.ts +0 -2
  148. package/utils/stream_map.test.d.ts.map +0 -1
  149. package/utils/stream_map.test.js +0 -89
  150. package/utils/stream_map.test.js.map +0 -1
  151. package/utils/stream_test_helper.d.ts +0 -15
  152. package/utils/stream_test_helper.d.ts.map +0 -1
  153. package/utils/stream_test_helper.js +0 -42
  154. package/utils/stream_test_helper.js.map +0 -1
  155. package/utils/string2stream.d.ts +0 -3
  156. package/utils/string2stream.d.ts.map +0 -1
  157. package/utils/string2stream.js +0 -18
  158. package/utils/string2stream.js.map +0 -1
  159. package/utils/string2stream.test.d.ts +0 -2
  160. package/utils/string2stream.test.d.ts.map +0 -1
  161. package/utils/string2stream.test.js +0 -9
  162. package/utils/string2stream.test.js.map +0 -1
  163. package/web/index.d.ts.map +0 -1
  164. package/web/web_sys_abstraction.d.ts +0 -4
  165. package/web/web_sys_abstraction.d.ts.map +0 -1
  166. package/web/web_sys_abstraction.js +0 -65
  167. package/web/web_sys_abstraction.js.map +0 -1
package/web/index.cjs ADDED
@@ -0,0 +1,286 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/web/index.ts
21
+ var web_exports = {};
22
+ __export(web_exports, {
23
+ WebSysAbstraction: () => WebSysAbstraction
24
+ });
25
+ module.exports = __toCommonJS(web_exports);
26
+
27
+ // src/time.ts
28
+ var Time = class {
29
+ TimeSince(start) {
30
+ const now = this.Now();
31
+ return now.getTime() - start.getTime();
32
+ }
33
+ };
34
+
35
+ // src/base_sys_abstraction.ts
36
+ var SysTime = class extends Time {
37
+ Now() {
38
+ return /* @__PURE__ */ new Date();
39
+ }
40
+ Sleep(duration) {
41
+ return new Promise((resolve) => {
42
+ setTimeout(() => {
43
+ resolve();
44
+ }, duration);
45
+ });
46
+ }
47
+ };
48
+ var ConstTime = class extends Time {
49
+ Now() {
50
+ return new Date(2021, 1, 1, 0, 0, 0, 0);
51
+ }
52
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
53
+ Sleep(duration) {
54
+ return Promise.resolve();
55
+ }
56
+ };
57
+ var StepTime = class extends Time {
58
+ constructor() {
59
+ super();
60
+ this._step = new ConstTime().Now();
61
+ }
62
+ Now() {
63
+ if (this._step.getTime() === 0) {
64
+ this._step = new ConstTime().Now();
65
+ return this._step;
66
+ }
67
+ this._step = new Date(this._step.getTime() + 1e3);
68
+ return this._step;
69
+ }
70
+ Sleep(duration) {
71
+ this._step = new Date(this._step.getTime() + duration);
72
+ return Promise.resolve();
73
+ }
74
+ };
75
+ function TimeFactory(timeMode) {
76
+ switch (timeMode) {
77
+ case "real" /* REAL */:
78
+ return new SysTime();
79
+ case "const" /* CONST */:
80
+ return new ConstTime();
81
+ case "step" /* STEP */:
82
+ return new StepTime();
83
+ }
84
+ return new SysTime();
85
+ }
86
+ var RandomService = class {
87
+ constructor(mode) {
88
+ this._step = 0;
89
+ this._mode = mode;
90
+ }
91
+ Random0ToValue(value) {
92
+ switch (this._mode) {
93
+ case "const" /* CONST */:
94
+ return 0.5 * value;
95
+ case "step" /* STEP */:
96
+ this._step += 1e-4;
97
+ return this._step * value;
98
+ case "random" /* RANDOM */:
99
+ return Math.random() * value;
100
+ default:
101
+ throw new Error("Unknown RandomMode");
102
+ }
103
+ }
104
+ };
105
+ var IdService = class {
106
+ constructor(mode) {
107
+ this._step = 0;
108
+ if (!mode) {
109
+ mode = "uuid" /* UUID */;
110
+ }
111
+ this._mode = mode;
112
+ }
113
+ NextId() {
114
+ switch (this._mode) {
115
+ case "uuid" /* UUID */:
116
+ return crypto.randomUUID();
117
+ case "const" /* CONST */:
118
+ return "VeryUniqueID";
119
+ case "step" /* STEP */:
120
+ return `STEPId-${this._step++}`;
121
+ default:
122
+ throw new Error("Unknown IDMode");
123
+ }
124
+ }
125
+ };
126
+ var decoder = new TextDecoder();
127
+ var BaseSysAbstraction = class {
128
+ constructor(params) {
129
+ this._time = new SysTime();
130
+ this._stdout = new WritableStream({
131
+ write(chunk) {
132
+ return new Promise((resolve) => {
133
+ const decoded = decoder.decode(chunk);
134
+ console.log(decoded.trimEnd());
135
+ resolve();
136
+ });
137
+ }
138
+ });
139
+ this._stderr = new WritableStream({
140
+ write(chunk) {
141
+ return new Promise((resolve) => {
142
+ const decoded = decoder.decode(chunk);
143
+ console.error(decoded.trimEnd());
144
+ resolve();
145
+ });
146
+ }
147
+ });
148
+ this._idService = new IdService();
149
+ this._randomService = new RandomService("random" /* RANDOM */);
150
+ this._fileSystem = params.FileSystem;
151
+ this._systemService = params.SystemService;
152
+ }
153
+ };
154
+ var WrapperSysAbstraction = class {
155
+ constructor(base, params) {
156
+ this._time = base._time;
157
+ this._stdout = base._stdout;
158
+ this._stderr = base._stderr;
159
+ this._idService = base._idService;
160
+ this._randomService = base._randomService;
161
+ this._fileSystem = base._fileSystem;
162
+ this._systemService = base._systemService;
163
+ if (params) {
164
+ if (params.TimeMode) {
165
+ this._time = TimeFactory(params.TimeMode);
166
+ }
167
+ if (params.Stdout) {
168
+ this._stdout = params.Stdout;
169
+ }
170
+ if (params.Stderr) {
171
+ this._stderr = params.Stderr;
172
+ }
173
+ if (params.IdMode) {
174
+ this._idService = new IdService(params.IdMode);
175
+ }
176
+ if (params.RandomMode) {
177
+ this._randomService = new RandomService(params.RandomMode);
178
+ }
179
+ if (params.FileSystem) {
180
+ this._fileSystem = params.FileSystem;
181
+ }
182
+ if (params.SystemService) {
183
+ this._systemService = params.SystemService;
184
+ }
185
+ }
186
+ }
187
+ Time() {
188
+ return this._time;
189
+ }
190
+ NextId() {
191
+ return this._idService.NextId();
192
+ }
193
+ Random0ToValue(value) {
194
+ return this._randomService.Random0ToValue(value);
195
+ }
196
+ Stdout() {
197
+ return this._stdout;
198
+ }
199
+ Stderr() {
200
+ return this._stderr;
201
+ }
202
+ System() {
203
+ return this._systemService;
204
+ }
205
+ FileSystem() {
206
+ return this._fileSystem;
207
+ }
208
+ };
209
+
210
+ // src/web/web_sys_abstraction.ts
211
+ var WebFileService = class {
212
+ get baseDir() {
213
+ throw new Error("basedir-Method not implemented.");
214
+ }
215
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
216
+ create(fname) {
217
+ throw new Error("create-Method not implemented.");
218
+ }
219
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
220
+ readFileString(fname) {
221
+ throw new Error("readFileString-Method not implemented.");
222
+ }
223
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
224
+ writeFileString(fname, content) {
225
+ throw new Error("writeFileString-Method not implemented.");
226
+ }
227
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
228
+ abs(fname) {
229
+ throw new Error("abs-Method not implemented.");
230
+ }
231
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
232
+ join(...paths) {
233
+ throw new Error("join-Method not implemented.");
234
+ }
235
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
236
+ relative(from, to) {
237
+ throw new Error("relative-Method not implemented.");
238
+ }
239
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
240
+ dirname(fname) {
241
+ throw new Error("dirname-Method not implemented.");
242
+ }
243
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
244
+ basename(fname) {
245
+ throw new Error("basename-Method not implemented.");
246
+ }
247
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
248
+ nodeImport(fname) {
249
+ throw new Error("nodeImport-Method not implemented.");
250
+ }
251
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
252
+ isAbsolute(fname) {
253
+ throw new Error("isAbsolute-Method not implemented.");
254
+ }
255
+ };
256
+ var WebSystemService = class {
257
+ Env() {
258
+ throw new Error("Env-Method not implemented.");
259
+ }
260
+ Args() {
261
+ throw new Error("Args-Method not implemented.");
262
+ }
263
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
264
+ OnExit(hdl) {
265
+ throw new Error("OnExit-Method not implemented.");
266
+ }
267
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
268
+ Exit(code) {
269
+ throw new Error("Exit-Method not implemented.");
270
+ }
271
+ };
272
+ var my = void 0;
273
+ function WebSysAbstraction(param) {
274
+ if (!my) {
275
+ my = new BaseSysAbstraction({
276
+ FileSystem: new WebFileService(),
277
+ SystemService: new WebSystemService()
278
+ });
279
+ }
280
+ return new WrapperSysAbstraction(my, param);
281
+ }
282
+ // Annotate the CommonJS export names for ESM import in node:
283
+ 0 && (module.exports = {
284
+ WebSysAbstraction
285
+ });
286
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/web/index.ts","../../../src/time.ts","../../../src/base_sys_abstraction.ts","../../../src/web/web_sys_abstraction.ts"],"sourcesContent":["export * from \"./web_sys_abstraction\";\n","export abstract class Time {\n abstract Now(): 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 constructor() {\n super();\n this._step = new ConstTime().Now();\n }\n Now() {\n if (this._step.getTime() === 0) {\n this._step = new ConstTime().Now();\n return this._step;\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 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 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","import { BaseSysAbstraction, WrapperSysAbstraction, WrapperSysAbstractionParams } from \"../base_sys_abstraction\";\nimport { FileService, NamedWritableStream } from \"../file_service\";\nimport { SysAbstraction, SystemService, VoidFunc } from \"../sys_abstraction\";\n\nclass WebFileService implements FileService {\n get baseDir(): string {\n throw new Error(\"basedir-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n create(fname: string): Promise<NamedWritableStream> {\n throw new Error(\"create-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n readFileString(fname: string): Promise<string> {\n throw new Error(\"readFileString-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n writeFileString(fname: string, content: string): Promise<void> {\n throw new Error(\"writeFileString-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abs(fname: string): string {\n throw new Error(\"abs-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n join(...paths: string[]): string {\n throw new Error(\"join-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n relative(from: string, to?: string | undefined): string {\n throw new Error(\"relative-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n dirname(fname: string): string {\n throw new Error(\"dirname-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n basename(fname: string): string {\n throw new Error(\"basename-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n nodeImport(fname: string): string {\n throw new Error(\"nodeImport-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n isAbsolute(fname: string): boolean {\n throw new Error(\"isAbsolute-Method not implemented.\");\n }\n}\n\nclass WebSystemService implements SystemService {\n Env(): Record<string, string> {\n throw new Error(\"Env-Method not implemented.\");\n }\n Args(): string[] {\n throw new Error(\"Args-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n OnExit(hdl: VoidFunc): VoidFunc {\n throw new Error(\"OnExit-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n Exit(code: number): void {\n throw new Error(\"Exit-Method not implemented.\");\n }\n}\n\nlet my: BaseSysAbstraction | undefined = undefined;\nexport function WebSysAbstraction(param?: WrapperSysAbstractionParams): SysAbstraction {\n if (!my) {\n my = new BaseSysAbstraction({\n FileSystem: new WebFileService(),\n SystemService: new WebSystemService(),\n });\n }\n return new WrapperSysAbstraction(my, param);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAe,OAAf,MAAoB;AAAA,EAGzB,UAAU,OAAuB;AAC/B,UAAM,MAAM,KAAK,IAAI;AACrB,WAAO,IAAI,QAAQ,IAAI,MAAM,QAAQ;AAAA,EACvC;AACF;;;ACHO,IAAM,UAAN,cAAsB,KAAK;AAAA,EAChC,M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AC/B,eAAe,IAAI,iBAAiB;AAAA,IACtC,CAAC;AAAA,EACH;AACA,SAAO,IAAI,sBAAsB,IAAI,KAAK;AAC5C;","names":[]}
@@ -0,0 +1,6 @@
1
+ import { W as WrapperSysAbstractionParams } from '../base_sys_abstraction-BYZvxqsW.cjs';
2
+ import { S as SysAbstraction } from '../sys_abstraction-CjljYIkv.cjs';
3
+
4
+ declare function WebSysAbstraction(param?: WrapperSysAbstractionParams): SysAbstraction;
5
+
6
+ export { WebSysAbstraction };
package/web/index.d.ts CHANGED
@@ -1,2 +1,6 @@
1
- export * from "./web_sys_abstraction";
2
- //# sourceMappingURL=index.d.ts.map
1
+ import { W as WrapperSysAbstractionParams } from '../base_sys_abstraction-BCdXJHNa.js';
2
+ import { S as SysAbstraction } from '../sys_abstraction-CjljYIkv.js';
3
+
4
+ declare function WebSysAbstraction(param?: WrapperSysAbstractionParams): SysAbstraction;
5
+
6
+ export { WebSysAbstraction };
package/web/index.js CHANGED
@@ -1,18 +1,9 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1
+ import {
2
+ WebSysAbstraction
3
+ } from "../chunk-MWAFFTM4.js";
4
+ import "../chunk-PZTL4UNG.js";
5
+ import "../chunk-J2IM7FHM.js";
6
+ export {
7
+ WebSysAbstraction
15
8
  };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./web_sys_abstraction"), exports);
18
9
  //# sourceMappingURL=index.js.map
package/web/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/web/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC"}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,79 +0,0 @@
1
- import { FileService } from "./file_service";
2
- import { TimeMode, RandomMode, IDMode, SystemService, VoidFunc, SysAbstraction } from "./sys_abstraction";
3
- import { Time } from "./time";
4
- export declare class SysTime extends Time {
5
- Now(): Date;
6
- Sleep(duration: number): Promise<void>;
7
- }
8
- export declare class ConstTime extends Time {
9
- Now(): Date;
10
- Sleep(duration: number): Promise<void>;
11
- }
12
- export declare class StepTime extends Time {
13
- _step: Date;
14
- constructor();
15
- Now(): Date;
16
- Sleep(duration: number): Promise<void>;
17
- }
18
- export declare function TimeFactory(timeMode: TimeMode): Time;
19
- export declare class RandomService {
20
- readonly _mode: RandomMode;
21
- _step: number;
22
- constructor(mode: RandomMode);
23
- Random0ToValue(value: number): number;
24
- }
25
- export declare class IdService {
26
- readonly _mode: IDMode;
27
- _step: number;
28
- constructor(mode?: IDMode);
29
- NextId(): string;
30
- }
31
- export interface BaseSysAbstractionParams {
32
- readonly FileSystem: FileService;
33
- readonly SystemService: SystemService;
34
- }
35
- export interface ExitHandler {
36
- readonly hdl: VoidFunc;
37
- readonly id: string;
38
- }
39
- export interface ExitService {
40
- injectExitHandlers(hdls: ExitHandler[]): void;
41
- exit(code: number): void;
42
- }
43
- export declare class BaseSysAbstraction {
44
- readonly _time: SysTime;
45
- readonly _stdout: WritableStream<any>;
46
- readonly _stderr: WritableStream<any>;
47
- readonly _idService: IdService;
48
- readonly _randomService: RandomService;
49
- readonly _fileSystem: FileService;
50
- readonly _systemService: SystemService;
51
- constructor(params: BaseSysAbstractionParams);
52
- }
53
- export interface WrapperSysAbstractionParams {
54
- readonly TimeMode?: TimeMode;
55
- readonly IdMode?: IDMode;
56
- readonly Stdout?: WritableStream<Uint8Array>;
57
- readonly Stderr?: WritableStream<Uint8Array>;
58
- readonly RandomMode?: RandomMode;
59
- readonly FileSystem?: FileService;
60
- readonly SystemService?: SystemService;
61
- }
62
- export declare class WrapperSysAbstraction implements SysAbstraction {
63
- readonly _time: Time;
64
- readonly _stdout: WritableStream<Uint8Array>;
65
- readonly _stderr: WritableStream<Uint8Array>;
66
- readonly _idService: IdService;
67
- readonly _randomService: RandomService;
68
- readonly _fileSystem: FileService;
69
- readonly _systemService: SystemService;
70
- constructor(base: BaseSysAbstraction, params?: WrapperSysAbstractionParams);
71
- Time(): Time;
72
- NextId(): string;
73
- Random0ToValue(value: number): number;
74
- Stdout(): WritableStream;
75
- Stderr(): WritableStream;
76
- System(): SystemService;
77
- FileSystem(): FileService;
78
- }
79
- //# sourceMappingURL=base_sys_abstraction.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base_sys_abstraction.d.ts","sourceRoot":"","sources":["../src/base_sys_abstraction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC1G,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,qBAAa,OAAQ,SAAQ,IAAI;IAC/B,GAAG,IAAI,IAAI;IAGX,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAOvC;AAED,qBAAa,SAAU,SAAQ,IAAI;IACjC,GAAG,IAAI,IAAI;IAIX,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGvC;AAED,qBAAa,QAAS,SAAQ,IAAI;IAChC,KAAK,EAAE,IAAI,CAAC;;IAKZ,GAAG;IAQH,KAAK,CAAC,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AE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IAC7C,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IAC7C,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;IACjC,QAAQ,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC;CACxC;AAED,qBAAa,qBAAsB,YAAW,cAAc;IAC1D,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IAC7C,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IAC7C,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,QAAQ,CAAC,cAAc,EAAE,aAAa,CAAC;IACvC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,cAAc,EAAE,aAAa,CAAC;gBAC3B,IAAI,EAAE,kBAAkB,EAAE,MAAM,CAAC,EAAE,2BAA2B;IAgC1E,IAAI,IAAI,IAAI;IAGZ,MAAM,IAAI,MAAM;IAGhB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAGrC,MAAM,IAAI,cAAc;IAGxB,MAAM,IAAI,cAAc;IAIxB,MAAM,IAAI,aAAa;IAGvB,UAAU,IAAI,WAAW;CAG1B"}
@@ -1,186 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WrapperSysAbstraction = exports.BaseSysAbstraction = exports.IdService = exports.RandomService = exports.TimeFactory = exports.StepTime = exports.ConstTime = exports.SysTime = void 0;
4
- const sys_abstraction_1 = require("./sys_abstraction");
5
- const time_1 = require("./time");
6
- class SysTime extends time_1.Time {
7
- Now() {
8
- return new Date();
9
- }
10
- Sleep(duration) {
11
- return new Promise((resolve) => {
12
- setTimeout(() => {
13
- resolve();
14
- }, duration);
15
- });
16
- }
17
- }
18
- exports.SysTime = SysTime;
19
- class ConstTime extends time_1.Time {
20
- Now() {
21
- return new Date(2021, 1, 1, 0, 0, 0, 0);
22
- }
23
- Sleep(duration) {
24
- return Promise.resolve();
25
- }
26
- }
27
- exports.ConstTime = ConstTime;
28
- class StepTime extends time_1.Time {
29
- constructor() {
30
- super();
31
- this._step = new ConstTime().Now();
32
- }
33
- Now() {
34
- if (this._step.getTime() === 0) {
35
- this._step = new ConstTime().Now();
36
- return this._step;
37
- }
38
- this._step = new Date(this._step.getTime() + 1000);
39
- return this._step;
40
- }
41
- Sleep(duration) {
42
- this._step = new Date(this._step.getTime() + duration);
43
- return Promise.resolve();
44
- }
45
- }
46
- exports.StepTime = StepTime;
47
- function TimeFactory(timeMode) {
48
- switch (timeMode) {
49
- case sys_abstraction_1.TimeMode.REAL:
50
- return new SysTime();
51
- case sys_abstraction_1.TimeMode.CONST:
52
- return new ConstTime();
53
- case sys_abstraction_1.TimeMode.STEP:
54
- return new StepTime();
55
- }
56
- return new SysTime();
57
- }
58
- exports.TimeFactory = TimeFactory;
59
- class RandomService {
60
- constructor(mode) {
61
- this._step = 0;
62
- this._mode = mode;
63
- }
64
- Random0ToValue(value) {
65
- switch (this._mode) {
66
- case sys_abstraction_1.RandomMode.CONST:
67
- return 0.5 * value;
68
- case sys_abstraction_1.RandomMode.STEP:
69
- this._step += 0.0001;
70
- return this._step * value;
71
- case sys_abstraction_1.RandomMode.RANDOM:
72
- return Math.random() * value;
73
- default:
74
- throw new Error("Unknown RandomMode");
75
- }
76
- }
77
- }
78
- exports.RandomService = RandomService;
79
- class IdService {
80
- constructor(mode) {
81
- this._step = 0;
82
- if (!mode) {
83
- mode = sys_abstraction_1.IDMode.UUID;
84
- }
85
- this._mode = mode;
86
- }
87
- NextId() {
88
- switch (this._mode) {
89
- case sys_abstraction_1.IDMode.UUID:
90
- return crypto.randomUUID();
91
- case sys_abstraction_1.IDMode.CONST:
92
- return "VeryUniqueID";
93
- case sys_abstraction_1.IDMode.STEP:
94
- return `STEPId-${this._step++}`;
95
- default:
96
- throw new Error("Unknown IDMode");
97
- }
98
- }
99
- }
100
- exports.IdService = IdService;
101
- const decoder = new TextDecoder();
102
- class BaseSysAbstraction {
103
- constructor(params) {
104
- this._time = new SysTime();
105
- this._stdout = new WritableStream({
106
- write(chunk) {
107
- return new Promise((resolve) => {
108
- const decoded = decoder.decode(chunk);
109
- console.log(decoded.trimEnd());
110
- resolve();
111
- });
112
- },
113
- });
114
- this._stderr = new WritableStream({
115
- write(chunk) {
116
- return new Promise((resolve) => {
117
- const decoded = decoder.decode(chunk);
118
- console.error(decoded.trimEnd());
119
- resolve();
120
- });
121
- },
122
- });
123
- this._idService = new IdService();
124
- this._randomService = new RandomService(sys_abstraction_1.RandomMode.RANDOM);
125
- this._fileSystem = params.FileSystem;
126
- this._systemService = params.SystemService;
127
- }
128
- }
129
- exports.BaseSysAbstraction = BaseSysAbstraction;
130
- class WrapperSysAbstraction {
131
- constructor(base, params) {
132
- this._time = base._time;
133
- this._stdout = base._stdout;
134
- this._stderr = base._stderr;
135
- this._idService = base._idService;
136
- this._randomService = base._randomService;
137
- this._fileSystem = base._fileSystem;
138
- this._systemService = base._systemService;
139
- if (params) {
140
- if (params.TimeMode) {
141
- this._time = TimeFactory(params.TimeMode);
142
- }
143
- if (params.Stdout) {
144
- this._stdout = params.Stdout;
145
- }
146
- if (params.Stderr) {
147
- this._stderr = params.Stderr;
148
- }
149
- if (params.IdMode) {
150
- this._idService = new IdService(params.IdMode);
151
- }
152
- if (params.RandomMode) {
153
- this._randomService = new RandomService(params.RandomMode);
154
- }
155
- if (params.FileSystem) {
156
- this._fileSystem = params.FileSystem;
157
- }
158
- if (params.SystemService) {
159
- this._systemService = params.SystemService;
160
- }
161
- }
162
- }
163
- Time() {
164
- return this._time;
165
- }
166
- NextId() {
167
- return this._idService.NextId();
168
- }
169
- Random0ToValue(value) {
170
- return this._randomService.Random0ToValue(value);
171
- }
172
- Stdout() {
173
- return this._stdout;
174
- }
175
- Stderr() {
176
- return this._stderr;
177
- }
178
- System() {
179
- return this._systemService;
180
- }
181
- FileSystem() {
182
- return this._fileSystem;
183
- }
184
- }
185
- exports.WrapperSysAbstraction = WrapperSysAbstraction;
186
- //# sourceMappingURL=base_sys_abstraction.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base_sys_abstraction.js","sourceRoot":"","sources":["../src/base_sys_abstraction.ts"],"names":[],"mappings":";;;AACA,uDAA0G;AAC1G,iCAA8B;AAE9B,MAAa,OAAQ,SAAQ,WAAI;IAC/B,GAAG;QACD,OAAO,IAAI,IAAI,EAAE,CAAC;IACpB,CAAC;IACD,KAAK,CAAC,QAAgB;QACpB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,UAAU,CAAC,GAAG,EAAE;gBACd,OAAO,EAAE,CAAC;YACZ,CAAC,EAAE,QAAQ,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAXD,0BAWC;AAED,MAAa,SAAU,SAAQ,WAAI;IACjC,GAAG;QACD,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,QAAgB;QACpB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CACF;AARD,8BAQC;AAED,MAAa,QAAS,SAAQ,WAAI;IAEhC;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,IAAI,SAAS,EAAE,CAAC,GAAG,EAAE,CAAC;IACrC,CAAC;IACD,GAAG;QACD,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;YAC/B,IAAI,CAAC,KAAK,GAAG,IAAI,SAAS,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oot":"","sources":["../src/base_sys_abstraction.test.ts"],"names":[],"mappings":""}