@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,47 @@
1
+ export async function stream2string(stream?: ReadableStream<Uint8Array> | null, maxSize?: number): Promise<string> {
2
+ if (!stream) {
3
+ return Promise.resolve("");
4
+ }
5
+ const reader = stream.getReader();
6
+ let res = "";
7
+ const decoder = new TextDecoder();
8
+ let rSize = 0;
9
+ while (typeof maxSize === "undefined" || rSize < maxSize) {
10
+ try {
11
+ const read = await reader.read();
12
+ if (read.done) {
13
+ break;
14
+ }
15
+ if (maxSize && rSize + read.value.length > maxSize) {
16
+ read.value = read.value.slice(0, maxSize - rSize);
17
+ }
18
+ const block = decoder.decode(read.value, { stream: true });
19
+ rSize += read.value.length;
20
+ res += block;
21
+ } catch (err) {
22
+ return Promise.reject(err);
23
+ }
24
+ }
25
+ return Promise.resolve(res);
26
+ }
27
+
28
+ export async function stream2uint8array(stream?: ReadableStream<Uint8Array> | null): Promise<Uint8Array> {
29
+ if (!stream) {
30
+ return Promise.resolve(new Uint8Array());
31
+ }
32
+ const reader = stream.getReader();
33
+ let res = new Uint8Array();
34
+ // eslint-disable-next-line no-constant-condition
35
+ while (1) {
36
+ try {
37
+ const { done, value } = await reader.read();
38
+ if (done) {
39
+ break;
40
+ }
41
+ res = new Uint8Array([...res, ...value]);
42
+ } catch (err) {
43
+ return Promise.reject(err);
44
+ }
45
+ }
46
+ return Promise.resolve(res);
47
+ }
@@ -0,0 +1,14 @@
1
+ import { TxtEnDecoder, Utf8EnDecoderSingleton } from "../txt-en-decoder.js";
2
+
3
+ export function string2stream(str: string, ende: TxtEnDecoder = Utf8EnDecoderSingleton()): ReadableStream<Uint8Array> {
4
+ return uint8array2stream(ende.encode(str));
5
+ }
6
+
7
+ export function uint8array2stream(str: Uint8Array): ReadableStream<Uint8Array> {
8
+ return new ReadableStream<Uint8Array>({
9
+ start(controller): void {
10
+ controller.enqueue(str);
11
+ controller.close();
12
+ },
13
+ });
14
+ }
package/src/version.ts ADDED
@@ -0,0 +1,3 @@
1
+ export const VERSION = Object.keys({
2
+ __packageVersion__: "xxxx",
3
+ })[0] as string;
@@ -0,0 +1 @@
1
+ export * from "./web-sys-abstraction.js";
@@ -0,0 +1,80 @@
1
+ import { BaseSysAbstraction, WrapperSysAbstraction, WrapperSysAbstractionParams } from "../base-sys-abstraction.js";
2
+ import { FileService, NamedWritableStream } from "../file-service.js";
3
+ import { SysAbstraction, SystemService, VoidFunc } from "../sys-abstraction.js";
4
+ import { Env, envFactory } from "../sys-env.js";
5
+ import { Utf8EnDecoderSingleton } from "../txt-en-decoder.js";
6
+
7
+ class WebFileService implements FileService {
8
+ get baseDir(): string {
9
+ throw new Error("basedir-Method not implemented.");
10
+ }
11
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
12
+ create(fname: string): Promise<NamedWritableStream> {
13
+ throw new Error("create-Method not implemented.");
14
+ }
15
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
16
+ readFileString(fname: string): Promise<string> {
17
+ throw new Error("readFileString-Method not implemented.");
18
+ }
19
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
20
+ writeFileString(fname: string, content: string): Promise<void> {
21
+ throw new Error("writeFileString-Method not implemented.");
22
+ }
23
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
24
+ abs(fname: string): string {
25
+ throw new Error("abs-Method not implemented.");
26
+ }
27
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
28
+ join(...paths: string[]): string {
29
+ throw new Error("join-Method not implemented.");
30
+ }
31
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
32
+ relative(from: string, to?: string | undefined): string {
33
+ throw new Error("relative-Method not implemented.");
34
+ }
35
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
36
+ dirname(fname: string): string {
37
+ throw new Error("dirname-Method not implemented.");
38
+ }
39
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
40
+ basename(fname: string): string {
41
+ throw new Error("basename-Method not implemented.");
42
+ }
43
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
44
+ nodeImport(fname: string): string {
45
+ throw new Error("nodeImport-Method not implemented.");
46
+ }
47
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
48
+ isAbsolute(fname: string): boolean {
49
+ throw new Error("isAbsolute-Method not implemented.");
50
+ }
51
+ }
52
+
53
+ class WebSystemService implements SystemService {
54
+ Env(): Env {
55
+ return envFactory();
56
+ }
57
+ Args(): string[] {
58
+ throw new Error("Args-Method not implemented.");
59
+ }
60
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
61
+ OnExit(hdl: VoidFunc): VoidFunc {
62
+ throw new Error("OnExit-Method not implemented.");
63
+ }
64
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
65
+ Exit(code: number): void {
66
+ throw new Error("Exit-Method not implemented.");
67
+ }
68
+ }
69
+
70
+ let my: BaseSysAbstraction | undefined = undefined;
71
+ export function WebSysAbstraction(param?: WrapperSysAbstractionParams): SysAbstraction {
72
+ if (!my) {
73
+ my = new BaseSysAbstraction({
74
+ TxtEnDecoder: param?.TxtEnDecoder || Utf8EnDecoderSingleton(),
75
+ FileSystem: new WebFileService(),
76
+ SystemService: new WebSystemService(),
77
+ });
78
+ }
79
+ return new WrapperSysAbstraction(my, param);
80
+ }
package/ts/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/ts/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # cement
2
+
3
+ An Agnostic Platform Wrapper
4
+
5
+ which Provides:
6
+
7
+ - SysAbstraction
8
+ ```typescript
9
+ export interface SysAbstraction {
10
+ Time(): Time;
11
+ Stdout(): WritableStream<Uint8Array>;
12
+ Stderr(): WritableStream<Uint8Array>;
13
+ NextId(): string;
14
+ Random0ToValue(value: number): number;
15
+ System(): SystemService;
16
+ FileSystem(): FileService;
17
+ }
18
+ ```
19
+ - Logger inspired from golang zlogger
20
+ ```typescript
21
+ export interface LoggerInterface<R> {
22
+ Module(key: string): R;
23
+ SetDebug(...modules: (string | string[])[]): R;
24
+
25
+ Str(key: string, value: string): R;
26
+ Error(): R;
27
+ Warn(): R;
28
+ Debug(): R;
29
+ Log(): R;
30
+ WithLevel(level: Level): R;
31
+
32
+ Err(err: unknown): R; // could be Error, or something which coerces to string
33
+ Info(): R;
34
+ Timestamp(): R;
35
+ Any(key: string, value: unknown): R;
36
+ Dur(key: string, nsec: number): R;
37
+ Uint64(key: string, value: number): R;
38
+ }
39
+ ```
@@ -0,0 +1,84 @@
1
+ import { FileService } from "./file-service.js";
2
+ import { TimeMode, RandomMode, IDMode, SystemService, VoidFunc, SysAbstraction } from "./sys-abstraction.js";
3
+ import { Time } from "./time.js";
4
+ import { TxtEnDecoder } from "./txt-en-decoder.js";
5
+ export declare class SysTime extends Time {
6
+ Now(): Date;
7
+ Sleep(duration: number): Promise<void>;
8
+ }
9
+ export declare class ConstTime extends Time {
10
+ Now(): Date;
11
+ Sleep(duration: number): Promise<void>;
12
+ }
13
+ export declare class StepTime extends Time {
14
+ _step: Date;
15
+ readonly _start: Date;
16
+ constructor();
17
+ Now(steps?: number): Date;
18
+ Sleep(duration: number): Promise<void>;
19
+ }
20
+ export declare function TimeFactory(timeMode: TimeMode): Time;
21
+ export declare class RandomService {
22
+ readonly _mode: RandomMode;
23
+ _step: number;
24
+ constructor(mode: RandomMode);
25
+ Random0ToValue(value: number): number;
26
+ }
27
+ export declare class IdService {
28
+ readonly _mode: IDMode;
29
+ _step: number;
30
+ constructor(mode?: IDMode);
31
+ NextId(): string;
32
+ }
33
+ export interface BaseSysAbstractionParams {
34
+ readonly TxtEnDecoder: TxtEnDecoder;
35
+ readonly FileSystem: FileService;
36
+ readonly SystemService: SystemService;
37
+ }
38
+ export interface ExitHandler {
39
+ readonly hdl: VoidFunc;
40
+ readonly id: string;
41
+ }
42
+ export interface ExitService {
43
+ injectExitHandlers(hdls: ExitHandler[]): void;
44
+ exit(code: number): void;
45
+ }
46
+ export declare class BaseSysAbstraction {
47
+ readonly _time: SysTime;
48
+ readonly _stdout: WritableStream;
49
+ readonly _stderr: WritableStream;
50
+ readonly _idService: IdService;
51
+ readonly _randomService: RandomService;
52
+ readonly _fileSystem: FileService;
53
+ readonly _systemService: SystemService;
54
+ readonly _txtEnDe: TxtEnDecoder;
55
+ constructor(params: BaseSysAbstractionParams);
56
+ }
57
+ export interface WrapperSysAbstractionParams {
58
+ readonly TimeMode?: TimeMode;
59
+ readonly IdMode?: IDMode;
60
+ readonly Stdout?: WritableStream<Uint8Array>;
61
+ readonly Stderr?: WritableStream<Uint8Array>;
62
+ readonly RandomMode?: RandomMode;
63
+ readonly FileSystem?: FileService;
64
+ readonly SystemService?: SystemService;
65
+ readonly TxtEnDecoder?: TxtEnDecoder;
66
+ }
67
+ export declare class WrapperSysAbstraction implements SysAbstraction {
68
+ readonly _time: Time;
69
+ readonly _stdout: WritableStream<Uint8Array>;
70
+ readonly _stderr: WritableStream<Uint8Array>;
71
+ readonly _idService: IdService;
72
+ readonly _randomService: RandomService;
73
+ readonly _fileSystem: FileService;
74
+ readonly _systemService: SystemService;
75
+ constructor(base: BaseSysAbstraction, params?: WrapperSysAbstractionParams);
76
+ Time(): Time;
77
+ NextId(): string;
78
+ Random0ToValue(value: number): number;
79
+ Stdout(): WritableStream;
80
+ Stderr(): WritableStream;
81
+ System(): SystemService;
82
+ FileSystem(): FileService;
83
+ }
84
+ //# sourceMappingURL=base-sys-abstraction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-sys-abstraction.d.ts","sourceRoot":"","sources":["../../src/base-sys-abstraction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC7G,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,qBAAa,OAAQ,SAAQ,IAAI;IAC/B,GAAG,IAAI,IAAI;IAGX,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAOvC;AAED,qBAAa,SAAU,SAAQ,IAAI;IACjC,GAAG,IAAI,IAAI;IAIX,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGvC;AAED,qBAAa,QAAS,SAAQ,IAAI;IAChC,KAAK,EAAE,IAAI,CAAC;IACZ,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;;IAMtB,GAAG,CAAC,KAAK,SAAI,GAAG,IAAI;IAcpB,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAIvC;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAUpD;AAED,qBAAa,aAAa;IACxB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,KAAK,SAAK;gBACE,IAAI,EAAE,UAAU;IAG5B,cAAc,CAAC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AAC,MAAM,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IAC7C,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;IACjC,QAAQ,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC;IACvC,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;CACtC;AAED,qBAAa,qBAAsB,YAAW,cAAc;IAC1D,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IAC7C,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IAC7C,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,QAAQ,CAAC,cAAc,EAAE,aAAa,CAAC;IACvC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,cAAc,EAAE,aAAa,CAAC;gBAC3B,IAAI,EAAE,kBAAkB,EAAE,MAAM,CAAC,EAAE,2BAA2B;IAgC1E,IAAI,IAAI,IAAI;IAGZ,MAAM,IAAI,MAAM;IAGhB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAGrC,MAAM,IAAI,cAAc;IAGxB,MAAM,IAAI,cAAc;IAIxB,MAAM,IAAI,aAAa;IAGvB,UAAU,IAAI,WAAW;CAG1B"}
@@ -0,0 +1,178 @@
1
+ import { TimeMode, RandomMode, IDMode } from "./sys-abstraction.js";
2
+ import { Time } from "./time.js";
3
+ export class SysTime extends Time {
4
+ Now() {
5
+ return new Date();
6
+ }
7
+ Sleep(duration) {
8
+ return new Promise((resolve) => {
9
+ setTimeout(() => {
10
+ resolve();
11
+ }, duration);
12
+ });
13
+ }
14
+ }
15
+ export class ConstTime extends Time {
16
+ Now() {
17
+ return new Date(2021, 1, 1, 0, 0, 0, 0);
18
+ }
19
+ Sleep(duration) {
20
+ return Promise.resolve();
21
+ }
22
+ }
23
+ export class StepTime extends Time {
24
+ constructor() {
25
+ super();
26
+ this._step = new ConstTime().Now();
27
+ this._start = this._step;
28
+ }
29
+ Now(steps = 1) {
30
+ for (let i = 0; steps > 0 && i < steps; i++) {
31
+ this._step = new Date(this._step.getTime() + 1000);
32
+ }
33
+ if (steps < 1) {
34
+ this._step = new Date(this._start.getTime() + steps * -1000);
35
+ }
36
+ return this._step;
37
+ }
38
+ Sleep(duration) {
39
+ this._step = new Date(this._step.getTime() + duration);
40
+ return Promise.resolve();
41
+ }
42
+ }
43
+ export function TimeFactory(timeMode) {
44
+ switch (timeMode) {
45
+ case TimeMode.REAL:
46
+ return new SysTime();
47
+ case TimeMode.CONST:
48
+ return new ConstTime();
49
+ case TimeMode.STEP:
50
+ return new StepTime();
51
+ }
52
+ return new SysTime();
53
+ }
54
+ export class RandomService {
55
+ constructor(mode) {
56
+ this._step = 0;
57
+ this._mode = mode;
58
+ }
59
+ Random0ToValue(value) {
60
+ switch (this._mode) {
61
+ case RandomMode.CONST:
62
+ return 0.5 * value;
63
+ case RandomMode.STEP:
64
+ this._step += 0.0001;
65
+ return this._step * value;
66
+ case RandomMode.RANDOM:
67
+ return Math.random() * value;
68
+ default:
69
+ throw new Error("Unknown RandomMode");
70
+ }
71
+ }
72
+ }
73
+ export class IdService {
74
+ constructor(mode) {
75
+ this._step = 0;
76
+ if (!mode) {
77
+ mode = IDMode.UUID;
78
+ }
79
+ this._mode = mode;
80
+ }
81
+ NextId() {
82
+ switch (this._mode) {
83
+ case IDMode.UUID:
84
+ return crypto.randomUUID();
85
+ case IDMode.CONST:
86
+ return "VeryUniqueID";
87
+ case IDMode.STEP:
88
+ return `STEPId-${this._step++}`;
89
+ default:
90
+ throw new Error("Unknown IDMode");
91
+ }
92
+ }
93
+ }
94
+ export class BaseSysAbstraction {
95
+ constructor(params) {
96
+ this._time = new SysTime();
97
+ this._idService = new IdService();
98
+ this._randomService = new RandomService(RandomMode.RANDOM);
99
+ this._fileSystem = params.FileSystem;
100
+ this._systemService = params.SystemService;
101
+ this._txtEnDe = params.TxtEnDecoder;
102
+ const decoder = this._txtEnDe;
103
+ this._stdout = new WritableStream({
104
+ write(chunk) {
105
+ return new Promise((resolve) => {
106
+ const decoded = decoder.decode(chunk);
107
+ console.log(decoded.trimEnd());
108
+ resolve();
109
+ });
110
+ },
111
+ });
112
+ this._stderr = new WritableStream({
113
+ write(chunk) {
114
+ return new Promise((resolve) => {
115
+ const decoded = decoder.decode(chunk);
116
+ console.error(decoded.trimEnd());
117
+ resolve();
118
+ });
119
+ },
120
+ });
121
+ }
122
+ }
123
+ export class WrapperSysAbstraction {
124
+ constructor(base, params) {
125
+ this._time = base._time;
126
+ this._stdout = base._stdout;
127
+ this._stderr = base._stderr;
128
+ this._idService = base._idService;
129
+ this._randomService = base._randomService;
130
+ this._fileSystem = base._fileSystem;
131
+ this._systemService = base._systemService;
132
+ if (params) {
133
+ if (params.TimeMode) {
134
+ this._time = TimeFactory(params.TimeMode);
135
+ }
136
+ if (params.Stdout) {
137
+ this._stdout = params.Stdout;
138
+ }
139
+ if (params.Stderr) {
140
+ this._stderr = params.Stderr;
141
+ }
142
+ if (params.IdMode) {
143
+ this._idService = new IdService(params.IdMode);
144
+ }
145
+ if (params.RandomMode) {
146
+ this._randomService = new RandomService(params.RandomMode);
147
+ }
148
+ if (params.FileSystem) {
149
+ this._fileSystem = params.FileSystem;
150
+ }
151
+ if (params.SystemService) {
152
+ this._systemService = params.SystemService;
153
+ }
154
+ }
155
+ }
156
+ Time() {
157
+ return this._time;
158
+ }
159
+ NextId() {
160
+ return this._idService.NextId();
161
+ }
162
+ Random0ToValue(value) {
163
+ return this._randomService.Random0ToValue(value);
164
+ }
165
+ Stdout() {
166
+ return this._stdout;
167
+ }
168
+ Stderr() {
169
+ return this._stderr;
170
+ }
171
+ System() {
172
+ return this._systemService;
173
+ }
174
+ FileSystem() {
175
+ return this._fileSystem;
176
+ }
177
+ }
178
+ //# sourceMappingURL=base-sys-abstraction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-sys-abstraction.js","sourceRoot":"","sources":["../../src/base-sys-abstraction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAA2C,MAAM,sBAAsB,CAAC;AAC7G,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,MAAM,OAAO,OAAQ,SAAQ,IAAI;IAC/B,GAAG;QACD,OAAO,IAAI,IAAI,EAAE,CAAC;IACpB,CAAC;IACD,KAAK,CAAC,QAAgB;QACpB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,UAAU,CAAC,GAAG,EAAE;gBACd,OAAO,EAAE,CAAC;YACZ,CAAC,EAAE,QAAQ,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,OAAO,SAAU,SAAQ,IAAI;IACjC,GAAG;QACD,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,QAAgB;QACpB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CACF;AAED,MAAM,OAAO,QAAS,SAAQ,IAAI;IAGhC;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,IAAI,SAAS,EAAE,CAAC,GAAG,EAAE,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC;IAC3B,CAAC;IACD,GAAG,CAAC,KAAK,GAAG,CAAC;QAKX,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;YAC5C,IAAI,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,IAA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