@adviser/cement 0.0.0-jsr-t1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (320) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +39 -0
  3. package/base-sys-abstraction-BkEiLHl0.d.ts +193 -0
  4. package/base-sys-abstraction-Qj7pkY1N.d.cts +193 -0
  5. package/chunk-7KFVMTOS.js +311 -0
  6. package/chunk-7KFVMTOS.js.map +1 -0
  7. package/chunk-GES3MUGV.js +92 -0
  8. package/chunk-GES3MUGV.js.map +1 -0
  9. package/chunk-Q65HLCNL.js +601 -0
  10. package/chunk-Q65HLCNL.js.map +1 -0
  11. package/chunk-WMMUXBDX.js +87 -0
  12. package/chunk-WMMUXBDX.js.map +1 -0
  13. package/index-Q3phXzYr.d.cts +75 -0
  14. package/index-tIGZMHTc.d.ts +75 -0
  15. package/index.cjs +2593 -0
  16. package/index.cjs.map +1 -0
  17. package/index.d.cts +532 -0
  18. package/index.d.ts +532 -0
  19. package/index.js +1533 -0
  20. package/index.js.map +1 -0
  21. package/node/index.cjs +924 -0
  22. package/node/index.cjs.map +1 -0
  23. package/node/index.d.cts +65 -0
  24. package/node/index.d.ts +65 -0
  25. package/node/index.js +398 -0
  26. package/node/index.js.map +1 -0
  27. package/package.json +81 -0
  28. package/src/base-sys-abstraction.test.ts +95 -0
  29. package/src/base-sys-abstraction.ts +242 -0
  30. package/src/bin2text.test.ts +59 -0
  31. package/src/bin2text.ts +47 -0
  32. package/src/crypto.test.ts +15 -0
  33. package/src/crypto.ts +125 -0
  34. package/src/file-service.ts +24 -0
  35. package/src/future.test.ts +32 -0
  36. package/src/future.ts +27 -0
  37. package/src/index.ts +22 -0
  38. package/src/jsr.json +20 -0
  39. package/src/log-level-impl.ts +87 -0
  40. package/src/log-writer-impl.ts +58 -0
  41. package/src/logger-impl.ts +498 -0
  42. package/src/logger.test.ts +1132 -0
  43. package/src/logger.ts +208 -0
  44. package/src/node/deno-file-service.ts +92 -0
  45. package/src/node/deno-sys-abstraction.ts +133 -0
  46. package/src/node/index.ts +4 -0
  47. package/src/node/mock-file-service.ts +45 -0
  48. package/src/node/node-file-service.ts +91 -0
  49. package/src/node/node-sys-abstraction.ts +121 -0
  50. package/src/option.ts +60 -0
  51. package/src/resolve-once.test.ts +321 -0
  52. package/src/resolve-once.ts +179 -0
  53. package/src/result.test.ts +102 -0
  54. package/src/result.ts +165 -0
  55. package/src/runtime.ts +36 -0
  56. package/src/sys-abstraction.ts +53 -0
  57. package/src/sys-env.test.ts +53 -0
  58. package/src/sys-env.ts +216 -0
  59. package/src/test/log-write-stream.ts +95 -0
  60. package/src/test/mock-logger.ts +40 -0
  61. package/src/time.ts +20 -0
  62. package/src/tracer.test.ts +314 -0
  63. package/src/tracer.ts +222 -0
  64. package/src/txt-en-decoder.ts +21 -0
  65. package/src/uri.test.ts +155 -0
  66. package/src/uri.ts +421 -0
  67. package/src/utils/console-write-stream.ts +72 -0
  68. package/src/utils/fanout-write-stream.ts +32 -0
  69. package/src/utils/index.ts +6 -0
  70. package/src/utils/rebuffer.ts +75 -0
  71. package/src/utils/stream-map.ts +67 -0
  72. package/src/utils/stream2string.ts +47 -0
  73. package/src/utils/string2stream.ts +14 -0
  74. package/src/version.ts +3 -0
  75. package/src/web/index.ts +1 -0
  76. package/src/web/web-sys-abstraction.ts +80 -0
  77. package/ts/LICENSE +201 -0
  78. package/ts/README.md +39 -0
  79. package/ts/base-sys-abstraction.d.ts +84 -0
  80. package/ts/base-sys-abstraction.d.ts.map +1 -0
  81. package/ts/base-sys-abstraction.js +178 -0
  82. package/ts/base-sys-abstraction.js.map +1 -0
  83. package/ts/base-sys-abstraction.test.d.ts +2 -0
  84. package/ts/base-sys-abstraction.test.d.ts.map +1 -0
  85. package/ts/base-sys-abstraction.test.js +82 -0
  86. package/ts/base-sys-abstraction.test.js.map +1 -0
  87. package/ts/bin2text.d.ts +3 -0
  88. package/ts/bin2text.d.ts.map +1 -0
  89. package/ts/bin2text.js +43 -0
  90. package/ts/bin2text.js.map +1 -0
  91. package/ts/bin2text.test.d.ts +2 -0
  92. package/ts/bin2text.test.d.ts.map +1 -0
  93. package/ts/bin2text.test.js +51 -0
  94. package/ts/bin2text.test.js.map +1 -0
  95. package/ts/crypto.d.ts +76 -0
  96. package/ts/crypto.d.ts.map +1 -0
  97. package/ts/crypto.js +22 -0
  98. package/ts/crypto.js.map +1 -0
  99. package/ts/crypto.test.d.ts +2 -0
  100. package/ts/crypto.test.d.ts.map +1 -0
  101. package/ts/crypto.test.js +14 -0
  102. package/ts/crypto.test.js.map +1 -0
  103. package/ts/file-service.d.ts +17 -0
  104. package/ts/file-service.d.ts.map +1 -0
  105. package/ts/file-service.js +2 -0
  106. package/ts/file-service.js.map +1 -0
  107. package/ts/future.d.ts +8 -0
  108. package/ts/future.d.ts.map +1 -0
  109. package/ts/future.js +38 -0
  110. package/ts/future.js.map +1 -0
  111. package/ts/future.test.d.ts +2 -0
  112. package/ts/future.test.d.ts.map +1 -0
  113. package/ts/future.test.js +28 -0
  114. package/ts/future.test.js.map +1 -0
  115. package/ts/index.d.ts +23 -0
  116. package/ts/index.d.ts.map +1 -0
  117. package/ts/index.js +23 -0
  118. package/ts/index.js.map +1 -0
  119. package/ts/log-level-impl.d.ts +14 -0
  120. package/ts/log-level-impl.d.ts.map +1 -0
  121. package/ts/log-level-impl.js +72 -0
  122. package/ts/log-level-impl.js.map +1 -0
  123. package/ts/log-writer-impl.d.ts +10 -0
  124. package/ts/log-writer-impl.d.ts.map +1 -0
  125. package/ts/log-writer-impl.js +45 -0
  126. package/ts/log-writer-impl.js.map +1 -0
  127. package/ts/logger-impl.d.ts +71 -0
  128. package/ts/logger-impl.d.ts.map +1 -0
  129. package/ts/logger-impl.js +412 -0
  130. package/ts/logger-impl.js.map +1 -0
  131. package/ts/logger.d.ts +84 -0
  132. package/ts/logger.d.ts.map +1 -0
  133. package/ts/logger.js +114 -0
  134. package/ts/logger.js.map +1 -0
  135. package/ts/logger.test.d.ts +2 -0
  136. package/ts/logger.test.d.ts.map +1 -0
  137. package/ts/logger.test.js +1023 -0
  138. package/ts/logger.test.js.map +1 -0
  139. package/ts/node/deno-file-service.d.ts +17 -0
  140. package/ts/node/deno-file-service.d.ts.map +1 -0
  141. package/ts/node/deno-file-service.js +65 -0
  142. package/ts/node/deno-file-service.js.map +1 -0
  143. package/ts/node/deno-sys-abstraction.d.ts +22 -0
  144. package/ts/node/deno-sys-abstraction.d.ts.map +1 -0
  145. package/ts/node/deno-sys-abstraction.js +101 -0
  146. package/ts/node/deno-sys-abstraction.js.map +1 -0
  147. package/ts/node/index.d.ts +5 -0
  148. package/ts/node/index.d.ts.map +1 -0
  149. package/ts/node/index.js +5 -0
  150. package/ts/node/index.js.map +1 -0
  151. package/ts/node/mock-file-service.d.ts +11 -0
  152. package/ts/node/mock-file-service.d.ts.map +1 -0
  153. package/ts/node/mock-file-service.js +34 -0
  154. package/ts/node/mock-file-service.js.map +1 -0
  155. package/ts/node/mock-file-service.test.d.ts +2 -0
  156. package/ts/node/mock-file-service.test.d.ts.map +1 -0
  157. package/ts/node/mock-file-service.test.js +31 -0
  158. package/ts/node/mock-file-service.test.js.map +1 -0
  159. package/ts/node/node-file-service.d.ts +16 -0
  160. package/ts/node/node-file-service.d.ts.map +1 -0
  161. package/ts/node/node-file-service.js +71 -0
  162. package/ts/node/node-file-service.js.map +1 -0
  163. package/ts/node/node-sys-abstraction.d.ts +22 -0
  164. package/ts/node/node-sys-abstraction.d.ts.map +1 -0
  165. package/ts/node/node-sys-abstraction.js +99 -0
  166. package/ts/node/node-sys-abstraction.js.map +1 -0
  167. package/ts/node/node-sys-abstraction.test.d.ts +2 -0
  168. package/ts/node/node-sys-abstraction.test.d.ts.map +1 -0
  169. package/ts/node/node-sys-abstraction.test.js +87 -0
  170. package/ts/node/node-sys-abstraction.test.js.map +1 -0
  171. package/ts/option.d.ts +25 -0
  172. package/ts/option.d.ts.map +1 -0
  173. package/ts/option.js +47 -0
  174. package/ts/option.js.map +1 -0
  175. package/ts/resolve-once.d.ts +46 -0
  176. package/ts/resolve-once.d.ts.map +1 -0
  177. package/ts/resolve-once.js +152 -0
  178. package/ts/resolve-once.js.map +1 -0
  179. package/ts/resolve-once.test.d.ts +2 -0
  180. package/ts/resolve-once.test.d.ts.map +1 -0
  181. package/ts/resolve-once.test.js +283 -0
  182. package/ts/resolve-once.test.js.map +1 -0
  183. package/ts/result.d.ts +34 -0
  184. package/ts/result.d.ts.map +1 -0
  185. package/ts/result.js +85 -0
  186. package/ts/result.js.map +1 -0
  187. package/ts/result.test.d.ts +2 -0
  188. package/ts/result.test.d.ts.map +1 -0
  189. package/ts/result.test.js +79 -0
  190. package/ts/result.test.js.map +1 -0
  191. package/ts/runtime.d.ts +8 -0
  192. package/ts/runtime.d.ts.map +1 -0
  193. package/ts/runtime.js +26 -0
  194. package/ts/runtime.js.map +1 -0
  195. package/ts/sys-abstraction.d.ts +36 -0
  196. package/ts/sys-abstraction.d.ts.map +1 -0
  197. package/ts/sys-abstraction.js +31 -0
  198. package/ts/sys-abstraction.js.map +1 -0
  199. package/ts/sys-env.d.ts +48 -0
  200. package/ts/sys-env.d.ts.map +1 -0
  201. package/ts/sys-env.js +176 -0
  202. package/ts/sys-env.js.map +1 -0
  203. package/ts/sys-env.test.d.ts +2 -0
  204. package/ts/sys-env.test.d.ts.map +1 -0
  205. package/ts/sys-env.test.js +51 -0
  206. package/ts/sys-env.test.js.map +1 -0
  207. package/ts/test/log-write-stream.d.ts +27 -0
  208. package/ts/test/log-write-stream.d.ts.map +1 -0
  209. package/ts/test/log-write-stream.js +74 -0
  210. package/ts/test/log-write-stream.js.map +1 -0
  211. package/ts/test/mock-logger.d.ts +14 -0
  212. package/ts/test/mock-logger.d.ts.map +1 -0
  213. package/ts/test/mock-logger.js +29 -0
  214. package/ts/test/mock-logger.js.map +1 -0
  215. package/ts/test/mock-logger.test.d.ts +2 -0
  216. package/ts/test/mock-logger.test.d.ts.map +1 -0
  217. package/ts/test/mock-logger.test.js +63 -0
  218. package/ts/test/mock-logger.test.js.map +1 -0
  219. package/ts/test/test-exit-handler.d.ts +2 -0
  220. package/ts/test/test-exit-handler.d.ts.map +1 -0
  221. package/ts/test/test-exit-handler.js +57 -0
  222. package/ts/test/test-exit-handler.js.map +1 -0
  223. package/ts/time.d.ts +13 -0
  224. package/ts/time.d.ts.map +1 -0
  225. package/ts/time.js +14 -0
  226. package/ts/time.js.map +1 -0
  227. package/ts/tracer.d.ts +59 -0
  228. package/ts/tracer.d.ts.map +1 -0
  229. package/ts/tracer.js +148 -0
  230. package/ts/tracer.js.map +1 -0
  231. package/ts/tracer.test.d.ts +2 -0
  232. package/ts/tracer.test.d.ts.map +1 -0
  233. package/ts/tracer.test.js +311 -0
  234. package/ts/tracer.test.js.map +1 -0
  235. package/ts/txt-en-decoder.d.ts +10 -0
  236. package/ts/txt-en-decoder.d.ts.map +1 -0
  237. package/ts/txt-en-decoder.js +15 -0
  238. package/ts/txt-en-decoder.js.map +1 -0
  239. package/ts/uri.d.ts +67 -0
  240. package/ts/uri.d.ts.map +1 -0
  241. package/ts/uri.js +283 -0
  242. package/ts/uri.js.map +1 -0
  243. package/ts/uri.test.d.ts +2 -0
  244. package/ts/uri.test.d.ts.map +1 -0
  245. package/ts/uri.test.js +119 -0
  246. package/ts/uri.test.js.map +1 -0
  247. package/ts/utils/console-write-stream.d.ts +21 -0
  248. package/ts/utils/console-write-stream.d.ts.map +1 -0
  249. package/ts/utils/console-write-stream.js +62 -0
  250. package/ts/utils/console-write-stream.js.map +1 -0
  251. package/ts/utils/fanout-write-stream.d.ts +12 -0
  252. package/ts/utils/fanout-write-stream.d.ts.map +1 -0
  253. package/ts/utils/fanout-write-stream.js +24 -0
  254. package/ts/utils/fanout-write-stream.js.map +1 -0
  255. package/ts/utils/index.d.ts +7 -0
  256. package/ts/utils/index.d.ts.map +1 -0
  257. package/ts/utils/index.js +7 -0
  258. package/ts/utils/index.js.map +1 -0
  259. package/ts/utils/rebuffer.d.ts +3 -0
  260. package/ts/utils/rebuffer.d.ts.map +1 -0
  261. package/ts/utils/rebuffer.js +60 -0
  262. package/ts/utils/rebuffer.js.map +1 -0
  263. package/ts/utils/rebuffer.test.d.ts +2 -0
  264. package/ts/utils/rebuffer.test.d.ts.map +1 -0
  265. package/ts/utils/rebuffer.test.js +77 -0
  266. package/ts/utils/rebuffer.test.js.map +1 -0
  267. package/ts/utils/stream-map.d.ts +9 -0
  268. package/ts/utils/stream-map.d.ts.map +1 -0
  269. package/ts/utils/stream-map.js +62 -0
  270. package/ts/utils/stream-map.js.map +1 -0
  271. package/ts/utils/stream-map.test.d.ts +2 -0
  272. package/ts/utils/stream-map.test.d.ts.map +1 -0
  273. package/ts/utils/stream-map.test.js +87 -0
  274. package/ts/utils/stream-map.test.js.map +1 -0
  275. package/ts/utils/stream-test-helper.d.ts +17 -0
  276. package/ts/utils/stream-test-helper.d.ts.map +1 -0
  277. package/ts/utils/stream-test-helper.js +37 -0
  278. package/ts/utils/stream-test-helper.js.map +1 -0
  279. package/ts/utils/stream2string.d.ts +3 -0
  280. package/ts/utils/stream2string.d.ts.map +1 -0
  281. package/ts/utils/stream2string.js +48 -0
  282. package/ts/utils/stream2string.js.map +1 -0
  283. package/ts/utils/stream2string.test.d.ts +2 -0
  284. package/ts/utils/stream2string.test.d.ts.map +1 -0
  285. package/ts/utils/stream2string.test.js +29 -0
  286. package/ts/utils/stream2string.test.js.map +1 -0
  287. package/ts/utils/string2stream.d.ts +4 -0
  288. package/ts/utils/string2stream.d.ts.map +1 -0
  289. package/ts/utils/string2stream.js +13 -0
  290. package/ts/utils/string2stream.js.map +1 -0
  291. package/ts/utils/string2stream.test.d.ts +2 -0
  292. package/ts/utils/string2stream.test.d.ts.map +1 -0
  293. package/ts/utils/string2stream.test.js +6 -0
  294. package/ts/utils/string2stream.test.js.map +1 -0
  295. package/ts/version.d.ts +2 -0
  296. package/ts/version.d.ts.map +1 -0
  297. package/ts/version.js +4 -0
  298. package/ts/version.js.map +1 -0
  299. package/ts/web/index.d.ts +2 -0
  300. package/ts/web/index.d.ts.map +1 -0
  301. package/ts/web/index.js +2 -0
  302. package/ts/web/index.js.map +1 -0
  303. package/ts/web/web-sys-abstraction.d.ts +4 -0
  304. package/ts/web/web-sys-abstraction.d.ts.map +1 -0
  305. package/ts/web/web-sys-abstraction.js +64 -0
  306. package/ts/web/web-sys-abstraction.js.map +1 -0
  307. package/txt-en-decoder-CZYJUju2.d.cts +11 -0
  308. package/txt-en-decoder-CZYJUju2.d.ts +11 -0
  309. package/utils/index.cjs +341 -0
  310. package/utils/index.cjs.map +1 -0
  311. package/utils/index.d.cts +2 -0
  312. package/utils/index.d.ts +2 -0
  313. package/utils/index.js +32 -0
  314. package/utils/index.js.map +1 -0
  315. package/web/index.cjs +593 -0
  316. package/web/index.cjs.map +1 -0
  317. package/web/index.d.cts +6 -0
  318. package/web/index.d.ts +6 -0
  319. package/web/index.js +9 -0
  320. package/web/index.js.map +1 -0
