@adviser/cement 0.3.20 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/base-sys-abstraction-DgTynXGV.d.cts +95 -0
  2. package/base-sys-abstraction-h0dB3nZ5.d.ts +95 -0
  3. package/cf/index.cjs +232 -283
  4. package/cf/index.cjs.map +1 -1
  5. package/cf/index.d.cts +10 -8
  6. package/cf/index.d.ts +10 -8
  7. package/cf/index.js +6 -41
  8. package/cf/index.js.map +1 -1
  9. package/{chunk-PHS255C5.js → chunk-FOALXQST.js} +1 -68
  10. package/chunk-FOALXQST.js.map +1 -0
  11. package/{chunk-UEER5ZC2.js → chunk-NPMIRK4R.js} +8 -22
  12. package/chunk-NPMIRK4R.js.map +1 -0
  13. package/{chunk-23MCJYE6.js → chunk-X3IV2RYT.js} +422 -602
  14. package/chunk-X3IV2RYT.js.map +1 -0
  15. package/chunk-YKGCONBX.js +677 -0
  16. package/chunk-YKGCONBX.js.map +1 -0
  17. package/{chunk-55W4AK2Z.js → chunk-YVACAIUX.js} +5 -5
  18. package/deno/index.cjs +257 -241
  19. package/deno/index.cjs.map +1 -1
  20. package/deno/index.d.cts +3 -5
  21. package/deno/index.d.ts +3 -5
  22. package/deno/index.js +14 -16
  23. package/deno/index.js.map +1 -1
  24. package/{index-BhmvYS_t.d.ts → index-N0bkrgSt.d.ts} +2 -2
  25. package/{index-DoK1OTgQ.d.cts → index-TtYD7HhB.d.cts} +2 -2
  26. package/index.cjs +1935 -1806
  27. package/index.cjs.map +1 -1
  28. package/index.d.cts +15 -8
  29. package/index.d.ts +15 -8
  30. package/index.js +58 -16
  31. package/index.js.map +1 -1
  32. package/metafile-cjs.json +1 -1
  33. package/metafile-esm.json +1 -1
  34. package/node/index.cjs +499 -474
  35. package/node/index.cjs.map +1 -1
  36. package/node/index.d.cts +3 -5
  37. package/node/index.d.ts +3 -5
  38. package/node/index.js +14 -16
  39. package/node/index.js.map +1 -1
  40. package/package.json +5 -5
  41. package/src/base-sys-abstraction.ts +106 -116
  42. package/src/cf/cf-basic-sys-abstraction.ts +79 -0
  43. package/src/cf/index.ts +1 -1
  44. package/src/cf-test-main.ts +10 -1
  45. package/src/coerce-binary.ts +39 -0
  46. package/src/deno/deno-basic-sys-abstraction.ts +39 -0
  47. package/src/deno/deno-file-service.ts +1 -1
  48. package/src/deno/deno-sys-abstraction.ts +19 -22
  49. package/src/index.ts +1 -0
  50. package/src/jsr.json +1 -1
  51. package/src/log-writer-impl.ts +6 -0
  52. package/src/logger-impl.ts +18 -20
  53. package/src/node/node-basic-sys-abstraction.ts +59 -0
  54. package/src/node/node-sys-abstraction.ts +19 -22
  55. package/src/sys-abstraction.ts +12 -6
  56. package/src/test/mock-logger.ts +2 -2
  57. package/src/txt-en-decoder.ts +3 -3
  58. package/src/web/index.ts +1 -1
  59. package/src/web/web-basic-sys-abstraction.ts +105 -0
  60. package/{sys-abstraction-B0x6IE7r.d.ts → sys-abstraction-CeAxxg9H.d.ts} +11 -7
  61. package/{sys-abstraction-BTs3Vzy4.d.cts → sys-abstraction-DDAwGTnk.d.cts} +11 -7
  62. package/test/index.cjs +1146 -1085
  63. package/test/index.cjs.map +1 -1
  64. package/test/index.d.cts +2 -2
  65. package/test/index.d.ts +2 -2
  66. package/test/index.js +4 -5
  67. package/ts/smoke/smoke.js +7 -8
  68. package/ts/smoke/smoke.js.map +1 -1
  69. package/ts/src/base-basic-sys-abstraction.test.d.ts +2 -0
  70. package/ts/src/base-basic-sys-abstraction.test.d.ts.map +1 -0
  71. package/ts/src/{base-sys-abstraction.test.js → base-basic-sys-abstraction.test.js} +9 -9
  72. package/ts/src/base-basic-sys-abstraction.test.js.map +1 -0
  73. package/ts/src/base-sys-abstraction.d.ts +33 -21
  74. package/ts/src/base-sys-abstraction.d.ts.map +1 -1
  75. package/ts/src/base-sys-abstraction.js +54 -67
  76. package/ts/src/base-sys-abstraction.js.map +1 -1
  77. package/ts/src/cf/cf-basic-sys-abstraction.d.ts +14 -0
  78. package/ts/src/cf/cf-basic-sys-abstraction.d.ts.map +1 -0
  79. package/ts/src/cf/cf-basic-sys-abstraction.js +67 -0
  80. package/ts/src/cf/cf-basic-sys-abstraction.js.map +1 -0
  81. package/ts/src/cf/index.d.ts +1 -1
  82. package/ts/src/cf/index.d.ts.map +1 -1
  83. package/ts/src/cf/index.js +1 -1
  84. package/ts/src/cf/index.js.map +1 -1
  85. package/ts/src/cf-test-main.d.ts.map +1 -1
  86. package/ts/src/cf-test-main.js +7 -1
  87. package/ts/src/cf-test-main.js.map +1 -1
  88. package/ts/src/coerce-binary.d.ts +6 -0
  89. package/ts/src/coerce-binary.d.ts.map +1 -0
  90. package/ts/src/coerce-binary.js +32 -0
  91. package/ts/src/coerce-binary.js.map +1 -0
  92. package/ts/src/coerce-binary.test.d.ts +2 -0
  93. package/ts/src/coerce-binary.test.d.ts.map +1 -0
  94. package/ts/src/coerce-binary.test.js +39 -0
  95. package/ts/src/coerce-binary.test.js.map +1 -0
  96. package/ts/src/deno/deno-basic-sys-abstraction.d.ts +14 -0
  97. package/ts/src/deno/deno-basic-sys-abstraction.d.ts.map +1 -0
  98. package/ts/src/deno/deno-basic-sys-abstraction.js +35 -0
  99. package/ts/src/deno/deno-basic-sys-abstraction.js.map +1 -0
  100. package/ts/src/deno/deno-file-service.d.ts +1 -1
  101. package/ts/src/deno/deno-file-service.d.ts.map +1 -1
  102. package/ts/src/deno/deno-sys-abstraction.d.ts +3 -6
  103. package/ts/src/deno/deno-sys-abstraction.d.ts.map +1 -1
  104. package/ts/src/deno/deno-sys-abstraction.js +13 -17
  105. package/ts/src/deno/deno-sys-abstraction.js.map +1 -1
  106. package/ts/src/index.d.ts +1 -0
  107. package/ts/src/index.d.ts.map +1 -1
  108. package/ts/src/index.js +1 -0
  109. package/ts/src/index.js.map +1 -1
  110. package/ts/src/log-writer-impl.d.ts +1 -0
  111. package/ts/src/log-writer-impl.d.ts.map +1 -1
  112. package/ts/src/log-writer-impl.js +1 -0
  113. package/ts/src/log-writer-impl.js.map +1 -1
  114. package/ts/src/logger-impl.d.ts +4 -4
  115. package/ts/src/logger-impl.d.ts.map +1 -1
  116. package/ts/src/logger-impl.js +4 -19
  117. package/ts/src/logger-impl.js.map +1 -1
  118. package/ts/src/logger.test.js +3 -4
  119. package/ts/src/logger.test.js.map +1 -1
  120. package/ts/src/node/node-basic-sys-abstraction.d.ts +25 -0
  121. package/ts/src/node/node-basic-sys-abstraction.d.ts.map +1 -0
  122. package/ts/src/node/node-basic-sys-abstraction.js +44 -0
  123. package/ts/src/node/node-basic-sys-abstraction.js.map +1 -0
  124. package/ts/src/node/node-sys-abstraction.d.ts +3 -6
  125. package/ts/src/node/node-sys-abstraction.d.ts.map +1 -1
  126. package/ts/src/node/node-sys-abstraction.js +13 -17
  127. package/ts/src/node/node-sys-abstraction.js.map +1 -1
  128. package/ts/src/node/node-sys-abstraction.test.js +1 -1
  129. package/ts/src/node/node-sys-abstraction.test.js.map +1 -1
  130. package/ts/src/sys-abstraction.d.ts +10 -6
  131. package/ts/src/sys-abstraction.d.ts.map +1 -1
  132. package/ts/src/test/mock-logger.d.ts +2 -2
  133. package/ts/src/test/mock-logger.d.ts.map +1 -1
  134. package/ts/src/test/mock-logger.js.map +1 -1
  135. package/ts/src/tracer.test.js +5 -8
  136. package/ts/src/tracer.test.js.map +1 -1
  137. package/ts/src/txt-en-decoder.d.ts.map +1 -1
  138. package/ts/src/txt-en-decoder.js +3 -3
  139. package/ts/src/txt-en-decoder.js.map +1 -1
  140. package/ts/src/web/index.d.ts +1 -1
  141. package/ts/src/web/index.d.ts.map +1 -1
  142. package/ts/src/web/index.js +1 -1
  143. package/ts/src/web/index.js.map +1 -1
  144. package/ts/src/web/web-basic-sys-abstraction.d.ts +4 -0
  145. package/ts/src/web/web-basic-sys-abstraction.d.ts.map +1 -0
  146. package/ts/src/web/web-basic-sys-abstraction.js +45 -0
  147. package/ts/src/web/web-basic-sys-abstraction.js.map +1 -0
  148. package/utils/index.cjs +132 -3
  149. package/utils/index.cjs.map +1 -1
  150. package/utils/index.js +5 -5
  151. package/web/index.cjs +277 -281
  152. package/web/index.cjs.map +1 -1
  153. package/web/index.d.cts +4 -17
  154. package/web/index.d.ts +4 -17
  155. package/web/index.js +4 -7
  156. package/base-sys-abstraction-BnBZ6zd0.d.ts +0 -84
  157. package/base-sys-abstraction-DAZ8tx5F.d.cts +0 -84
  158. package/chunk-23MCJYE6.js.map +0 -1
  159. package/chunk-H6MLKWIZ.js +0 -88
  160. package/chunk-H6MLKWIZ.js.map +0 -1
  161. package/chunk-LXTKPZ6M.js +0 -255
  162. package/chunk-LXTKPZ6M.js.map +0 -1
  163. package/chunk-PHS255C5.js.map +0 -1
  164. package/chunk-UEER5ZC2.js.map +0 -1
  165. package/src/cf/cf-sys-abstraction.ts +0 -34
  166. package/src/web/web-sys-abstraction.ts +0 -80
  167. package/ts/src/base-sys-abstraction.test.d.ts +0 -2
  168. package/ts/src/base-sys-abstraction.test.d.ts.map +0 -1
  169. package/ts/src/base-sys-abstraction.test.js.map +0 -1
  170. package/ts/src/cf/cf-sys-abstraction.d.ts +0 -11
  171. package/ts/src/cf/cf-sys-abstraction.d.ts.map +0 -1
  172. package/ts/src/cf/cf-sys-abstraction.js +0 -30
  173. package/ts/src/cf/cf-sys-abstraction.js.map +0 -1
  174. package/ts/src/web/web-sys-abstraction.d.ts +0 -18
  175. package/ts/src/web/web-sys-abstraction.d.ts.map +0 -1
  176. package/ts/src/web/web-sys-abstraction.js +0 -64
  177. package/ts/src/web/web-sys-abstraction.js.map +0 -1
  178. /package/{chunk-55W4AK2Z.js.map → chunk-YVACAIUX.js.map} +0 -0
