@adviser/cement 0.2.28 → 0.2.29

Sign up to get free protection for your applications and to get access to all the features.
Files changed (319) hide show
  1. package/{base-sys-abstraction-C9WW3w57.d.cts → base-sys-abstraction-BkEiLHl0.d.ts} +8 -4
  2. package/{base-sys-abstraction-C9WW3w57.d.ts → base-sys-abstraction-Qj7pkY1N.d.cts} +8 -4
  3. package/{chunk-OXD3YZZ7.js → chunk-7KFVMTOS.js} +3 -47
  4. package/chunk-7KFVMTOS.js.map +1 -0
  5. package/{chunk-P5RXA4C4.js → chunk-GES3MUGV.js} +24 -27
  6. package/{chunk-LCPYQVWT.js.map → chunk-GES3MUGV.js.map} +1 -1
  7. package/{chunk-YDIUMYIE.js → chunk-Q65HLCNL.js} +8 -7
  8. package/chunk-Q65HLCNL.js.map +1 -0
  9. package/{chunk-DPIL5UIL.js → chunk-WMMUXBDX.js} +6 -2
  10. package/chunk-WMMUXBDX.js.map +1 -0
  11. package/{index-Dhb2fQiw.d.cts → index-Q3phXzYr.d.cts} +2 -21
  12. package/{index-CcsGcehs.d.ts → index-tIGZMHTc.d.ts} +2 -21
  13. package/index.cjs +264 -7343
  14. package/index.cjs.map +1 -1
  15. package/index.d.cts +72 -12
  16. package/index.d.ts +72 -12
  17. package/index.js +217 -7265
  18. package/index.js.map +1 -1
  19. package/node/index.cjs +220 -39
  20. package/node/index.cjs.map +1 -1
  21. package/node/index.d.cts +22 -4
  22. package/node/index.d.ts +22 -4
  23. package/node/index.js +201 -25
  24. package/node/index.js.map +1 -1
  25. package/package.json +23 -12
  26. package/src/LICENSE +201 -0
  27. package/src/README.md +39 -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/base-sys-abstraction.d.ts +84 -0
  78. package/ts/base-sys-abstraction.d.ts.map +1 -0
  79. package/ts/base-sys-abstraction.js +178 -0
  80. package/ts/base-sys-abstraction.js.map +1 -0
  81. package/ts/base-sys-abstraction.test.d.ts +2 -0
  82. package/ts/base-sys-abstraction.test.d.ts.map +1 -0
  83. package/ts/base-sys-abstraction.test.js +82 -0
  84. package/ts/base-sys-abstraction.test.js.map +1 -0
  85. package/ts/bin2text.d.ts +3 -0
  86. package/ts/bin2text.d.ts.map +1 -0
  87. package/ts/bin2text.js +43 -0
  88. package/ts/bin2text.js.map +1 -0
  89. package/ts/bin2text.test.d.ts +2 -0
  90. package/ts/bin2text.test.d.ts.map +1 -0
  91. package/ts/bin2text.test.js +51 -0
  92. package/ts/bin2text.test.js.map +1 -0
  93. package/ts/crypto.d.ts +76 -0
  94. package/ts/crypto.d.ts.map +1 -0
  95. package/ts/crypto.js +22 -0
  96. package/ts/crypto.js.map +1 -0
  97. package/ts/crypto.test.d.ts +2 -0
  98. package/ts/crypto.test.d.ts.map +1 -0
  99. package/ts/crypto.test.js +14 -0
  100. package/ts/crypto.test.js.map +1 -0
  101. package/ts/file-service.d.ts +17 -0
  102. package/ts/file-service.d.ts.map +1 -0
  103. package/ts/file-service.js +2 -0
  104. package/ts/file-service.js.map +1 -0
  105. package/ts/future.d.ts +8 -0
  106. package/ts/future.d.ts.map +1 -0
  107. package/ts/future.js +38 -0
  108. package/ts/future.js.map +1 -0
  109. package/ts/future.test.d.ts +2 -0
  110. package/ts/future.test.d.ts.map +1 -0
  111. package/ts/future.test.js +28 -0
  112. package/ts/future.test.js.map +1 -0
  113. package/ts/index.d.ts +23 -0
  114. package/ts/index.d.ts.map +1 -0
  115. package/ts/index.js +23 -0
  116. package/ts/index.js.map +1 -0
  117. package/ts/log-level-impl.d.ts +14 -0
  118. package/ts/log-level-impl.d.ts.map +1 -0
  119. package/ts/log-level-impl.js +72 -0
  120. package/ts/log-level-impl.js.map +1 -0
  121. package/ts/log-writer-impl.d.ts +10 -0
  122. package/ts/log-writer-impl.d.ts.map +1 -0
  123. package/ts/log-writer-impl.js +45 -0
  124. package/ts/log-writer-impl.js.map +1 -0
  125. package/ts/logger-impl.d.ts +71 -0
  126. package/ts/logger-impl.d.ts.map +1 -0
  127. package/ts/logger-impl.js +412 -0
  128. package/ts/logger-impl.js.map +1 -0
  129. package/ts/logger.d.ts +84 -0
  130. package/ts/logger.d.ts.map +1 -0
  131. package/ts/logger.js +114 -0
  132. package/ts/logger.js.map +1 -0
  133. package/ts/logger.test.d.ts +2 -0
  134. package/ts/logger.test.d.ts.map +1 -0
  135. package/ts/logger.test.js +1023 -0
  136. package/ts/logger.test.js.map +1 -0
  137. package/ts/node/deno-file-service.d.ts +17 -0
  138. package/ts/node/deno-file-service.d.ts.map +1 -0
  139. package/ts/node/deno-file-service.js +65 -0
  140. package/ts/node/deno-file-service.js.map +1 -0
  141. package/ts/node/deno-sys-abstraction.d.ts +22 -0
  142. package/ts/node/deno-sys-abstraction.d.ts.map +1 -0
  143. package/ts/node/deno-sys-abstraction.js +101 -0
  144. package/ts/node/deno-sys-abstraction.js.map +1 -0
  145. package/ts/node/index.d.ts +5 -0
  146. package/ts/node/index.d.ts.map +1 -0
  147. package/ts/node/index.js +5 -0
  148. package/ts/node/index.js.map +1 -0
  149. package/ts/node/mock-file-service.d.ts +11 -0
  150. package/ts/node/mock-file-service.d.ts.map +1 -0
  151. package/ts/node/mock-file-service.js +34 -0
  152. package/ts/node/mock-file-service.js.map +1 -0
  153. package/ts/node/mock-file-service.test.d.ts +2 -0
  154. package/ts/node/mock-file-service.test.d.ts.map +1 -0
  155. package/ts/node/mock-file-service.test.js +31 -0
  156. package/ts/node/mock-file-service.test.js.map +1 -0
  157. package/ts/node/node-file-service.d.ts +16 -0
  158. package/ts/node/node-file-service.d.ts.map +1 -0
  159. package/ts/node/node-file-service.js +71 -0
  160. package/ts/node/node-file-service.js.map +1 -0
  161. package/ts/node/node-sys-abstraction.d.ts +22 -0
  162. package/ts/node/node-sys-abstraction.d.ts.map +1 -0
  163. package/ts/node/node-sys-abstraction.js +99 -0
  164. package/ts/node/node-sys-abstraction.js.map +1 -0
  165. package/ts/node/node-sys-abstraction.test.d.ts +2 -0
  166. package/ts/node/node-sys-abstraction.test.d.ts.map +1 -0
  167. package/ts/node/node-sys-abstraction.test.js +87 -0
  168. package/ts/node/node-sys-abstraction.test.js.map +1 -0
  169. package/ts/option.d.ts +25 -0
  170. package/ts/option.d.ts.map +1 -0
  171. package/ts/option.js +47 -0
  172. package/ts/option.js.map +1 -0
  173. package/ts/resolve-once.d.ts +46 -0
  174. package/ts/resolve-once.d.ts.map +1 -0
  175. package/ts/resolve-once.js +152 -0
  176. package/ts/resolve-once.js.map +1 -0
  177. package/ts/resolve-once.test.d.ts +2 -0
  178. package/ts/resolve-once.test.d.ts.map +1 -0
  179. package/ts/resolve-once.test.js +283 -0
  180. package/ts/resolve-once.test.js.map +1 -0
  181. package/ts/result.d.ts +34 -0
  182. package/ts/result.d.ts.map +1 -0
  183. package/ts/result.js +85 -0
  184. package/ts/result.js.map +1 -0
  185. package/ts/result.test.d.ts +2 -0
  186. package/ts/result.test.d.ts.map +1 -0
  187. package/ts/result.test.js +79 -0
  188. package/ts/result.test.js.map +1 -0
  189. package/ts/runtime.d.ts +8 -0
  190. package/ts/runtime.d.ts.map +1 -0
  191. package/ts/runtime.js +26 -0
  192. package/ts/runtime.js.map +1 -0
  193. package/ts/sys-abstraction.d.ts +36 -0
  194. package/ts/sys-abstraction.d.ts.map +1 -0
  195. package/ts/sys-abstraction.js +31 -0
  196. package/ts/sys-abstraction.js.map +1 -0
  197. package/ts/sys-env.d.ts +48 -0
  198. package/ts/sys-env.d.ts.map +1 -0
  199. package/ts/sys-env.js +176 -0
  200. package/ts/sys-env.js.map +1 -0
  201. package/ts/sys-env.test.d.ts +2 -0
  202. package/ts/sys-env.test.d.ts.map +1 -0
  203. package/ts/sys-env.test.js +51 -0
  204. package/ts/sys-env.test.js.map +1 -0
  205. package/ts/test/log-write-stream.d.ts +27 -0
  206. package/ts/test/log-write-stream.d.ts.map +1 -0
  207. package/ts/test/log-write-stream.js +74 -0
  208. package/ts/test/log-write-stream.js.map +1 -0
  209. package/ts/test/mock-logger.d.ts +14 -0
  210. package/ts/test/mock-logger.d.ts.map +1 -0
  211. package/ts/test/mock-logger.js +29 -0
  212. package/ts/test/mock-logger.js.map +1 -0
  213. package/ts/test/mock-logger.test.d.ts +2 -0
  214. package/ts/test/mock-logger.test.d.ts.map +1 -0
  215. package/ts/test/mock-logger.test.js +63 -0
  216. package/ts/test/mock-logger.test.js.map +1 -0
  217. package/ts/test/test-exit-handler.d.ts +2 -0
  218. package/ts/test/test-exit-handler.d.ts.map +1 -0
  219. package/ts/test/test-exit-handler.js +57 -0
  220. package/ts/test/test-exit-handler.js.map +1 -0
  221. package/ts/time.d.ts +13 -0
  222. package/ts/time.d.ts.map +1 -0
  223. package/ts/time.js +14 -0
  224. package/ts/time.js.map +1 -0
  225. package/ts/tracer.d.ts +59 -0
  226. package/ts/tracer.d.ts.map +1 -0
  227. package/ts/tracer.js +148 -0
  228. package/ts/tracer.js.map +1 -0
  229. package/ts/tracer.test.d.ts +2 -0
  230. package/ts/tracer.test.d.ts.map +1 -0
  231. package/ts/tracer.test.js +311 -0
  232. package/ts/tracer.test.js.map +1 -0
  233. package/ts/txt-en-decoder.d.ts +10 -0
  234. package/ts/txt-en-decoder.d.ts.map +1 -0
  235. package/ts/txt-en-decoder.js +15 -0
  236. package/ts/txt-en-decoder.js.map +1 -0
  237. package/ts/uri.d.ts +67 -0
  238. package/ts/uri.d.ts.map +1 -0
  239. package/ts/uri.js +283 -0
  240. package/ts/uri.js.map +1 -0
  241. package/ts/uri.test.d.ts +2 -0
  242. package/ts/uri.test.d.ts.map +1 -0
  243. package/ts/uri.test.js +119 -0
  244. package/ts/uri.test.js.map +1 -0
  245. package/ts/utils/console-write-stream.d.ts +21 -0
  246. package/ts/utils/console-write-stream.d.ts.map +1 -0
  247. package/ts/utils/console-write-stream.js +62 -0
  248. package/ts/utils/console-write-stream.js.map +1 -0
  249. package/ts/utils/fanout-write-stream.d.ts +12 -0
  250. package/ts/utils/fanout-write-stream.d.ts.map +1 -0
  251. package/ts/utils/fanout-write-stream.js +24 -0
  252. package/ts/utils/fanout-write-stream.js.map +1 -0
  253. package/ts/utils/index.d.ts +7 -0
  254. package/ts/utils/index.d.ts.map +1 -0
  255. package/ts/utils/index.js +7 -0
  256. package/ts/utils/index.js.map +1 -0
  257. package/ts/utils/rebuffer.d.ts +3 -0
  258. package/ts/utils/rebuffer.d.ts.map +1 -0
  259. package/ts/utils/rebuffer.js +60 -0
  260. package/ts/utils/rebuffer.js.map +1 -0
  261. package/ts/utils/rebuffer.test.d.ts +2 -0
  262. package/ts/utils/rebuffer.test.d.ts.map +1 -0
  263. package/ts/utils/rebuffer.test.js +77 -0
  264. package/ts/utils/rebuffer.test.js.map +1 -0
  265. package/ts/utils/stream-map.d.ts +9 -0
  266. package/ts/utils/stream-map.d.ts.map +1 -0
  267. package/ts/utils/stream-map.js +62 -0
  268. package/ts/utils/stream-map.js.map +1 -0
  269. package/ts/utils/stream-map.test.d.ts +2 -0
  270. package/ts/utils/stream-map.test.d.ts.map +1 -0
  271. package/ts/utils/stream-map.test.js +87 -0
  272. package/ts/utils/stream-map.test.js.map +1 -0
  273. package/ts/utils/stream-test-helper.d.ts +17 -0
  274. package/ts/utils/stream-test-helper.d.ts.map +1 -0
  275. package/ts/utils/stream-test-helper.js +37 -0
  276. package/ts/utils/stream-test-helper.js.map +1 -0
  277. package/ts/utils/stream2string.d.ts +3 -0
  278. package/ts/utils/stream2string.d.ts.map +1 -0
  279. package/ts/utils/stream2string.js +48 -0
  280. package/ts/utils/stream2string.js.map +1 -0
  281. package/ts/utils/stream2string.test.d.ts +2 -0
  282. package/ts/utils/stream2string.test.d.ts.map +1 -0
  283. package/ts/utils/stream2string.test.js +29 -0
  284. package/ts/utils/stream2string.test.js.map +1 -0
  285. package/ts/utils/string2stream.d.ts +4 -0
  286. package/ts/utils/string2stream.d.ts.map +1 -0
  287. package/ts/utils/string2stream.js +13 -0
  288. package/ts/utils/string2stream.js.map +1 -0
  289. package/ts/utils/string2stream.test.d.ts +2 -0
  290. package/ts/utils/string2stream.test.d.ts.map +1 -0
  291. package/ts/utils/string2stream.test.js +6 -0
  292. package/ts/utils/string2stream.test.js.map +1 -0
  293. package/ts/version.d.ts +2 -0
  294. package/ts/version.d.ts.map +1 -0
  295. package/ts/version.js +4 -0
  296. package/ts/version.js.map +1 -0
  297. package/ts/web/index.d.ts +2 -0
  298. package/ts/web/index.d.ts.map +1 -0
  299. package/ts/web/index.js +2 -0
  300. package/ts/web/index.js.map +1 -0
  301. package/ts/web/web-sys-abstraction.d.ts +4 -0
  302. package/ts/web/web-sys-abstraction.d.ts.map +1 -0
  303. package/ts/web/web-sys-abstraction.js +64 -0
  304. package/ts/web/web-sys-abstraction.js.map +1 -0
  305. package/utils/index.cjs +0 -42
  306. package/utils/index.cjs.map +1 -1
  307. package/utils/index.d.cts +1 -2
  308. package/utils/index.d.ts +1 -2
  309. package/utils/index.js +2 -7
  310. package/web/index.cjs +25 -7
  311. package/web/index.cjs.map +1 -1
  312. package/web/index.d.cts +2 -1
  313. package/web/index.d.ts +2 -1
  314. package/web/index.js +3 -3
  315. package/chunk-DPIL5UIL.js.map +0 -1
  316. package/chunk-LCPYQVWT.js +0 -21
  317. package/chunk-OXD3YZZ7.js.map +0 -1
  318. package/chunk-P5RXA4C4.js.map +0 -1
  319. package/chunk-YDIUMYIE.js.map +0 -1