@@ -0,0 +1,601 @@
1
+ import {
2
+ __privateAdd,
3
+ __privateGet,
4
+ __privateSet
5
+ } from "./chunk-GES3MUGV.js";
6
+
7
+ // src/sys-abstraction.ts
8
+ var TimeMode = /* @__PURE__ */ ((TimeMode2) => {
9
+ TimeMode2["REAL"] = "real";
10
+ TimeMode2["CONST"] = "const";
11
+ TimeMode2["STEP"] = "step";
12
+ return TimeMode2;
13
+ })(TimeMode || {});
14
+ var RandomMode = /* @__PURE__ */ ((RandomMode2) => {
15
+ RandomMode2["CONST"] = "const";
16
+ RandomMode2["STEP"] = "step";
17
+ RandomMode2["RANDOM"] = "random";
18
+ return RandomMode2;
19
+ })(RandomMode || {});
20
+ var IDMode = /* @__PURE__ */ ((IDMode2) => {
21
+ IDMode2["UUID"] = "uuid";
22
+ IDMode2["CONST"] = "const";
23
+ IDMode2["STEP"] = "step";
24
+ return IDMode2;
25
+ })(IDMode || {});
26
+ function String2TimeMode(s) {
27
+ switch (s == null ? void 0 : s.toLowerCase()) {
28
+ case "real":
29
+ return "real" /* REAL */;
30
+ case "const":
31
+ return "const" /* CONST */;
32
+ case "step":
33
+ return "step" /* STEP */;
34
+ default:
35
+ return "real" /* REAL */;
36
+ }
37
+ }
38
+
39
+ // src/time.ts
40
+ var Time = class {
41
+ TimeSince(start) {
42
+ const now = this.Now();
43
+ return now.getTime() - start.getTime();
44
+ }
45
+ };
46
+ var TimeUnits = /* @__PURE__ */ ((TimeUnits2) => {
47
+ TimeUnits2[TimeUnits2["Microsecond"] = 1] = "Microsecond";
48
+ TimeUnits2[TimeUnits2["Second"] = 1e3] = "Second";
49
+ TimeUnits2[TimeUnits2["Minute"] = 6e4] = "Minute";
50
+ TimeUnits2[TimeUnits2["Hour"] = 36e5] = "Hour";
51
+ return TimeUnits2;
52
+ })(TimeUnits || {});
53
+
54
+ // src/base-sys-abstraction.ts
55
+ var SysTime = class extends Time {
56
+ Now() {
57
+ return /* @__PURE__ */ new Date();
58
+ }
59
+ Sleep(duration) {
60
+ return new Promise((resolve) => {
61
+ setTimeout(() => {
62
+ resolve();
63
+ }, duration);
64
+ });
65
+ }
66
+ };
67
+ var ConstTime = class extends Time {
68
+ Now() {
69
+ return new Date(2021, 1, 1, 0, 0, 0, 0);
70
+ }
71
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
72
+ Sleep(duration) {
73
+ return Promise.resolve();
74
+ }
75
+ };
76
+ var StepTime = class extends Time {
77
+ constructor() {
78
+ super();
79
+ this._step = new ConstTime().Now();
80
+ this._start = this._step;
81
+ }
82
+ Now(steps = 1) {
83
+ for (let i = 0; steps > 0 && i < steps; i++) {
84
+ this._step = new Date(this._step.getTime() + 1e3);
85
+ }
86
+ if (steps < 1) {
87
+ this._step = new Date(this._start.getTime() + steps * -1e3);
88
+ }
89
+ return this._step;
90
+ }
91
+ Sleep(duration) {
92
+ this._step = new Date(this._step.getTime() + duration);
93
+ return Promise.resolve();
94
+ }
95
+ };
96
+ function TimeFactory(timeMode) {
97
+ switch (timeMode) {
98
+ case "real" /* REAL */:
99
+ return new SysTime();
100
+ case "const" /* CONST */:
101
+ return new ConstTime();
102
+ case "step" /* STEP */:
103
+ return new StepTime();
104
+ }
105
+ return new SysTime();
106
+ }
107
+ var RandomService = class {
108
+ constructor(mode) {
109
+ this._step = 0;
110
+ this._mode = mode;
111
+ }
112
+ Random0ToValue(value) {
113
+ switch (this._mode) {
114
+ case "const" /* CONST */:
115
+ return 0.5 * value;
116
+ case "step" /* STEP */:
117
+ this._step += 1e-4;
118
+ return this._step * value;
119
+ case "random" /* RANDOM */:
120
+ return Math.random() * value;
121
+ default:
122
+ throw new Error("Unknown RandomMode");
123
+ }
124
+ }
125
+ };
126
+ var IdService = class {
127
+ constructor(mode) {
128
+ this._step = 0;
129
+ if (!mode) {
130
+ mode = "uuid" /* UUID */;
131
+ }
132
+ this._mode = mode;
133
+ }
134
+ NextId() {
135
+ switch (this._mode) {
136
+ case "uuid" /* UUID */:
137
+ return crypto.randomUUID();
138
+ case "const" /* CONST */:
139
+ return "VeryUniqueID";
140
+ case "step" /* STEP */:
141
+ return `STEPId-${this._step++}`;
142
+ default:
143
+ throw new Error("Unknown IDMode");
144
+ }
145
+ }
146
+ };
147
+ var BaseSysAbstraction = class {
148
+ constructor(params) {
149
+ this._time = new SysTime();
150
+ this._idService = new IdService();
151
+ this._randomService = new RandomService("random" /* RANDOM */);
152
+ this._fileSystem = params.FileSystem;
153
+ this._systemService = params.SystemService;
154
+ this._txtEnDe = params.TxtEnDecoder;
155
+ const decoder = this._txtEnDe;
156
+ this._stdout = new WritableStream({
157
+ write(chunk) {
158
+ return new Promise((resolve) => {
159
+ const decoded = decoder.decode(chunk);
160
+ console.log(decoded.trimEnd());
161
+ resolve();
162
+ });
163
+ }
164
+ });
165
+ this._stderr = new WritableStream({
166
+ write(chunk) {
167
+ return new Promise((resolve) => {
168
+ const decoded = decoder.decode(chunk);
169
+ console.error(decoded.trimEnd());
170
+ resolve();
171
+ });
172
+ }
173
+ });
174
+ }
175
+ };
176
+ var WrapperSysAbstraction = class {
177
+ constructor(base, params) {
178
+ this._time = base._time;
179
+ this._stdout = base._stdout;
180
+ this._stderr = base._stderr;
181
+ this._idService = base._idService;
182
+ this._randomService = base._randomService;
183
+ this._fileSystem = base._fileSystem;
184
+ this._systemService = base._systemService;
185
+ if (params) {
186
+ if (params.TimeMode) {
187
+ this._time = TimeFactory(params.TimeMode);
188
+ }
189
+ if (params.Stdout) {
190
+ this._stdout = params.Stdout;
191
+ }
192
+ if (params.Stderr) {
193
+ this._stderr = params.Stderr;
194
+ }
195
+ if (params.IdMode) {
196
+ this._idService = new IdService(params.IdMode);
197
+ }
198
+ if (params.RandomMode) {
199
+ this._randomService = new RandomService(params.RandomMode);
200
+ }
201
+ if (params.FileSystem) {
202
+ this._fileSystem = params.FileSystem;
203
+ }
204
+ if (params.SystemService) {
205
+ this._systemService = params.SystemService;
206
+ }
207
+ }
208
+ }
209
+ Time() {
210
+ return this._time;
211
+ }
212
+ NextId() {
213
+ return this._idService.NextId();
214
+ }
215
+ Random0ToValue(value) {
216
+ return this._randomService.Random0ToValue(value);
217
+ }
218
+ Stdout() {
219
+ return this._stdout;
220
+ }
221
+ Stderr() {
222
+ return this._stderr;
223
+ }
224
+ System() {
225
+ return this._systemService;
226
+ }
227
+ FileSystem() {
228
+ return this._fileSystem;
229
+ }
230
+ };
231
+
232
+ // src/future.ts
233
+ var _promise, _resolveFn, _rejectFn;
234
+ var Future = class {
235
+ constructor() {
236
+ __privateAdd(this, _promise);
237
+ __privateAdd(this, _resolveFn, () => {
238
+ throw new Error("This Promise is not working as expected.");
239
+ });
240
+ __privateAdd(this, _rejectFn, () => {
241
+ throw new Error("This Promise is not working as expected.");
242
+ });
243
+ __privateSet(this, _promise, new Promise((resolve, reject) => {
244
+ __privateSet(this, _resolveFn, resolve);
245
+ __privateSet(this, _rejectFn, reject);
246
+ }));
247
+ }
248
+ async asPromise() {
249
+ return __privateGet(this, _promise);
250
+ }
251
+ resolve(value) {
252
+ __privateGet(this, _resolveFn).call(this, value);
253
+ }
254
+ reject(reason) {
255
+ __privateGet(this, _rejectFn).call(this, reason);
256
+ }
257
+ };
258
+ _promise = new WeakMap();
259
+ _resolveFn = new WeakMap();
260
+ _rejectFn = new WeakMap();
261
+
262
+ // src/resolve-once.ts
263
+ var ResolveSeq = class {
264
+ constructor(ctx) {
265
+ this._seqFutures = [];
266
+ this.ctx = ctx;
267
+ }
268
+ reset() {
269
+ }
270
+ async _step(item) {
271
+ if (!item) {
272
+ return;
273
+ }
274
+ item.fn(this.ctx).then((value) => item.future.resolve(value)).catch((e) => item.future.reject(e)).finally(() => {
275
+ this._seqFutures.shift();
276
+ this._step(this._seqFutures[0]);
277
+ });
278
+ }
279
+ async add(fn, id) {
280
+ const future = new Future();
281
+ this._seqFutures.push({ future, fn, id });
282
+ if (this._seqFutures.length === 1) {
283
+ this._step(this._seqFutures[0]);
284
+ }
285
+ return future.asPromise();
286
+ }
287
+ };
288
+ var ResolveOnce = class {
289
+ constructor(ctx) {
290
+ this._onceDone = false;
291
+ this._onceFutures = [];
292
+ this._onceOk = false;
293
+ this._isPromise = false;
294
+ this.ctx = ctx;
295
+ }
296
+ get ready() {
297
+ return this._onceDone;
298
+ }
299
+ reset() {
300
+ this._onceDone = false;
301
+ this._onceOk = false;
302
+ this._onceValue = void 0;
303
+ this._onceError = void 0;
304
+ this._onceFutures.length = 0;
305
+ }
306
+ // T extends Option<infer U> ? U : T
307
+ once(fn) {
308
+ if (this._onceDone) {
309
+ if (this._onceError) {
310
+ if (this._isPromise) {
311
+ return Promise.reject(this._onceError);
312
+ } else {
313
+ throw this._onceError;
314
+ }
315
+ }
316
+ if (this._onceOk) {
317
+ if (this._isPromise) {
318
+ return Promise.resolve(this._onceValue);
319
+ } else {
320
+ return this._onceValue;
321
+ }
322
+ }
323
+ throw new Error("ResolveOnce.once impossible");
324
+ }
325
+ const future = new Future();
326
+ this._onceFutures.push(future);
327
+ if (this._onceFutures.length === 1) {
328
+ const okFn = (value) => {
329
+ this._onceValue = value;
330
+ this._onceOk = true;
331
+ this._onceDone = true;
332
+ if (this._isPromise) {
333
+ this._onceFutures.forEach((f) => f.resolve(this._onceValue));
334
+ }
335
+ this._onceFutures.length = 0;
336
+ };
337
+ const catchFn = (e) => {
338
+ this._onceError = e;
339
+ this._onceOk = false;
340
+ this._onceValue = void 0;
341
+ this._onceDone = true;
342
+ if (this._isPromise) {
343
+ this._onceFutures.forEach((f) => f.reject(this._onceError));
344
+ }
345
+ this._onceFutures.length = 0;
346
+ };
347
+ try {
348
+ const ret = fn(this.ctx);
349
+ if (typeof ret.then === "function") {
350
+ this._isPromise = true;
351
+ ret.then(okFn).catch(catchFn);
352
+ } else {
353
+ okFn(ret);
354
+ }
355
+ } catch (e) {
356
+ catchFn(e);
357
+ }
358
+ }
359
+ if (this._isPromise) {
360
+ return future.asPromise();
361
+ } else {
362
+ return this.once(fn);
363
+ }
364
+ }
365
+ };
366
+ var Keyed = class {
367
+ constructor(factory) {
368
+ this._map = /* @__PURE__ */ new Map();
369
+ this.factory = factory;
370
+ }
371
+ async asyncGet(key) {
372
+ return this.get(await key());
373
+ }
374
+ get(key) {
375
+ if (typeof key === "function") {
376
+ key = key();
377
+ }
378
+ let keyed = this._map.get(key);
379
+ if (!keyed) {
380
+ keyed = this.factory(key);
381
+ this._map.set(key, keyed);
382
+ }
383
+ return keyed;
384
+ }
385
+ unget(key) {
386
+ const keyed = this._map.get(key);
387
+ keyed == null ? void 0 : keyed.reset();
388
+ this._map.delete(key);
389
+ }
390
+ reset() {
391
+ this._map.forEach((keyed) => keyed.reset());
392
+ this._map.clear();
393
+ }
394
+ };
395
+ var KeyedResolvOnce = class extends Keyed {
396
+ constructor() {
397
+ super((key) => new ResolveOnce(key));
398
+ }
399
+ };
400
+ var KeyedResolvSeq = class extends Keyed {
401
+ constructor() {
402
+ super((key) => new ResolveSeq(key));
403
+ }
404
+ };
405
+
406
+ // src/sys-env.ts
407
+ var _node;
408
+ var NodeEnvActions = class {
409
+ // eslint-disable-next-line @typescript-eslint/no-useless-constructor, @typescript-eslint/no-unused-vars
410
+ constructor(opts) {
411
+ __privateAdd(this, _node, globalThis);
412
+ this._env = this.active() ? __privateGet(this, _node).process.env : {};
413
+ }
414
+ register(env) {
415
+ return env;
416
+ }
417
+ active() {
418
+ return typeof __privateGet(this, _node) === "object" && typeof __privateGet(this, _node).process === "object" && typeof __privateGet(this, _node).process.env === "object";
419
+ }
420
+ keys() {
421
+ return Object.keys(this._env);
422
+ }
423
+ get(key) {
424
+ return this._env[key];
425
+ }
426
+ set(key, value) {
427
+ if (value) {
428
+ this._env[key] = value;
429
+ }
430
+ }
431
+ delete(key) {
432
+ delete this._env[key];
433
+ }
434
+ };
435
+ _node = new WeakMap();
436
+ var _deno;
437
+ var DenoEnvActions = class {
438
+ // eslint-disable-next-line @typescript-eslint/no-useless-constructor, @typescript-eslint/no-unused-vars
439
+ constructor(opts) {
440
+ __privateAdd(this, _deno, globalThis);
441
+ }
442
+ get _env() {
443
+ return __privateGet(this, _deno).Deno.env;
444
+ }
445
+ register(env) {
446
+ return env;
447
+ }
448
+ active() {
449
+ return typeof __privateGet(this, _deno) === "object" && typeof __privateGet(this, _deno).Deno === "object" && typeof __privateGet(this, _deno).Deno.env === "object";
450
+ }
451
+ keys() {
452
+ return Array.from(this._env.keys());
453
+ }
454
+ get(key) {
455
+ return this._env.get(key);
456
+ }
457
+ set(key, value) {
458
+ if (value) {
459
+ this._env.set(key, value);
460
+ }
461
+ }
462
+ delete(key) {
463
+ this._env.delete(key);
464
+ }
465
+ };
466
+ _deno = new WeakMap();
467
+ var BrowserEnvActions = class {
468
+ constructor(opts) {
469
+ this.env = /* @__PURE__ */ new Map();
470
+ this.opts = opts;
471
+ }
472
+ get(key) {
473
+ return this.env.get(key);
474
+ }
475
+ set(key, value) {
476
+ if (value) {
477
+ this.env.set(key, value);
478
+ }
479
+ }
480
+ delete(key) {
481
+ this.env.delete(key);
482
+ }
483
+ keys() {
484
+ return Array.from(this.env.keys());
485
+ }
486
+ active() {
487
+ return true;
488
+ }
489
+ register(env) {
490
+ const sym = Symbol.for(this.opts.symbol || "CP_ENV");
491
+ const browser = globalThis;
492
+ browser[sym] = env;
493
+ return env;
494
+ }
495
+ };
496
+ var _envFactory = new ResolveOnce();
497
+ function envFactory(opts = {}) {
498
+ return _envFactory.once(() => {
499
+ const found = [new NodeEnvActions(opts), new DenoEnvActions(opts), new BrowserEnvActions(opts)].find((env) => env.active());
500
+ if (!found) {
501
+ throw new Error("SysContainer:envFactory: no env available");
502
+ }
503
+ const ret = new EnvImpl(found, opts);
504
+ found.register(ret);
505
+ return ret;
506
+ });
507
+ }
508
+ var EnvImpl = class {
509
+ constructor(map, opts = {}) {
510
+ this._onSet = [];
511
+ this._map = map;
512
+ this._updatePresets(opts.presetEnv);
513
+ }
514
+ _updatePresets(presetEnv) {
515
+ if (!presetEnv) {
516
+ return;
517
+ }
518
+ for (const [key, value] of presetEnv) {
519
+ this._map.set(key, value);
520
+ }
521
+ }
522
+ _applyOnSet(onSet, key, value) {
523
+ onSet.forEach((item) => {
524
+ let keys = [];
525
+ if (key) {
526
+ keys = [key];
527
+ } else {
528
+ keys = this._map.keys();
529
+ }
530
+ keys.filter((k) => {
531
+ if (item.filter.size === 0) {
532
+ return true;
533
+ }
534
+ if (item.filter.has(k)) {
535
+ return true;
536
+ }
537
+ return false;
538
+ }).forEach((k) => {
539
+ let v;
540
+ if (!key && !value) {
541
+ v = this._map.get(k);
542
+ } else if (key && !value) {
543
+ v = void 0;
544
+ } else {
545
+ v = value;
546
+ }
547
+ item.fn(k, v);
548
+ });
549
+ });
550
+ }
551
+ keys() {
552
+ return this._map.keys();
553
+ }
554
+ // filter is not set all sets passed
555
+ onSet(fn, ...filter) {
556
+ const item = { filter: new Set(filter), fn };
557
+ this._onSet.push(item);
558
+ this._applyOnSet([item]);
559
+ }
560
+ get(key) {
561
+ return this._map.get(key);
562
+ }
563
+ set(key, value) {
564
+ if (!value) {
565
+ return;
566
+ }
567
+ this._map.set(key, value);
568
+ this._applyOnSet(this._onSet, key, value);
569
+ }
570
+ delete(key) {
571
+ this._map.delete(key);
572
+ this._applyOnSet(this._onSet, key);
573
+ }
574
+ };
575
+
576
+ export {
577
+ TimeMode,
578
+ RandomMode,
579
+ IDMode,
580
+ String2TimeMode,
581
+ Time,
582
+ TimeUnits,
583
+ SysTime,
584
+ ConstTime,
585
+ StepTime,
586
+ TimeFactory,
587
+ RandomService,
588
+ IdService,
589
+ BaseSysAbstraction,
590
+ WrapperSysAbstraction,
591
+ Future,
592
+ ResolveSeq,
593
+ ResolveOnce,
594
+ Keyed,
595
+ KeyedResolvOnce,
596
+ KeyedResolvSeq,
597
+ BrowserEnvActions,
598
+ envFactory,
599
+ EnvImpl
600
+ };
601
+ //# sourceMappingURL=chunk-Q65HLCNL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/sys-abstraction.ts","../../src/time.ts","../../src/base-sys-abstraction.ts","../../src/future.ts","../../src/resolve-once.ts","../../src/sys-env.ts"],"sourcesContent":["import { FileService } from \"./file-service.js\";\nimport { Env } from \"./sys-env.js\";\nimport { Time } from \"./time.js\";\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(): Env;\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(add?: number): 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.js\";\nimport { TimeMode, RandomMode, IDMode, SystemService, VoidFunc, SysAbstraction } from \"./sys-abstraction.js\";\nimport { Time } from \"./time.js\";\nimport { TxtEnDecoder } from \"./txt-en-decoder.js\";\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 readonly _start: Date;\n constructor() {\n super();\n this._step = new ConstTime().Now();\n this._start = this._step;\n }\n Now(steps = 1): Date {\n // if (this._step.getTime() === 0) {\n // this._step = new ConstTime().Now();\n // return this._step;\n // }\n for (let i = 0; steps > 0 && i < steps; i++) {\n this._step = new Date(this._step.getTime() + 1000);\n }\n if (steps < 1) {\n this._step = new Date(this._start.getTime() + steps * -1000);\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 TxtEnDecoder: TxtEnDecoder;\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\nexport class BaseSysAbstraction {\n readonly _time: SysTime = new SysTime();\n readonly _stdout: WritableStream;\n readonly _stderr: WritableStream;\n\n readonly _idService: IdService = new IdService();\n readonly _randomService: RandomService = new RandomService(RandomMode.RANDOM);\n readonly _fileSystem: FileService;\n readonly _systemService: SystemService;\n readonly _txtEnDe: TxtEnDecoder;\n\n constructor(params: BaseSysAbstractionParams) {\n this._fileSystem = params.FileSystem;\n this._systemService = params.SystemService;\n this._txtEnDe = params.TxtEnDecoder;\n const decoder = this._txtEnDe;\n this._stdout = new WritableStream({\n write(chunk): Promise<void> {\n return new Promise((resolve) => {\n const decoded = decoder.decode(chunk);\n // eslint-disable-next-line no-console\n console.log(decoded.trimEnd());\n resolve();\n });\n },\n });\n this._stderr = new WritableStream({\n write(chunk): Promise<void> {\n return new Promise((resolve) => {\n const decoded = decoder.decode(chunk);\n // eslint-disable-next-line no-console\n console.error(decoded.trimEnd());\n resolve();\n });\n },\n });\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 readonly TxtEnDecoder?: TxtEnDecoder;\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","export class Future<T> {\n readonly #promise: Promise<T>;\n #resolveFn: (value: T) => void = () => {\n throw new Error(\"This Promise is not working as expected.\");\n };\n #rejectFn: (reason: unknown) => void = () => {\n throw new Error(\"This Promise is not working as expected.\");\n };\n\n constructor() {\n this.#promise = new Promise<T>((resolve, reject) => {\n this.#resolveFn = resolve;\n this.#rejectFn = reject;\n });\n }\n\n async asPromise(): Promise<T> {\n return this.#promise;\n }\n\n resolve(value: T): void {\n this.#resolveFn(value);\n }\n reject(reason: unknown): void {\n this.#rejectFn(reason);\n }\n}\n","import { Future } from \"./future.js\";\n\ninterface ResolveSeqItem<T, C> {\n readonly future: Future<T>;\n readonly fn: (c: C) => Promise<T>;\n readonly id?: number;\n}\n\nexport class ResolveSeq<T, C = void> {\n readonly ctx: C;\n constructor(ctx?: C) {\n this.ctx = ctx as C;\n }\n reset(): void {\n /* noop */\n }\n async _step(item?: ResolveSeqItem<T, C> | undefined): Promise<void> {\n if (!item) {\n // done\n return;\n }\n item\n .fn(this.ctx)\n .then((value) => item.future.resolve(value))\n .catch((e) => item.future.reject(e as Error))\n .finally(() => {\n this._seqFutures.shift();\n this._step(this._seqFutures[0]);\n });\n }\n readonly _seqFutures: ResolveSeqItem<T, C>[] = [];\n async add(fn: (c: C) => Promise<T>, id?: number): Promise<T> {\n const future = new Future<T>();\n this._seqFutures.push({ future, fn, id });\n if (this._seqFutures.length === 1) {\n this._step(this._seqFutures[0]);\n }\n return future.asPromise();\n }\n}\n\nexport class ResolveOnce<T, CTX = void> {\n _onceDone = false;\n readonly _onceFutures: Future<T>[] = [];\n _onceOk = false;\n _onceValue?: T;\n _onceError?: Error;\n _isPromise = false;\n\n readonly ctx: CTX;\n\n constructor(ctx?: CTX) {\n this.ctx = ctx as CTX;\n }\n\n get ready(): boolean {\n return this._onceDone;\n }\n\n reset(): void {\n this._onceDone = false;\n this._onceOk = false;\n this._onceValue = undefined;\n this._onceError = undefined;\n this._onceFutures.length = 0;\n }\n\n // T extends Option<infer U> ? U : T\n once<R>(fn: (c: CTX) => R): R {\n if (this._onceDone) {\n if (this._onceError) {\n if (this._isPromise) {\n return Promise.reject(this._onceError) as unknown as R;\n } else {\n throw this._onceError;\n }\n }\n if (this._onceOk) {\n if (this._isPromise) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return Promise.resolve(this._onceValue!) as unknown as R;\n } else {\n return this._onceValue as unknown as R;\n }\n }\n throw new Error(\"ResolveOnce.once impossible\");\n }\n const future = new Future<T>();\n this._onceFutures.push(future);\n if (this._onceFutures.length === 1) {\n const okFn = (value: T): void => {\n this._onceValue = value;\n this._onceOk = true;\n this._onceDone = true;\n if (this._isPromise) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this._onceFutures.forEach((f) => f.resolve(this._onceValue!));\n }\n this._onceFutures.length = 0;\n };\n const catchFn = (e: Error): void => {\n this._onceError = e as Error;\n this._onceOk = false;\n this._onceValue = undefined;\n this._onceDone = true;\n if (this._isPromise) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this._onceFutures.forEach((f) => f.reject(this._onceError!));\n }\n this._onceFutures.length = 0;\n };\n try {\n const ret = fn(this.ctx);\n if (typeof (ret as Promise<T>).then === \"function\") {\n this._isPromise = true;\n (ret as Promise<T>).then(okFn).catch(catchFn);\n } else {\n okFn(ret as unknown as T);\n }\n } catch (e) {\n catchFn(e as Error);\n }\n }\n if (this._isPromise) {\n return future.asPromise() as unknown as R;\n } else {\n // abit funky but i don't want to impl the return just once\n return this.once(fn);\n }\n }\n}\n\nexport class Keyed<T extends { reset: () => void }, K = string> {\n private readonly _map = new Map<K, T>();\n\n readonly factory: (key: K) => T;\n constructor(factory: (key: K) => T) {\n this.factory = factory;\n }\n\n async asyncGet(key: () => Promise<K>): Promise<T> {\n return this.get(await key());\n }\n\n get(key: K | (() => K)): T {\n if (typeof key === \"function\") {\n key = (key as () => K)();\n }\n let keyed = this._map.get(key);\n if (!keyed) {\n keyed = this.factory(key);\n this._map.set(key, keyed);\n }\n return keyed;\n }\n\n unget(key: K): void {\n const keyed = this._map.get(key);\n keyed?.reset();\n this._map.delete(key);\n }\n\n reset(): void {\n this._map.forEach((keyed) => keyed.reset());\n this._map.clear();\n }\n}\n\nexport class KeyedResolvOnce<T, K = string> extends Keyed<ResolveOnce<T, K>, K> {\n constructor() {\n super((key) => new ResolveOnce<T, K>(key));\n }\n}\n\nexport class KeyedResolvSeq<T, K = string> extends Keyed<ResolveSeq<T, K>, K> {\n constructor() {\n super((key) => new ResolveSeq<T, K>(key));\n }\n}\n","import { ResolveOnce } from \"./resolve-once.js\";\n\nexport interface EnvMap {\n get(key: string): string | undefined;\n set(key: string, value?: string): void;\n delete(key: string): void;\n keys(): string[];\n}\nexport interface EnvActions extends EnvMap {\n active(): boolean;\n register(env: Env): Env;\n}\n\nclass NodeEnvActions implements EnvActions {\n readonly #node = globalThis as unknown as { process: { env: Record<string, string> } };\n\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor, @typescript-eslint/no-unused-vars\n constructor(opts: Partial<EnvFactoryOpts>) {\n // do nothing\n }\n\n register(env: Env): Env {\n return env;\n }\n\n active(): boolean {\n return typeof this.#node === \"object\" && typeof this.#node.process === \"object\" && typeof this.#node.process.env === \"object\";\n }\n readonly _env = this.active() ? this.#node.process.env : {};\n keys(): string[] {\n return Object.keys(this._env);\n }\n get(key: string): string | undefined {\n return this._env[key];\n }\n set(key: string, value?: string): void {\n if (value) {\n this._env[key] = value;\n }\n }\n delete(key: string): void {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._env[key];\n }\n}\n\nclass DenoEnvActions implements EnvActions {\n readonly #deno = globalThis as unknown as { Deno: { env: Map<string, string> } };\n\n get _env(): Map<string, string> {\n return this.#deno.Deno.env;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor, @typescript-eslint/no-unused-vars\n constructor(opts: Partial<EnvFactoryOpts>) {\n // do nothing\n }\n\n register(env: Env): Env {\n return env;\n }\n active(): boolean {\n return typeof this.#deno === \"object\" && typeof this.#deno.Deno === \"object\" && typeof this.#deno.Deno.env === \"object\";\n }\n keys(): string[] {\n return Array.from(this._env.keys());\n }\n get(key: string): string | undefined {\n return this._env.get(key);\n }\n set(key: string, value?: string): void {\n if (value) {\n this._env.set(key, value);\n }\n }\n delete(key: string): void {\n this._env.delete(key);\n }\n}\n\nexport class BrowserEnvActions implements EnvActions {\n readonly env: Map<string, string> = new Map<string, string>();\n readonly opts: Partial<EnvFactoryOpts>;\n constructor(opts: Partial<EnvFactoryOpts>) {\n this.opts = opts;\n }\n\n get(key: string): string | undefined {\n return this.env.get(key);\n }\n set(key: string, value?: string): void {\n if (value) {\n this.env.set(key, value);\n }\n }\n delete(key: string): void {\n this.env.delete(key);\n }\n keys(): string[] {\n return Array.from(this.env.keys());\n }\n active(): boolean {\n return true; // that should work on every runtime\n }\n\n register(env: Env): Env {\n const sym = Symbol.for(this.opts.symbol || \"CP_ENV\");\n const browser = globalThis as unknown as Record<symbol, Env>;\n browser[sym] = env;\n return env;\n }\n}\n\nexport interface EnvFactoryOpts {\n readonly symbol: string; // default \"CP_ENV\" used by BrowserEnvActions\n readonly presetEnv: Map<string, string>;\n}\n\ntype OnSetFn = (key: string, value?: string) => void;\nexport interface OnSetItem {\n readonly filter: Set<string>;\n readonly fn: OnSetFn;\n}\n\nexport interface Env extends EnvMap {\n onSet(fn: OnSetFn, ...filter: string[]): void;\n}\n\nconst _envFactory = new ResolveOnce<Env>();\nexport function envFactory(opts: Partial<EnvFactoryOpts> = {}): Env {\n return _envFactory.once(() => {\n const found = [new NodeEnvActions(opts), new DenoEnvActions(opts), new BrowserEnvActions(opts)].find((env) => env.active());\n if (!found) {\n throw new Error(\"SysContainer:envFactory: no env available\");\n }\n const ret = new EnvImpl(found, opts);\n found.register(ret);\n return ret;\n });\n}\n\nexport class EnvImpl implements Env {\n readonly _map: EnvMap;\n constructor(map: EnvMap, opts: Partial<EnvFactoryOpts> = {}) {\n this._map = map;\n this._updatePresets(opts.presetEnv);\n }\n _updatePresets(presetEnv?: Map<string, string>): void {\n if (!presetEnv) {\n return;\n }\n for (const [key, value] of presetEnv) {\n this._map.set(key, value);\n }\n }\n _applyOnSet(onSet: OnSetItem[], key?: string, value?: string): void {\n onSet.forEach((item) => {\n let keys: string[] = [];\n if (key) {\n keys = [key];\n } else {\n keys = this._map.keys();\n }\n keys\n .filter((k) => {\n if (item.filter.size === 0) {\n return true;\n }\n if (item.filter.has(k)) {\n return true;\n }\n return false;\n })\n .forEach((k) => {\n let v;\n if (!key && !value) {\n // init\n v = this._map.get(k);\n } else if (key && !value) {\n // del\n v = undefined;\n } else {\n // set\n v = value;\n }\n item.fn(k, v);\n });\n });\n }\n readonly _onSet: OnSetItem[] = [];\n keys(): string[] {\n return this._map.keys();\n }\n // filter is not set all sets passed\n onSet(fn: OnSetFn, ...filter: string[]): void {\n const item: OnSetItem = { filter: new Set(filter), fn };\n this._onSet.push(item);\n this._applyOnSet([item]);\n }\n get(key: string): string | undefined {\n return this._map.get(key);\n }\n set(key: string, value?: string): void {\n if (!value) {\n return;\n }\n this._map.set(key, value);\n this._applyOnSet(this._onSet, key, value);\n }\n delete(key: string): void {\n this._map.delete(key);\n this._applyOnSet(this._onSet, key);\n }\n}\n\n// export const envImpl = new EnvImpl();\n"],"mappings":";;;;;;;AAIO,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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