package/web/index.cjs CHANGED
@@ -27,11 +27,47 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
27
27
  // src/web/index.ts
28
28
  var web_exports = {};
29
29
  __export(web_exports, {
30
- WebFileService: () => WebFileService,
31
- WebSysAbstraction: () => WebSysAbstraction
30
+ WebBasicSysAbstraction: () => WebBasicSysAbstraction
32
31
  });
33
32
  module.exports = __toCommonJS(web_exports);
34
33
 
34
+ // src/runtime.ts
35
+ function isSet(value, ref = globalThis) {
36
+ const [head, ...tail] = value.split(".");
37
+ if (["object", "function"].includes(typeof ref) && ref && ["object", "function"].includes(typeof ref[head]) && ref[head]) {
38
+ if (tail.length <= 1) {
39
+ return true;
40
+ }
41
+ return isSet(tail.join("."), ref[head]);
42
+ }
43
+ return false;
44
+ }
45
+ function runtimeFn() {
46
+ const gt = globalThis;
47
+ let isReactNative = (
48
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
49
+ isSet("navigator.product") && typeof gt["navigator"] === "object" && gt["navigator"]["product"] === "ReactNative"
50
+ );
51
+ let isNodeIsh = false;
52
+ if (!isSet("Deno")) {
53
+ isNodeIsh = isSet("process.versions.node") && !isReactNative;
54
+ }
55
+ let isDeno = isSet("Deno");
56
+ const isCFWorker = isSet("caches.default") && isSet("WebSocketPair");
57
+ if (isCFWorker) {
58
+ isDeno = false;
59
+ isNodeIsh = false;
60
+ isReactNative = false;
61
+ }
62
+ return {
63
+ isNodeIsh,
64
+ isBrowser: !(isNodeIsh || isDeno || isCFWorker || isReactNative),
65
+ isDeno,
66
+ isReactNative,
67
+ isCFWorker
68
+ };
69
+ }
70
+
35
71
  // src/sys-abstraction.ts
