@adviser/cement 0.3.20 → 0.4.0

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