@adviser/cement 0.1.11 → 0.1.13

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 +986 -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 +610 -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
@@ -0,0 +1,21 @@
1
+ import { V as VoidFunc, T as TimeMode, I as IDMode, R as RandomMode, F as FileService, b as SystemService } from './sys_abstraction-CjljYIkv.js';
2
+
3
+ interface ExitHandler {
4
+ readonly hdl: VoidFunc;
5
+ readonly id: string;
6
+ }
7
+ interface ExitService {
8
+ injectExitHandlers(hdls: ExitHandler[]): void;
9
+ exit(code: number): void;
10
+ }
11
+ interface WrapperSysAbstractionParams {
12
+ readonly TimeMode?: TimeMode;
13
+ readonly IdMode?: IDMode;
14
+ readonly Stdout?: WritableStream<Uint8Array>;
15
+ readonly Stderr?: WritableStream<Uint8Array>;
16
+ readonly RandomMode?: RandomMode;
17
+ readonly FileSystem?: FileService;
18
+ readonly SystemService?: SystemService;
19
+ }
20
+
21
+ export type { ExitService as E, WrapperSysAbstractionParams as W, ExitHandler as a };
@@ -0,0 +1,21 @@
1
+ import { V as VoidFunc, T as TimeMode, I as IDMode, R as RandomMode, F as FileService, b as SystemService } from './sys_abstraction-CjljYIkv.cjs';
2
+
3
+ interface ExitHandler {
4
+ readonly hdl: VoidFunc;
5
+ readonly id: string;
6
+ }
7
+ interface ExitService {
8
+ injectExitHandlers(hdls: ExitHandler[]): void;
9
+ exit(code: number): void;
10
+ }
11
+ interface WrapperSysAbstractionParams {
12
+ readonly TimeMode?: TimeMode;
13
+ readonly IdMode?: IDMode;
14
+ readonly Stdout?: WritableStream<Uint8Array>;
15
+ readonly Stderr?: WritableStream<Uint8Array>;
16
+ readonly RandomMode?: RandomMode;
17
+ readonly FileSystem?: FileService;
18
+ readonly SystemService?: SystemService;
19
+ }
20
+
21
+ export type { ExitService as E, WrapperSysAbstractionParams as W, ExitHandler as a };
@@ -0,0 +1,65 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
6
+ var __typeError = (msg) => {
7
+ throw TypeError(msg);
8
+ };
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols)
15
+ for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
21
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
22
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
23
+ 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);
24
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
25
+ var __await = function(promise, isYieldStar) {
26
+ this[0] = promise;
27
+ this[1] = isYieldStar;
28
+ };
29
+ var __yieldStar = (value) => {
30
+ var obj = value[__knownSymbol("asyncIterator")], isAwait = false, method, it = {};
31
+ if (obj == null) {
32
+ obj = value[__knownSymbol("iterator")]();
33
+ method = (k) => it[k] = (x) => obj[k](x);
34
+ } else {
35
+ obj = obj.call(value);
36
+ method = (k) => it[k] = (v) => {
37
+ if (isAwait) {
38
+ isAwait = false;
39
+ if (k === "throw") throw v;
40
+ return v;
41
+ }
42
+ isAwait = true;
43
+ return {
44
+ done: false,
45
+ value: new __await(new Promise((resolve) => {
46
+ var x = obj[k](v);
47
+ if (!(x instanceof Object)) __typeError("Object expected");
48
+ resolve(x);
49
+ }), 1)
50
+ };
51
+ };
52
+ }
53
+ return it[__knownSymbol("iterator")] = () => it, method("next"), "throw" in obj ? method("throw") : it.throw = (x) => {
54
+ throw x;
55
+ }, "return" in obj && method("return"), it;
56
+ };
57
+
58
+ export {
59
+ __spreadValues,
60
+ __privateGet,
61
+ __privateAdd,
62
+ __privateSet,
63
+ __yieldStar
64
+ };
65
+ //# sourceMappingURL=chunk-J2IM7FHM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,82 @@
1
+ import {
2
+ BaseSysAbstraction,
3
+ WrapperSysAbstraction
4
+ } from "./chunk-PZTL4UNG.js";
5
+
6
+ // src/web/web_sys_abstraction.ts
7
+ var WebFileService = class {
8
+ get baseDir() {
9
+ throw new Error("basedir-Method not implemented.");
10
+ }
11
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
12
+ create(fname) {
13
+ throw new Error("create-Method not implemented.");
14
+ }
15
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
16
+ readFileString(fname) {
17
+ throw new Error("readFileString-Method not implemented.");
18
+ }
19
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
20
+ writeFileString(fname, content) {
21
+ throw new Error("writeFileString-Method not implemented.");
22
+ }
23
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
24
+ abs(fname) {
25
+ throw new Error("abs-Method not implemented.");
26
+ }
27
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
28
+ join(...paths) {
29
+ throw new Error("join-Method not implemented.");
30
+ }
31
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
32
+ relative(from, to) {
33
+ throw new Error("relative-Method not implemented.");
34
+ }
35
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
36
+ dirname(fname) {
37
+ throw new Error("dirname-Method not implemented.");
38
+ }
39
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
40
+ basename(fname) {
41
+ throw new Error("basename-Method not implemented.");
42
+ }
43
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
44
+ nodeImport(fname) {
45
+ throw new Error("nodeImport-Method not implemented.");
46
+ }
47
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
48
+ isAbsolute(fname) {
49
+ throw new Error("isAbsolute-Method not implemented.");
50
+ }
51
+ };
52
+ var WebSystemService = class {
53
+ Env() {
54
+ throw new Error("Env-Method not implemented.");
55
+ }
56
+ Args() {
57
+ throw new Error("Args-Method not implemented.");
58
+ }
59
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
60
+ OnExit(hdl) {
61
+ throw new Error("OnExit-Method not implemented.");
62
+ }
63
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
64
+ Exit(code) {
65
+ throw new Error("Exit-Method not implemented.");
66
+ }
67
+ };
68
+ var my = void 0;
69
+ function WebSysAbstraction(param) {
70
+ if (!my) {
71
+ my = new BaseSysAbstraction({
72
+ FileSystem: new WebFileService(),
73
+ SystemService: new WebSystemService()
74
+ });
75
+ }
76
+ return new WrapperSysAbstraction(my, param);
77
+ }
78
+
79
+ export {
80
+ WebSysAbstraction
81
+ };
82
+ //# sourceMappingURL=chunk-MWAFFTM4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/web/web_sys_abstraction.ts"],"sourcesContent":["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":";;;;;;AAIA,IAAM,iBAAN,MAA4C;AAAA,EAC1C,IAAI,UAAkB;AACpB,UAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AAAA;AAAA,EAEA,OAAO,OAA6C;AAClD,UAAM,IAAI,MAAM,gCAAgC;AAAA,EAClD;AAAA;AAAA,EAEA,eAAe,OAAgC;AAC7C,UAAM,IAAI,MAAM,wCAAwC;AAAA,EAC1D;AAAA;AAAA,EAEA,gBAAgB,OAAe,SAAgC;AAC7D,UAAM,IAAI,MAAM,yCAAyC;AAAA,EAC3D;AAAA;AAAA,EAEA,IAAI,OAAuB;AACzB,UAAM,IAAI,MAAM,6BAA6B;AAAA,EAC/C;AAAA;AAAA,EAEA,QAAQ,OAAyB;AAC/B,UAAM,IAAI,MAAM,8BAA8B;AAAA,EAChD;AAAA;AAAA,EAEA,SAAS,MAAc,IAAiC;AACtD,UAAM,IAAI,MAAM,kCAAkC;AAAA,EACpD;AAAA;AAAA,EAEA,QAAQ,OAAuB;AAC7B,UAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AAAA;AAAA,EAEA,SAAS,OAAuB;AAC9B,UAAM,IAAI,MAAM,kCAAkC;AAAA,EACpD;AAAA;AAAA,EAEA,WAAW,OAAuB;AAChC,UAAM,IAAI,MAAM,oCAAoC;AAAA,EACtD;AAAA;AAAA,EAEA,WAAW,OAAwB;AACjC,UAAM,IAAI,MAAM,oCAAoC;AAAA,EACtD;AACF;AAEA,IAAM,mBAAN,MAAgD;AAAA,EAC9C,MAA8B;AAC5B,UAAM,IAAI,MAAM,6BAA6B;AAAA,EAC/C;AAAA,EACA,OAAiB;AACf,UAAM,IAAI,MAAM,8BAA8B;AAAA,EAChD;AAAA;AAAA,EAEA,OAAO,KAAyB;AAC9B,UAAM,IAAI,MAAM,gCAAgC;AAAA,EAClD;AAAA;AAAA,EAEA,KAAK,MAAoB;AACvB,UAAM,IAAI,MAAM,8BAA8B;AAAA,EAChD;AACF;AAEA,IAAI,KAAqC;AAClC,SAAS,kBAAkB,OAAqD;AACrF,MAAI,CAAC,IAAI;AACP,SAAK,IAAI,mBAAmB;AAAA,MAC1B,YAAY,IAAI,eAAe;AAAA,MAC/B,eAAe,IAAI,iBAAiB;AAAA,IACtC,CAAC;AAAA,EACH;AACA,SAAO,IAAI,sBAAsB,IAAI,KAAK;AAC5C;","names":[]}
@@ -0,0 +1,233 @@
1
+ // src/sys_abstraction.ts
2
+ var TimeMode = /* @__PURE__ */ ((TimeMode2) => {
3
+ TimeMode2["REAL"] = "real";
4
+ TimeMode2["CONST"] = "const";
5
+ TimeMode2["STEP"] = "step";
6
+ return TimeMode2;
7
+ })(TimeMode || {});
8
+ var RandomMode = /* @__PURE__ */ ((RandomMode2) => {
9
+ RandomMode2["CONST"] = "const";
10
+ RandomMode2["STEP"] = "step";
11
+ RandomMode2["RANDOM"] = "random";
12
+ return RandomMode2;
13
+ })(RandomMode || {});
14
+ var IDMode = /* @__PURE__ */ ((IDMode2) => {
15
+ IDMode2["UUID"] = "uuid";
16
+ IDMode2["CONST"] = "const";
17
+ IDMode2["STEP"] = "step";
18
+ return IDMode2;
19
+ })(IDMode || {});
20
+ function String2TimeMode(s) {
21
+ switch (s == null ? void 0 : s.toLowerCase()) {
22
+ case "real":
23
+ return "real" /* REAL */;
24
+ case "const":
25
+ return "const" /* CONST */;
26
+ case "step":
27
+ return "step" /* STEP */;
28
+ default:
29
+ return "real" /* REAL */;
30
+ }
31
+ }
32
+
33
+ // src/time.ts
34
+ var Time = class {
35
+ TimeSince(start) {
36
+ const now = this.Now();
37
+ return now.getTime() - start.getTime();
38
+ }
39
+ };
40
+ var TimeUnits = /* @__PURE__ */ ((TimeUnits2) => {
41
+ TimeUnits2[TimeUnits2["Microsecond"] = 1] = "Microsecond";
42
+ TimeUnits2[TimeUnits2["Second"] = 1e3] = "Second";
43
+ TimeUnits2[TimeUnits2["Minute"] = 6e4] = "Minute";
44
+ TimeUnits2[TimeUnits2["Hour"] = 36e5] = "Hour";
45
+ return TimeUnits2;
46
+ })(TimeUnits || {});
47
+
48
+ // src/base_sys_abstraction.ts
49
+ var SysTime = class extends Time {
50
+ Now() {
51
+ return /* @__PURE__ */ new Date();
52
+ }
53
+ Sleep(duration) {
54
+ return new Promise((resolve) => {
55
+ setTimeout(() => {
56
+ resolve();
57
+ }, duration);
58
+ });
59
+ }
60
+ };
61
+ var ConstTime = class extends Time {
62
+ Now() {
63
+ return new Date(2021, 1, 1, 0, 0, 0, 0);
64
+ }
65
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
66
+ Sleep(duration) {
67
+ return Promise.resolve();
68
+ }
69
+ };
70
+ var StepTime = class extends Time {
71
+ constructor() {
72
+ super();
73
+ this._step = new ConstTime().Now();
74
+ }
75
+ Now() {
76
+ if (this._step.getTime() === 0) {
77
+ this._step = new ConstTime().Now();
78
+ return this._step;
79
+ }
80
+ this._step = new Date(this._step.getTime() + 1e3);
81
+ return this._step;
82
+ }
83
+ Sleep(duration) {
84
+ this._step = new Date(this._step.getTime() + duration);
85
+ return Promise.resolve();
86
+ }
87
+ };
88
+ function TimeFactory(timeMode) {
89
+ switch (timeMode) {
90
+ case "real" /* REAL */:
91
+ return new SysTime();
92
+ case "const" /* CONST */:
93
+ return new ConstTime();
94
+ case "step" /* STEP */:
95
+ return new StepTime();
96
+ }
97
+ return new SysTime();
98
+ }
99
+ var RandomService = class {
100
+ constructor(mode) {
101
+ this._step = 0;
102
+ this._mode = mode;
103
+ }
104
+ Random0ToValue(value) {
105
+ switch (this._mode) {
106
+ case "const" /* CONST */:
107
+ return 0.5 * value;
108
+ case "step" /* STEP */:
109
+ this._step += 1e-4;
110
+ return this._step * value;
111
+ case "random" /* RANDOM */:
112
+ return Math.random() * value;
113
+ default:
114
+ throw new Error("Unknown RandomMode");
115
+ }
116
+ }
117
+ };
118
+ var IdService = class {
119
+ constructor(mode) {
120
+ this._step = 0;
121
+ if (!mode) {
122
+ mode = "uuid" /* UUID */;
123
+ }
124
+ this._mode = mode;
125
+ }
126
+ NextId() {
127
+ switch (this._mode) {
128
+ case "uuid" /* UUID */:
129
+ return crypto.randomUUID();
130
+ case "const" /* CONST */:
131
+ return "VeryUniqueID";
132
+ case "step" /* STEP */:
133
+ return `STEPId-${this._step++}`;
134
+ default:
135
+ throw new Error("Unknown IDMode");
136
+ }
137
+ }
138
+ };
139
+ var decoder = new TextDecoder();
140
+ var BaseSysAbstraction = class {
141
+ constructor(params) {
142
+ this._time = new SysTime();
143
+ this._stdout = new WritableStream({
144
+ write(chunk) {
145
+ return new Promise((resolve) => {
146
+ const decoded = decoder.decode(chunk);
147
+ console.log(decoded.trimEnd());
148
+ resolve();
149
+ });
150
+ }
151
+ });
152
+ this._stderr = new WritableStream({
153
+ write(chunk) {
154
+ return new Promise((resolve) => {
155
+ const decoded = decoder.decode(chunk);
156
+ console.error(decoded.trimEnd());
157
+ resolve();
158
+ });
159
+ }
160
+ });
161
+ this._idService = new IdService();
162
+ this._randomService = new RandomService("random" /* RANDOM */);
163
+ this._fileSystem = params.FileSystem;
164
+ this._systemService = params.SystemService;
165
+ }
166
+ };
167
+ var WrapperSysAbstraction = class {
168
+ constructor(base, params) {
169
+ this._time = base._time;
170
+ this._stdout = base._stdout;
171
+ this._stderr = base._stderr;
172
+ this._idService = base._idService;
173
+ this._randomService = base._randomService;
174
+ this._fileSystem = base._fileSystem;
175
+ this._systemService = base._systemService;
176
+ if (params) {
177
+ if (params.TimeMode) {
178
+ this._time = TimeFactory(params.TimeMode);
179
+ }
180
+ if (params.Stdout) {
181
+ this._stdout = params.Stdout;
182
+ }
183
+ if (params.Stderr) {
184
+ this._stderr = params.Stderr;
185
+ }
186
+ if (params.IdMode) {
187
+ this._idService = new IdService(params.IdMode);
188
+ }
189
+ if (params.RandomMode) {
190
+ this._randomService = new RandomService(params.RandomMode);
191
+ }
192
+ if (params.FileSystem) {
193
+ this._fileSystem = params.FileSystem;
194
+ }
195
+ if (params.SystemService) {
196
+ this._systemService = params.SystemService;
197
+ }
198
+ }
199
+ }
200
+ Time() {
201
+ return this._time;
202
+ }
203
+ NextId() {
204
+ return this._idService.NextId();
205
+ }
206
+ Random0ToValue(value) {
207
+ return this._randomService.Random0ToValue(value);
208
+ }
209
+ Stdout() {
210
+ return this._stdout;
211
+ }
212
+ Stderr() {
213
+ return this._stderr;
214
+ }
215
+ System() {
216
+ return this._systemService;
217
+ }
218
+ FileSystem() {
219
+ return this._fileSystem;
220
+ }
221
+ };
222
+
223
+ export {
224
+ TimeMode,
225
+ RandomMode,
226
+ IDMode,
227
+ String2TimeMode,
228
+ Time,
229
+ TimeUnits,
230
+ BaseSysAbstraction,
231
+ WrapperSysAbstraction
232
+ };
233
+ //# sourceMappingURL=chunk-PZTL4UNG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/sys_abstraction.ts","../../src/time.ts","../../src/base_sys_abstraction.ts"],"sourcesContent":["import { FileService } from \"./file_service\";\nimport { Time } from \"./time\";\n\nexport enum TimeMode {\n REAL = \"real\",\n CONST = \"const\",\n STEP = \"step\",\n}\n\nexport enum RandomMode {\n CONST = \"const\",\n STEP = \"step\",\n RANDOM = \"random\",\n}\n\nexport enum IDMode {\n UUID = \"uuid\",\n CONST = \"const\",\n STEP = \"step\",\n}\n\nexport function String2TimeMode(s?: string): TimeMode {\n switch (s?.toLowerCase()) {\n case \"real\":\n return TimeMode.REAL;\n case \"const\":\n return TimeMode.CONST;\n case \"step\":\n return TimeMode.STEP;\n default:\n return TimeMode.REAL;\n }\n}\n\nexport type VoidFunc = () => void | Promise<void>;\n\nexport interface SystemService {\n Env(): Record<string, string>;\n Args(): string[];\n OnExit(hdl: VoidFunc): VoidFunc;\n Exit(code: number): void;\n}\n\nexport interface SysAbstraction {\n Time(): Time;\n Stdout(): WritableStream<Uint8Array>;\n Stderr(): WritableStream<Uint8Array>;\n NextId(): string;\n Random0ToValue(value: number): number;\n System(): SystemService;\n FileSystem(): FileService;\n}\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"],"mappings":";AAGO,IAAK,WAAL,kBAAKA,cAAL;AACL,EAAAA,UAAA,UAAO;AACP,EAAAA,UAAA,WAAQ;AACR,EAAAA,UAAA,UAAO;AAHG,SAAAA;AAAA,GAAA;AAML,IAAK,aAAL,kBAAKC,gBAAL;AACL,EAAAA,YAAA,WAAQ;AACR,EAAAA,YAAA,UAAO;AACP,EAAAA,YAAA,YAAS;AAHC,SAAAA;AAAA,GAAA;AAML,IAAK,SAAL,kBAAKC,YAAL;AACL,EAAAA,QAAA,UAAO;AACP,EAAAA,QAAA,WAAQ;AACR,EAAAA,QAAA,UAAO;AAHG,SAAAA;AAAA,GAAA;AAML,SAAS,gBAAgB,GAAsB;AACpD,UAAQ,uBAAG,eAAe;AAAA,IACxB,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;;;AChCO,IAAe,OAAf,MAAoB;AAAA,EAGzB,UAAU,OAAuB;AAC/B,UAAM,MAAM,KAAK,IAAI;AACrB,WAAO,IAAI,QAAQ,IAAI,MAAM,QAAQ;AAAA,EACvC;AACF;AAIO,IAAK,YAAL,kBAAKC,eAAL;AACL,EAAAA,sBAAA,iBAAc,KAAd;AAEA,EAAAA,sBAAA,YAAS,OAAT;AAEA,EAAAA,sBAAA,YAAS,OAAT;AAEA,EAAAA,sBAAA,UAAO,QAAP;AAPU,SAAAA;AAAA,GAAA;;;ACPL,IAAM,UAAN,cAAsB,KAAK;AAAA,EAChC,MAAY;AACV,WAAO,oBAAI,KAAK;AAAA,EAClB;AAAA,EACA,MAAM,UAAiC;AACr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