36
72
  var TimeMode = {
37
73
  REAL: "real",
@@ -66,195 +102,6 @@ var TimeUnits = {
66
102
  // Minute,
67
103
  };
68
104
 
69
- // src/base-sys-abstraction.ts
70
- var SysTime = class extends Time {
71
- Now() {
72
- return /* @__PURE__ */ new Date();
73
- }
74
- Sleep(duration) {
75
- return new Promise((resolve) => {
76
- setTimeout(() => {
77
- resolve();
78
- }, duration);
79
- });
80
- }
81
- };
82
- var ConstTime = class extends Time {
83
- Now() {
84
- return new Date(2021, 1, 1, 0, 0, 0, 0);
85
- }
86
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
87
- Sleep(duration) {
88
- return Promise.resolve();
89
- }
90
- };
91
- var StepTime = class extends Time {
92
- constructor() {
93
- super();
94
- this._step = new ConstTime().Now();
95
- this._start = this._step;
96
- }
97
- Now(steps = 1) {
98
- for (let i = 0; steps > 0 && i < steps; i++) {
99
- this._step = new Date(this._step.getTime() + 1e3);
100
- }
101
- if (steps < 1) {
102
- this._step = new Date(this._start.getTime() + steps * -1e3);
103
- }
104
- return this._step;
105
- }
106
- Sleep(duration) {
107
- this._step = new Date(this._step.getTime() + duration);
108
- return Promise.resolve();
109
- }
110
- };
111
- function TimeFactory(timeMode) {
112
- switch (timeMode) {
113
- case TimeMode.REAL:
114
- return new SysTime();
115
- case TimeMode.CONST:
116
- return new ConstTime();
117
- case TimeMode.STEP:
118
- return new StepTime();
119
- }
120
- return new SysTime();
121
- }
122
- var RandomService = class {
123
- constructor(mode) {
124
- this._step = 0;
125
- this._mode = mode;
126
- }
127
- Random0ToValue(value) {
128
- switch (this._mode) {
129
- case RandomMode.CONST:
130
- return 0.5 * value;
131
- case RandomMode.STEP:
132
- this._step += 1e-4;
133
- return this._step * value;
134
- case RandomMode.RANDOM:
135
- return Math.random() * value;
136
- default:
137
- throw new Error("Unknown RandomMode");
138
- }
139
- }
140
- };
141
- var IdService = class {
142
- constructor(mode) {
143
- this._step = 0;
144
- if (!mode) {
145
- mode = IDMode.UUID;
146
- }
147
- this._mode = mode;
148
- }
149
- NextId() {
150
- switch (this._mode) {
151
- case IDMode.UUID:
152
- return crypto.randomUUID();
153
- case IDMode.CONST:
154
- return "VeryUniqueID";
155
- case IDMode.STEP:
156
- return `STEPId-${this._step++}`;
157
- default:
158
- throw new Error("Unknown IDMode");
159
- }
160
- }
161
- };
162
- function consumeReadableStream(reader, writeFn) {
163
- reader.read().then(({ done, value }) => {
164
- if (done) {
165
- return;
166
- }
167
- writeFn(value).then(() => {
168
- consumeReadableStream(reader, writeFn);
169
- }).catch((e) => {
170
- console.error("consumeReadableStream:writeFn", e);
171
- });
172
- }).catch((e) => {
173
- console.error("consumeReadableStream:read", e);
174
- });
175
- }
176
- function CFWriteableStream(writeFn) {
177
- const ts = new TransformStream();
178
- consumeReadableStream(ts.readable.getReader(), writeFn);
179
- return ts.writable;
180
- }
181
- var BaseSysAbstraction = class {
182
- constructor(params) {
183
- this._time = new SysTime();
184
- this._idService = new IdService();
185
- this._randomService = new RandomService(RandomMode.RANDOM);
186
- this._fileSystem = params.FileSystem;
187
- this._systemService = params.SystemService;
188
- this._txtEnDe = params.TxtEnDecoder;
189
- const decoder = this._txtEnDe;
190
- this._stdout = CFWriteableStream((chunk) => {
191
- const decoded = decoder.decode(chunk);
192
- console.log(decoded.trimEnd());
193
- return Promise.resolve();
194
- });
195
- this._stderr = CFWriteableStream((chunk) => {
196
- const decoded = decoder.decode(chunk);
197
- console.error(decoded.trimEnd());
198
- return Promise.resolve();
199
- });
200
- }
201
- };
202
- var WrapperSysAbstraction = class {
203
- constructor(base, params) {
204
- this._time = base._time;
205
- this._stdout = base._stdout;
206
- this._stderr = base._stderr;
207
- this._idService = base._idService;
208
- this._randomService = base._randomService;
209
- this._fileSystem = base._fileSystem;
210
- this._systemService = base._systemService;
211
- if (params) {
212
- if (params.TimeMode) {
213
- this._time = TimeFactory(params.TimeMode);
214
- }
215
- if (params.Stdout) {
216
- this._stdout = params.Stdout;
217
- }
218
- if (params.Stderr) {
219
- this._stderr = params.Stderr;
220
- }
221
- if (params.IdMode) {
222
- this._idService = new IdService(params.IdMode);
223
- }
224
- if (params.RandomMode) {
225
- this._randomService = new RandomService(params.RandomMode);
226
- }
227
- if (params.FileSystem) {
228
- this._fileSystem = params.FileSystem;
229
- }
230
- if (params.SystemService) {
231
- this._systemService = params.SystemService;
232
- }
233
- }
234
- }
235
- Time() {
236
- return this._time;
237
- }
238
- NextId() {
239
- return this._idService.NextId();
240
- }
241
- Random0ToValue(value) {
242
- return this._randomService.Random0ToValue(value);
243
- }
244
- Stdout() {
245
- return this._stdout;
246
- }
247
- Stderr() {
248
- return this._stderr;
249
- }
250
- System() {
251
- return this._systemService;
252
- }
253
- FileSystem() {
254
- return this._fileSystem;
255
- }
256
- };
257
-
258
105
  // src/future.ts
259
106
  var _promise, _resolveFn, _rejectFn;
260
107
  var Future = class {
@@ -611,43 +458,6 @@ var KeyedResolvOnce = class extends Keyed {
611
458
  }
612
459
  };
613
460
 
614
- // src/runtime.ts
615
- function isSet(value, ref = globalThis) {
616
- const [head, ...tail] = value.split(".");
617
- if (["object", "function"].includes(typeof ref) && ref && ["object", "function"].includes(typeof ref[head]) && ref[head]) {
618
- if (tail.length <= 1) {
619
- return true;
620
- }
621
- return isSet(tail.join("."), ref[head]);
622
- }
623
- return false;
624
- }
625
- function runtimeFn() {
626
- const gt = globalThis;
627
- let isReactNative = (
628
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
629
- isSet("navigator.product") && typeof gt["navigator"] === "object" && gt["navigator"]["product"] === "ReactNative"
630
- );
631
- let isNodeIsh = false;
632
- if (!isSet("Deno")) {
633
- isNodeIsh = isSet("process.versions.node") && !isReactNative;
634
- }
635
- let isDeno = isSet("Deno");
636
- const isCFWorker = isSet("caches.default") && isSet("WebSocketPair");
637
- if (isCFWorker) {
638
- isDeno = false;
639
- isNodeIsh = false;
640
- isReactNative = false;
641
- }
642
- return {
643
- isNodeIsh,
644
- isBrowser: !(isNodeIsh || isDeno || isCFWorker || isReactNative),
645
- isDeno,
646
- isReactNative,
647
- isCFWorker
648
- };
649
- }
650
-
651
461
  // src/deno/deno-env-actions.ts
652
462
  var once = new ResolveOnce();
653
463
  var _deno;
@@ -1070,88 +880,274 @@ var TxtOps = class {
1070
880
  return this.decode(resolved);
1071
881
  }
1072
882
  };