package/src/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/src/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,95 @@
1
+ import { runtimeFn, IDMode, TimeMode, RandomMode } from "@adviser/cement";
2
+ import { DenoSysAbstraction, NodeSysAbstraction } from "@adviser/cement/node";
3
+ import { WebSysAbstraction } from "@adviser/cement/web";
4
+
5
+ const abstractions = [];
6
+
7
+ if (runtimeFn().isNodeIsh) {
8
+ abstractions.push({ name: "NodeSysAbstraction", fn: NodeSysAbstraction });
9
+ }
10
+
11
+ if (runtimeFn().isDeno) {
12
+ abstractions.push({ name: "DenoSysAbstraction", fn: DenoSysAbstraction });
13
+ }
14
+
15
+ if (runtimeFn().isBrowser) {
16
+ abstractions.push({ name: "WebSysAbstraction", fn: WebSysAbstraction });
17
+ }
18
+
19
+ for (const abstraction of abstractions) {
20
+ describe(abstraction.name, () => {
21
+ it("IdService UUID", () => {
22
+ const sys = abstraction.fn();
23
+ const id1 = sys.NextId();
24
+ const id2 = sys.NextId();
25
+ expect(id1).not.toEqual(id2);
26
+ });
27
+
28
+ it("IdService explict UUID", () => {
29
+ const sys = abstraction.fn({ IdMode: IDMode.UUID });
30
+ const id1 = sys.NextId();
31
+ const id2 = sys.NextId();
32
+ expect(id1).not.toEqual(id2);
33
+ });
34
+
35
+ it("IdService const", () => {
36
+ const sys = abstraction.fn({ IdMode: IDMode.CONST });
37
+ const id1 = sys.NextId();
38
+ const id2 = sys.NextId();
39
+ expect(id1).toEqual(id2);
40
+ });
41
+
42
+ it("IdService set", () => {
43
+ for (let i = 0; i < 10; i++) {
44
+ const sys = abstraction.fn({ IdMode: IDMode.STEP });
45
+ const id1 = sys.NextId();
46
+ const id2 = sys.NextId();
47
+ expect(id1).toEqual("STEPId-0");
48
+ expect(id2).toEqual("STEPId-1");
49
+ }
50
+ });
51
+
52
+ it("time sleep", async () => {
53
+ const sys = abstraction.fn();
54
+ const start = sys.Time().Now();
55
+ await sys.Time().Sleep(100);
56
+ expect(sys.Time().TimeSince(start)).toBeGreaterThan(90);
57
+ });
58
+
59
+ it("time sleep const", async () => {
60
+ const sys = abstraction.fn({ TimeMode: TimeMode.REAL });
61
+ const start = new Date();
62
+ await sys.Time().Sleep(100);
63
+ const end = new Date();
64
+ expect(end.getTime() - start.getTime()).toBeGreaterThan(90);
65
+ });
66
+
67
+ it("time sleep step", async () => {
68
+ const sys = abstraction.fn({ TimeMode: TimeMode.STEP });
69
+ const start = sys.Time().Now();
70
+ await sys.Time().Sleep(86400500);
71
+ expect(sys.Time().Now().getTime() - start.getTime()).toEqual(86401500);
72
+ });
73
+
74
+ it("const random", () => {
75
+ const sys = abstraction.fn({ RandomMode: RandomMode.CONST });
76
+ expect(sys.Random0ToValue(10)).toEqual(5);
77
+ expect(sys.Random0ToValue(10)).toEqual(5);
78
+ });
79
+
80
+ it("step random", () => {
81
+ const sys = abstraction.fn({ RandomMode: RandomMode.STEP });
82
+ expect(sys.Random0ToValue(10000)).toEqual(1);
83
+ expect(sys.Random0ToValue(10000)).toEqual(2);
84
+ });
85
+
86
+ it("random", () => {
87
+ const sys = abstraction.fn({});
88
+ for (let i = 0; i < 100; i++) {
89
+ const val = sys.Random0ToValue(10);
90
+ expect(val).toBeGreaterThanOrEqual(0);
91
+ expect(val).toBeLessThanOrEqual(10);
92
+ }
93
+ });
94
+ });
95
+ }
@@ -0,0 +1,242 @@
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
+
6
+ export class SysTime extends Time {
7
+ Now(): Date {
8
+ return new Date();
9
+ }
10
+ Sleep(duration: number): Promise<void> {
11
+ return new Promise((resolve) => {
12
+ setTimeout(() => {
13
+ resolve();
14
+ }, duration);
15
+ });
16
+ }
17
+ }
18
+
19
+ export class ConstTime extends Time {
20
+ Now(): Date {
21
+ return new Date(2021, 1, 1, 0, 0, 0, 0);
22
+ }
23
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
24
+ Sleep(duration: number): Promise<void> {
25
+ return Promise.resolve();
26
+ }
27
+ }
28
+
29
+ export class StepTime extends Time {
30
+ _step: Date;
31
+ readonly _start: Date;
32
+ constructor() {
33
+ super();
34
+ this._step = new ConstTime().Now();
35
+ this._start = this._step;
36
+ }
37
+ Now(steps = 1): Date {
38
+ // if (this._step.getTime() === 0) {
39
+ // this._step = new ConstTime().Now();
40
+ // return this._step;
41
+ // }
42
+ for (let i = 0; steps > 0 && i < steps; i++) {
43
+ this._step = new Date(this._step.getTime() + 1000);
44
+ }
45
+ if (steps < 1) {
46
+ this._step = new Date(this._start.getTime() + steps * -1000);
47
+ }
48
+ // this._step = new Date(this._step.getTime() + 1000);
49
+ return this._step;
50
+ }
51
+ Sleep(duration: number): Promise<void> {
52
+ this._step = new Date(this._step.getTime() + duration);
53
+ return Promise.resolve();
54
+ }
55
+ }
56
+
57
+ export function TimeFactory(timeMode: TimeMode): Time {
58
+ switch (timeMode) {
59
+ case TimeMode.REAL:
60
+ return new SysTime();
61
+ case TimeMode.CONST:
62
+ return new ConstTime();
63
+ case TimeMode.STEP:
64
+ return new StepTime();
65
+ }
66
+ return new SysTime();
67
+ }
68
+
69
+ export class RandomService {
70
+ readonly _mode: RandomMode;
71
+ _step = 0;
72
+ constructor(mode: RandomMode) {
73
+ this._mode = mode;
74
+ }
75
+ Random0ToValue(value: number): number {
76
+ switch (this._mode) {
77
+ case RandomMode.CONST:
78
+ return 0.5 * value;
79
+ case RandomMode.STEP:
80
+ this._step += 0.0001;
81
+ return this._step * value;
82
+ case RandomMode.RANDOM:
83
+ return Math.random() * value;
84
+ default:
85
+ throw new Error("Unknown RandomMode");
86
+ }
87
+ }
88
+ }
89
+
90
+ export class IdService {
91
+ readonly _mode: IDMode;
92
+ _step = 0;
93
+ constructor(mode?: IDMode) {
94
+ if (!mode) {
95
+ mode = IDMode.UUID;
96
+ }
97
+ this._mode = mode;
98
+ }
99
+ NextId(): string {
100
+ switch (this._mode) {
101
+ case IDMode.UUID:
102
+ return crypto.randomUUID();
103
+ case IDMode.CONST:
104
+ return "VeryUniqueID";
105
+ case IDMode.STEP:
106
+ return `STEPId-${this._step++}`;
107
+ default:
108
+ throw new Error("Unknown IDMode");
109
+ }
110
+ }
111
+ }
112
+
113
+ export interface BaseSysAbstractionParams {
114
+ readonly TxtEnDecoder: TxtEnDecoder;
115
+ readonly FileSystem: FileService;
116
+ readonly SystemService: SystemService;
117
+ }
118
+
119
+ export interface ExitHandler {
120
+ readonly hdl: VoidFunc;
121
+ readonly id: string;
122
+ }
123
+
124
+ export interface ExitService {
125
+ injectExitHandlers(hdls: ExitHandler[]): void;
126
+ exit(code: number): void;
127
+ }
128
+
129
+ export class BaseSysAbstraction {
130
+ readonly _time: SysTime = new SysTime();
131
+ readonly _stdout: WritableStream;
132
+ readonly _stderr: WritableStream;
133
+
134
+ readonly _idService: IdService = new IdService();
135
+ readonly _randomService: RandomService = new RandomService(RandomMode.RANDOM);
136
+ readonly _fileSystem: FileService;
137
+ readonly _systemService: SystemService;
138
+ readonly _txtEnDe: TxtEnDecoder;
139
+
140
+ constructor(params: BaseSysAbstractionParams) {
141
+ this._fileSystem = params.FileSystem;
142
+ this._systemService = params.SystemService;
143
+ this._txtEnDe = params.TxtEnDecoder;
144
+ const decoder = this._txtEnDe;
145
+ this._stdout = new WritableStream({
146
+ write(chunk): Promise<void> {
147
+ return new Promise((resolve) => {
148
+ const decoded = decoder.decode(chunk);
149
+ // eslint-disable-next-line no-console
150
+ console.log(decoded.trimEnd());
151
+ resolve();
152
+ });
153
+ },
154
+ });
155
+ this._stderr = new WritableStream({
156
+ write(chunk): Promise<void> {
157
+ return new Promise((resolve) => {
158
+ const decoded = decoder.decode(chunk);
159
+ // eslint-disable-next-line no-console
160
+ console.error(decoded.trimEnd());
161
+ resolve();
162
+ });
163
+ },
164
+ });
165
+ }
166
+ }
167
+
168
+ export interface WrapperSysAbstractionParams {
169
+ readonly TimeMode?: TimeMode;
170
+ readonly IdMode?: IDMode;
171
+ readonly Stdout?: WritableStream<Uint8Array>;
172
+ readonly Stderr?: WritableStream<Uint8Array>;
173
+ readonly RandomMode?: RandomMode;
174
+ readonly FileSystem?: FileService;
175
+ readonly SystemService?: SystemService;
176
+ readonly TxtEnDecoder?: TxtEnDecoder;
177
+ }
178
+
179
+ export class WrapperSysAbstraction implements SysAbstraction {
180
+ readonly _time: Time;
181
+ readonly _stdout: WritableStream<Uint8Array>;
182
+ readonly _stderr: WritableStream<Uint8Array>;
183
+ readonly _idService: IdService;
184
+ readonly _randomService: RandomService;
185
+ readonly _fileSystem: FileService;
186
+ readonly _systemService: SystemService;
187
+ constructor(base: BaseSysAbstraction, params?: WrapperSysAbstractionParams) {
188
+ this._time = base._time;
189
+ this._stdout = base._stdout;
190
+ this._stderr = base._stderr;
191
+ this._idService = base._idService;
192
+ this._randomService = base._randomService;
193
+ this._fileSystem = base._fileSystem;
194
+ this._systemService = base._systemService;
195
+ if (params) {
196
+ if (params.TimeMode) {
197
+ this._time = TimeFactory(params.TimeMode);
198
+ }
199
+ if (params.Stdout) {
200
+ this._stdout = params.Stdout;
201
+ }
202
+ if (params.Stderr) {
203
+ this._stderr = params.Stderr;
204
+ }
205
+ if (params.IdMode) {
206
+ this._idService = new IdService(params.IdMode);
207
+ }
208
+ if (params.RandomMode) {
209
+ this._randomService = new RandomService(params.RandomMode);
210
+ }
211
+ if (params.FileSystem) {
212
+ this._fileSystem = params.FileSystem;
213
+ }
214
+ if (params.SystemService) {
215
+ this._systemService = params.SystemService;
216
+ }
217
+ }
218
+ }
219
+ Time(): Time {
220
+ return this._time;
221
+ }
222
+ NextId(): string {
223
+ return this._idService.NextId();
224
+ }
225
+ Random0ToValue(value: number): number {
226
+ return this._randomService.Random0ToValue(value);
227
+ }
228
+ Stdout(): WritableStream {
229
+ return this._stdout;
230
+ }
231
+ Stderr(): WritableStream {
232
+ return this._stderr;
233
+ }
234
+
235
+ System(): SystemService {
236
+ return this._systemService;
237
+ }
238
+ FileSystem(): FileService {
239
+ return this._fileSystem;
240
+ }
241
+ }
242
+ // export const BaseSysAbstraction = new BaseSysAbstractionImpl()
@@ -0,0 +1,59 @@
1
+ import { bin2string, bin2text } from "./bin2text.js";
2
+
3
+ it("bin2hex empty", () => {
4
+ expect(bin2string(new Uint8Array())).toEqual("");
5
+ });
6
+
7
+ it("bin2hex one", () => {
8
+ expect(bin2string(new Uint8Array([64]))).toBe("0000 40 @");
9
+ });
10
+
11
+ it("bin2hex 12", () => {
12
+ const collector: string[] = [];
13
+ bin2text(new Uint8Array([1, 2, 3, 4, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc]), (line) => {
14
+ collector.push(line);
15
+ });
16
+ expect(collector).toEqual(["0000 01 02 03 04 04 05 06 07 08 09 0a 0b 0c ............."]);
17
+ });
18
+
19
+ it("bin2hex cut", () => {
20
+ const collector: string[] = [];
21
+ bin2text(
22
+ new Uint8Array(new Array(255).fill(1).map((_, i) => i)),
23
+ (line) => {
24
+ collector.push(line);
25
+ },
26
+ 52,
27
+ );
28
+ expect(collector).toEqual([
29
+ "0000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f ................",
30
+ "0010 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f ................",
31
+ "0020 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f !\"#$%&'()*+,-./",
32
+ "00f0>>f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ...............",
33
+ ]);
34
+ });
35
+
36
+ it("bin2hex long", () => {
37
+ const collector: string[] = [];
38
+ bin2text(new Uint8Array(new Array(256).fill(1).map((_, i) => i % 0xff)), (line) => {
39
+ collector.push(line);
40
+ });
41
+ expect(collector).toEqual([
42
+ "0000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f ................",
43
+ "0010 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f ................",
44
+ "0020 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f !\"#$%&'()*+,-./",
45
+ "0030 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 0123456789:;<=>?",
46
+ "0040 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f @ABCDEFGHIJKLMNO",
47
+ "0050 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f PQRSTUVWXYZ[\\]^_",
48
+ "0060 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f `abcdefghijklmno",
49
+ "0070 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f pqrstuvwxyz{|}~.",
50
+ "0080 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f ................",
51
+ "0090 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f ................",
52
+ "00a0 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af ................",
53
+ "00b0 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf ................",
54
+ "00c0 c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf ................",
55
+ "00d0 d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df ................",
56
+ "00e0 e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef ................",
57
+ "00f0 f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe 00 ................",
58
+ ]);
59
+ });
@@ -0,0 +1,47 @@
1
+ export function bin2text(hex: ArrayBufferView, lineFn: (line: string) => void, size = 0): void {
2
+ const arr = new Uint8Array(hex.buffer, hex.byteOffset, hex.byteLength);
3
+ let cutted = " ";
4
+ if (size == 0) {
5
+ size = arr.length;
6
+ }
7
+ size = Math.min(size, arr.length);
8
+ const cols = 16;
9
+ for (let line = 0; line < size; line += cols) {
10
+ if (line + cols <= size || arr.length == size) {
11
+ // normal line
12
+ } else {
13
+ line = arr.length - (arr.length % cols);
14
+ size = arr.length;
15
+ cutted = ">>";
16
+ }
17
+ const l: string[] = [line.toString(16).padStart(4, "0"), cutted];
18
+ for (let col = 0; col < cols; col++) {
19
+ if (line + col < size) {
20
+ l.push(arr[line + col].toString(16).padStart(2, "0"));
21
+ } else {
22
+ l.push(" ");
23
+ }
24
+ // l.push((col > 0 && col % 4 === 3) ? " " : " ");
25
+ l.push(" ");
26
+ }
27
+ for (let col = 0; col < cols; col++) {
28
+ if (line + col < size) {
29
+ const ch = arr[line + col];
30
+ l.push(ch >= 32 && ch < 127 ? String.fromCharCode(ch) : ".");
31
+ }
32
+ }
33
+ lineFn(l.join(""));
34
+ }
35
+ }
36
+
37
+ export function bin2string(hex: ArrayBufferView, size = 0): string {
38
+ const collector: string[] = [];
39
+ bin2text(
40
+ hex,
41
+ (line) => {
42
+ collector.push(line);
43
+ },
44
+ size,
45
+ );
46
+ return collector.join("\n");
47
+ }