1073
- var txtEnDecoder;
883
+ var txtEnDecoder = new ResolveOnce();
1074
884
  function TxtEnDecoderSingleton() {
1075
- txtEnDecoder = txtEnDecoder != null ? txtEnDecoder : new TxtOps();
1076
- return txtEnDecoder;
885
+ return txtEnDecoder.once(() => new TxtOps());
1077
886
  }
1078
887
 
1079
- // src/web/web-sys-abstraction.ts
1080
- var WebFileService = class {
1081
- get baseDir() {
1082
- throw new Error("basedir-Method not implemented.");
888
+ // src/cf/cf-basic-sys-abstraction.ts
889
+ var baseSysAbstraction = new ResolveOnce();
890
+
891
+ // src/deno/deno-basic-sys-abstraction.ts
892
+ var baseSysAbstraction2 = new ResolveOnce();
893
+
894
+ // src/node/node-basic-sys-abstraction.ts
895
+ var baseSysAbstraction3 = new ResolveOnce();
896
+
897
+ // src/base-sys-abstraction.ts
898
+ var SysTime = class extends Time {
899
+ Now() {
900
+ return /* @__PURE__ */ new Date();
1083
901
  }
1084
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1085
- create(fname) {
1086
- throw new Error("create-Method not implemented.");
902
+ Sleep(duration) {
903
+ return new Promise((resolve) => {
904
+ setTimeout(() => {
905
+ resolve();
906
+ }, duration);
907
+ });
1087
908
  }
1088
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1089
- readFileString(fname) {
1090
- throw new Error("readFileString-Method not implemented.");
909
+ };
910
+ var ConstTime = class extends Time {
911
+ Now() {
912
+ return new Date(2021, 1, 1, 0, 0, 0, 0);
1091
913
  }
1092
914
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
1093
- writeFileString(fname, content) {
1094
- throw new Error("writeFileString-Method not implemented.");
915
+ Sleep(duration) {
916
+ return Promise.resolve();
1095
917
  }
1096
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1097
- abs(fname) {
1098
- throw new Error("abs-Method not implemented.");
918
+ };
919
+ var StepTime = class extends Time {
920
+ constructor() {
921
+ super();
922
+ this._step = new ConstTime().Now();
923
+ this._start = this._step;
1099
924
  }
1100
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1101
- join(...paths) {
1102
- throw new Error("join-Method not implemented.");
925
+ Now(steps = 1) {
926
+ for (let i = 0; steps > 0 && i < steps; i++) {
927
+ this._step = new Date(this._step.getTime() + 1e3);
928
+ }
929
+ if (steps < 1) {
930
+ this._step = new Date(this._start.getTime() + steps * -1e3);
931
+ }
932
+ return this._step;
1103
933
  }
1104
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1105
- relative(from, to) {
1106
- throw new Error("relative-Method not implemented.");
934
+ Sleep(duration) {
935
+ this._step = new Date(this._step.getTime() + duration);
936
+ return Promise.resolve();
1107
937
  }
1108
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1109
- dirname(fname) {
1110
- throw new Error("dirname-Method not implemented.");
938
+ };
939
+ function TimeFactory(timeMode) {
940
+ switch (timeMode) {
941
+ case TimeMode.REAL:
942
+ return new SysTime();
943
+ case TimeMode.CONST:
944
+ return new ConstTime();
945
+ case TimeMode.STEP:
946
+ return new StepTime();
1111
947
  }
1112
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1113
- basename(fname) {
1114
- throw new Error("basename-Method not implemented.");
948
+ return new SysTime();
949
+ }
950
+ var RandomService = class {
951
+ constructor(mode) {
952
+ this._step = 0;
953
+ this._mode = mode;
1115
954
  }
1116
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1117
- nodeImport(fname) {
1118
- throw new Error("nodeImport-Method not implemented.");
955
+ Random0ToValue(value) {
956
+ switch (this._mode) {
957
+ case RandomMode.CONST:
958
+ return 0.5 * value;
959
+ case RandomMode.STEP:
960
+ this._step += 1e-4;
961
+ return this._step * value;
962
+ case RandomMode.RANDOM:
963
+ return Math.random() * value;
964
+ default:
965
+ throw new Error("Unknown RandomMode");
966
+ }
1119
967
  }
1120
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1121
- isAbsolute(fname) {
1122
- throw new Error("isAbsolute-Method not implemented.");
968
+ };
969
+ var IdService = class {
970
+ constructor(mode) {
971
+ this._step = 0;
972
+ if (!mode) {
973
+ mode = IDMode.UUID;
974
+ }
975
+ this._mode = mode;
976
+ }
977
+ NextId() {
978
+ switch (this._mode) {
979
+ case IDMode.UUID:
980
+ return crypto.randomUUID();
981
+ case IDMode.CONST:
982
+ return "VeryUniqueID";
983
+ case IDMode.STEP:
984
+ return `STEPId-${this._step++}`;
985
+ default:
986
+ throw new Error("Unknown IDMode");
987
+ }
988
+ }
989
+ };
990
+ var BaseBasicSysAbstraction = class {
991
+ constructor(params) {
992
+ this._time = new SysTime();
993
+ // system independent services
994
+ this._idService = new IdService();
995
+ this._randomService = new RandomService(RandomMode.RANDOM);
996
+ this._txtEnDe = params.TxtEnDecoder;
997
+ }
998
+ };
999
+ var WrapperBasicSysAbstraction = class {
1000
+ constructor(base, params) {
1001
+ this._time = base._time;
1002
+ this._basicRuntimeService = params.basicRuntimeService;
1003
+ this._idService = base._idService;
1004
+ this._randomService = base._randomService;
1005
+ if (params.TimeMode) {
1006
+ this._time = TimeFactory(params.TimeMode);
1007
+ }
1008
+ if (params.IdMode) {
1009
+ this._idService = new IdService(params.IdMode);
1010
+ }
1011
+ if (params.RandomMode) {
1012
+ this._randomService = new RandomService(params.RandomMode);
1013
+ }
1014
+ }
1015
+ Time() {
1016
+ return this._time;
1017
+ }
1018
+ NextId() {
1019
+ return this._idService.NextId();
1020
+ }
1021
+ Random0ToValue(value) {
1022
+ return this._randomService.Random0ToValue(value);
1023
+ }
1024
+ Stdout() {
1025
+ return this._basicRuntimeService.Stdout();
1026
+ }
1027
+ Stderr() {
1028
+ return this._basicRuntimeService.Stderr();
1029
+ }
1030
+ Env() {
1031
+ return this._basicRuntimeService.Env();
1032
+ }
1033
+ Args() {
1034
+ return this._basicRuntimeService.Args();
1035
+ }
1036
+ // System(): SystemService {
1037
+ // return this._systemService;
1038
+ // }
1039
+ // FileSystem(): FileService {
1040
+ // return this._fileSystem;
1041
+ // }
1042
+ };
1043
+
1044
+ // src/utils/console-write-stream.ts
1045
+ var ConsoleWriterStreamDefaultWriter = class {
1046
+ constructor(stream) {
1047
+ this.stream = stream;
1048
+ this.desiredSize = null;
1049
+ this.decoder = new TextDecoder();
1050
+ this._stream = stream;
1051
+ this.ready = Promise.resolve(void 0);
1052
+ this.closed = Promise.resolve(void 0);
1053
+ }
1054
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
1055
+ abort(reason) {
1056
+ throw new Error("Method not implemented.");
1057
+ }
1058
+ async close() {
1059
+ }
1060
+ releaseLock() {
1061
+ this._stream.locked = false;
1062
+ this.ready = Promise.resolve(void 0);
1063
+ this.closed = Promise.resolve(void 0);
1064
+ }
1065
+ write(chunk) {
1066
+ let strObj = this.decoder.decode(chunk).trimEnd();
1067
+ let output = "log";
1068
+ try {
1069
+ strObj = JSON.parse(strObj);
1070
+ output = strObj.level;
1071
+ } catch (e) {
1072
+ }
1073
+ switch (output) {
1074
+ case "error":
1075
+ console.error(strObj);
1076
+ break;
1077
+ case "warn":
1078
+ console.warn(strObj);
1079
+ break;
1080
+ default:
1081
+ console.log(strObj);
1082
+ }
1083
+ return Promise.resolve();
1084
+ }
1085
+ };
1086
+ var ConsoleWriterStream = class {
1087
+ constructor() {
1088
+ this.locked = false;
1089
+ }
1090
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
1091
+ abort(reason) {
1092
+ throw new Error("Method not implemented.");
1093
+ }
1094
+ close() {
1095
+ return Promise.resolve();
1096
+ }
1097
+ getWriter() {
1098
+ if (this.locked) {
1099
+ throw new Error("Stream is locked");
1100
+ }
1101
+ this.locked = true;
1102
+ if (!this._writer) {
1103
+ this._writer = new ConsoleWriterStreamDefaultWriter(this);
1104
+ }
1105
+ return this._writer;
1123
1106
  }
1124
1107
  };
1108
+
1109
+ // src/web/web-basic-sys-abstraction.ts
1125
1110
  var WebSystemService = class {
1111
+ constructor(ende) {
1112
+ this._txtEnDe = ende;
1113
+ }
1126
1114
  Env() {
1127
1115
  return envFactory();
1128
1116
  }
1129
1117
  Args() {
1130
1118
  throw new Error("Args-Method not implemented.");
1131
1119
  }
1132
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1133
- OnExit(hdl) {
1134
- throw new Error("OnExit-Method not implemented.");
1120
+ Stdout() {
1121
+ return new ConsoleWriterStream();
1135
1122
  }
1136
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1137
- Exit(code) {
1138
- throw new Error("Exit-Method not implemented.");
1123
+ Stderr() {
1124
+ const decoder = this._txtEnDe;
1125
+ return new WritableStream({
1126
+ write(chunk) {
1127
+ return new Promise((resolve) => {
1128
+ const decoded = decoder.decode(chunk);
1129
+ console.error(decoded.trimEnd());
1130
+ resolve();
1131
+ });
1132
+ }
1133
+ });
1139
1134
  }
1140
1135
  };
1141
- var my = void 0;
1142
- function WebSysAbstraction(param2) {
1143
- if (!my) {
1144
- my = new BaseSysAbstraction({
1145
- TxtEnDecoder: (param2 == null ? void 0 : param2.TxtEnDecoder) || TxtEnDecoderSingleton(),
1146
- FileSystem: new WebFileService(),
1147
- SystemService: new WebSystemService()
1136
+ var baseSysAbstraction4 = new ResolveOnce();
1137
+ function WebBasicSysAbstraction(param2) {
1138
+ var _a;
1139
+ const my = baseSysAbstraction4.once(() => {
1140
+ return new BaseBasicSysAbstraction({
1141
+ TxtEnDecoder: (param2 == null ? void 0 : param2.TxtEnDecoder) || TxtEnDecoderSingleton()
1148
1142
  });
1149
- }
1150
- return new WrapperSysAbstraction(my, param2);
1143
+ });
1144
+ return new WrapperBasicSysAbstraction(my, {
1145
+ basicRuntimeService: new WebSystemService((_a = param2 == null ? void 0 : param2.TxtEnDecoder) != null ? _a : my._txtEnDe),
1146
+ ...param2
1147
+ });
1151
1148
  }
1152
1149
  // Annotate the CommonJS export names for ESM import in node:
1153
1150
  0 && (module.exports = {
1154
- WebFileService,
1155
- WebSysAbstraction
1151
+ WebBasicSysAbstraction
1156
1152
  });
1157
1153
  //# sourceMappingURL=index.cjs.map