@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 @@
1
+ {"version":3,"file":"base-sys-abstraction.test.d.ts","sourceRoot":"","sources":["../../src/base-sys-abstraction.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,82 @@
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
+ const abstractions = [];
5
+ if (runtimeFn().isNodeIsh) {
6
+ abstractions.push({ name: "NodeSysAbstraction", fn: NodeSysAbstraction });
7
+ }
8
+ if (runtimeFn().isDeno) {
9
+ abstractions.push({ name: "DenoSysAbstraction", fn: DenoSysAbstraction });
10
+ }
11
+ if (runtimeFn().isBrowser) {
12
+ abstractions.push({ name: "WebSysAbstraction", fn: WebSysAbstraction });
13
+ }
14
+ for (const abstraction of abstractions) {
15
+ describe(abstraction.name, () => {
16
+ it("IdService UUID", () => {
17
+ const sys = abstraction.fn();
18
+ const id1 = sys.NextId();
19
+ const id2 = sys.NextId();
20
+ expect(id1).not.toEqual(id2);
21
+ });
22
+ it("IdService explict UUID", () => {
23
+ const sys = abstraction.fn({ IdMode: IDMode.UUID });
24
+ const id1 = sys.NextId();
25
+ const id2 = sys.NextId();
26
+ expect(id1).not.toEqual(id2);
27
+ });
28
+ it("IdService const", () => {
29
+ const sys = abstraction.fn({ IdMode: IDMode.CONST });
30
+ const id1 = sys.NextId();
31
+ const id2 = sys.NextId();
32
+ expect(id1).toEqual(id2);
33
+ });
34
+ it("IdService set", () => {
35
+ for (let i = 0; i < 10; i++) {
36
+ const sys = abstraction.fn({ IdMode: IDMode.STEP });
37
+ const id1 = sys.NextId();
38
+ const id2 = sys.NextId();
39
+ expect(id1).toEqual("STEPId-0");
40
+ expect(id2).toEqual("STEPId-1");
41
+ }
42
+ });
43
+ it("time sleep", async () => {
44
+ const sys = abstraction.fn();
45
+ const start = sys.Time().Now();
46
+ await sys.Time().Sleep(100);
47
+ expect(sys.Time().TimeSince(start)).toBeGreaterThan(90);
48
+ });
49
+ it("time sleep const", async () => {
50
+ const sys = abstraction.fn({ TimeMode: TimeMode.REAL });
51
+ const start = new Date();
52
+ await sys.Time().Sleep(100);
53
+ const end = new Date();
54
+ expect(end.getTime() - start.getTime()).toBeGreaterThan(90);
55
+ });
56
+ it("time sleep step", async () => {
57
+ const sys = abstraction.fn({ TimeMode: TimeMode.STEP });
58
+ const start = sys.Time().Now();
59
+ await sys.Time().Sleep(86400500);
60
+ expect(sys.Time().Now().getTime() - start.getTime()).toEqual(86401500);
61
+ });
62
+ it("const random", () => {
63
+ const sys = abstraction.fn({ RandomMode: RandomMode.CONST });
64
+ expect(sys.Random0ToValue(10)).toEqual(5);
65
+ expect(sys.Random0ToValue(10)).toEqual(5);
66
+ });
67
+ it("step random", () => {
68
+ const sys = abstraction.fn({ RandomMode: RandomMode.STEP });
69
+ expect(sys.Random0ToValue(10000)).toEqual(1);
70
+ expect(sys.Random0ToValue(10000)).toEqual(2);
71
+ });
72
+ it("random", () => {
73
+ const sys = abstraction.fn({});
74
+ for (let i = 0; i < 100; i++) {
75
+ const val = sys.Random0ToValue(10);
76
+ expect(val).toBeGreaterThanOrEqual(0);
77
+ expect(val).toBeLessThanOrEqual(10);
78
+ }
79
+ });
80
+ });
81
+ }
82
+ //# sourceMappingURL=base-sys-abstraction.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-sys-abstraction.test.js","sourceRoot":"","sources":["../../src/base-sys-abstraction.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,YAAY,GAAG,EAAE,CAAC;AAExB,IAAI,SAAS,EAAE,CAAC,SAAS,EAAE,CAAC;IAC1B,YAAY,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,oBAAoB,EAAE,EAAE,EAAE,kBAAkB,EAAE,CAAC,CAAC;AAC5E,CAAC;AAED,IAAI,SAAS,EAAE,CAAC,MAAM,EAAE,CAAC;IACvB,YAAY,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,oBAAoB,EAAE,EAAE,EAAE,kBAAkB,EAAE,CAAC,CAAC;AAC5E,CAAC;AAED,IAAI,SAAS,EAAE,CAAC,SAAS,EAAE,CAAC;IAC1B,YAAY,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,EAAE,EAAE,iBAAiB,EAAE,CAAC,CAAC;AAC1E,CAAC;AAED,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;IACvC,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,EAAE;QAC9B,EAAE,CAAC,gBAAgB,EAAE,GAAG,EAAE;YACxB,MAAM,GAAG,GAAG,WAAW,CAAC,EAAE,EAAE,CAAC;YAC7B,MAAM,GAAG,GAAG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GAAG,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;gBACnC,MAAM,CAAC,GAAG,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC;gBACtC,MAAM,CAAC,GAAG,CAAC,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAC;YACtC,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function bin2text(hex: ArrayBufferView, lineFn: (line: string) => void, size?: number): void;
2
+ export declare function bin2string(hex: ArrayBufferView, size?: number): string;
3
+ //# sourceMappingURL=bin2text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin2text.d.ts","sourceRoot":"","sources":["../../src/bin2text.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,EAAE,IAAI,SAAI,GAAG,IAAI,CAkC7F;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,eAAe,EAAE,IAAI,SAAI,GAAG,MAAM,CAUjE"}
package/ts/bin2text.js ADDED
@@ -0,0 +1,43 @@
1
+ export function bin2text(hex, lineFn, size = 0) {
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
+ }
12
+ else {
13
+ line = arr.length - (arr.length % cols);
14
+ size = arr.length;
15
+ cutted = ">>";
16
+ }
17
+ const l = [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
+ }
22
+ else {
23
+ l.push(" ");
24
+ }
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
+ export function bin2string(hex, size = 0) {
37
+ const collector = [];
38
+ bin2text(hex, (line) => {
39
+ collector.push(line);
40
+ }, size);
41
+ return collector.join("\n");
42
+ }
43
+ //# sourceMappingURL=bin2text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin2text.js","sourceRoot":"","sources":["../../src/bin2text.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,QAAQ,CAAC,GAAoB,EAAE,MAA8B,EAAE,IAAI,GAAG,CAAC;IACrF,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;IACvE,IAAI,MAAM,GAAG,IAAI,CAAC;IAClB,IAAI,IAAI,IAAI,CAAC,EAAE,CAAC;QACd,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC;IACpB,CAAC;IACD,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,IAAI,IAAI,EAAE,CAAC;QAC7C,IAAI,IAAI,GAAG,IAAI,IAAI,IAAI,IAAI,GAAG,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;QAEhD,CAAC;aAAM,CAAC;YACN,IAAI,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;YACxC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC;YAClB,MAAM,GAAG,IAAI,CAAC;QAChB,CAAC;QACD,MAAM,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AI,CAAC,CAAC;IACvB,CAAC,EACD,IAAI,CACL,CAAC;IACF,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=bin2text.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin2text.test.d.ts","sourceRoot":"","sources":["../../src/bin2text.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,51 @@
1
+ import { bin2string, bin2text } from "./bin2text.js";
2
+ it("bin2hex empty", () => {
3
+ expect(bin2string(new Uint8Array())).toEqual("");
4
+ });
5
+ it("bin2hex one", () => {
6
+ expect(bin2string(new Uint8Array([64]))).toBe("0000 40 @");
7
+ });
8
+ it("bin2hex 12", () => {
9
+ const collector = [];
10
+ bin2text(new Uint8Array([1, 2, 3, 4, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc]), (line) => {
11
+ collector.push(line);
12
+ });
13
+ expect(collector).toEqual(["0000 01 02 03 04 04 05 06 07 08 09 0a 0b 0c ............."]);
14
+ });
15
+ it("bin2hex cut", () => {
16
+ const collector = [];
17
+ bin2text(new Uint8Array(new Array(255).fill(1).map((_, i) => i)), (line) => {
18
+ collector.push(line);
19
+ }, 52);
20
+ expect(collector).toEqual([
21
+ "0000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f ................",
22
+ "0010 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f ................",
23
+ "0020 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f !\"#$%&'()*+,-./",
24
+ "00f0>>f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ...............",
25
+ ]);
26
+ });
27
+ it("bin2hex long", () => {
28
+ const collector = [];
29
+ bin2text(new Uint8Array(new Array(256).fill(1).map((_, i) => i % 0xff)), (line) => {
30
+ collector.push(line);
31
+ });
32
+ expect(collector).toEqual([
33
+ "0000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f ................",
34
+ "0010 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f ................",
35
+ "0020 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f !\"#$%&'()*+,-./",
36
+ "0030 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 0123456789:;<=>?",
37
+ "0040 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f @ABCDEFGHIJKLMNO",
38
+ "0050 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f PQRSTUVWXYZ[\\]^_",
39
+ "0060 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f `abcdefghijklmno",
40
+ "0070 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f pqrstuvwxyz{|}~.",
41
+ "0080 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f ................",
42
+ "0090 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f ................",
43
+ "00a0 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af ................",
44
+ "00b0 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf ................",
45
+ "00c0 c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf ................",
46
+ "00d0 d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df ................",
47
+ "00e0 e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef ................",
48
+ "00f0 f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe 00 ................",
49
+ ]);
50
+ });
51
+ //# sourceMappingURL=bin2text.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin2text.test.js","sourceRoot":"","sources":["../../src/bin2text.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE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,MAAM,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC;QACxB,wEAAwE;QACxE,wEAAwE;QACxE,yEAAyE;QACzE,uEAAuE;KACxE,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,cAAc,EAAE,GAAG,EAAE;IACtB,MAAM,SAAS,GAAa,EAAE,CAAC;IAC/B,QAAQ,CAAC,IAAI,UAAU,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE;QAChF,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC;QACxB,wEAAwE;QACxE,wEAAwE;QACxE,yEAAyE;QACzE,wEAAwE;QACxE,wEAAwE;QACxE,yEAAyE;QACzE,wEAAwE;QACxE,wEAAwE;QACxE,wEAAwE;QACxE,wEAAwE;QACxE,wEAAwE;QACxE,wEAAwE;QACxE,wEAAwE;QACxE,wEAAwE;QACxE,wEAAwE;QACxE,wEAAwE;KACzE,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/ts/crypto.d.ts ADDED
@@ -0,0 +1,76 @@
1
+ export interface CTJsonWebKey {
2
+ alg?: string;
3
+ crv?: string;
4
+ d?: string;
5
+ dp?: string;
6
+ dq?: string;
7
+ e?: string;
8
+ ext?: boolean;
9
+ k?: string;
10
+ key_ops?: string[];
11
+ kty?: string;
12
+ n?: string;
13
+ oth?: RsaOtherPrimesInfo[];
14
+ p?: string;
15
+ q?: string;
16
+ qi?: string;
17
+ use?: string;
18
+ x?: string;
19
+ y?: string;
20
+ }
21
+ export type CTKeyFormat = "jwk" | "pkcs8" | "raw" | "spki";
22
+ export type CTKeyUsage = "decrypt" | "deriveBits" | "deriveKey" | "encrypt" | "sign" | "unwrapKey" | "verify" | "wrapKey";
23
+ export interface CTAlgorithm {
24
+ name: string;
25
+ }
26
+ export type CTAlgorithmIdentifier = CTAlgorithm | string;
27
+ export interface CTRsaHashedImportParams extends CTAlgorithm {
28
+ hash: CTAlgorithmIdentifier;
29
+ }
30
+ export type CTNamedCurve = string;
31
+ export interface CTEcKeyImportParams extends CTAlgorithm {
32
+ namedCurve: CTNamedCurve;
33
+ }
34
+ export interface CTHmacImportParams extends CTAlgorithm {
35
+ hash: CTAlgorithmIdentifier;
36
+ length?: number;
37
+ }
38
+ export interface CTAesKeyAlgorithm extends CTAlgorithm {
39
+ length: number;
40
+ }
41
+ export type CTKeyType = "private" | "public" | "secret";
42
+ export interface CTCryptoKey {
43
+ readonly algorithm: CTAlgorithm;
44
+ readonly extractable: boolean;
45
+ readonly type: CTKeyType;
46
+ readonly usages: CTKeyUsage[];
47
+ }
48
+ interface CTArrayBufferTypes {
49
+ ArrayBuffer: ArrayBuffer;
50
+ }
51
+ type CTArrayBufferLike = CTArrayBufferTypes[keyof CTArrayBufferTypes];
52
+ export interface CTArrayBufferView {
53
+ buffer: CTArrayBufferLike;
54
+ byteLength: number;
55
+ byteOffset: number;
56
+ }
57
+ export type CTBufferSource = CTArrayBufferView | ArrayBuffer;
58
+ export interface CryptoRuntime {
59
+ importKey(format: CTKeyFormat, keyData: CTJsonWebKey | CTBufferSource, algorithm: CTAlgorithmIdentifier | CTRsaHashedImportParams | CTEcKeyImportParams | CTHmacImportParams | CTAesKeyAlgorithm, extractable: boolean, keyUsages: CTKeyUsage[]): Promise<CTCryptoKey>;
60
+ exportKey(format: CTKeyFormat, key: CTCryptoKey): Promise<CTJsonWebKey | ArrayBuffer>;
61
+ decrypt(algo: {
62
+ name: string;
63
+ iv: Uint8Array;
64
+ tagLength: number;
65
+ }, key: CTCryptoKey, data: Uint8Array): Promise<ArrayBuffer>;
66
+ encrypt(algo: {
67
+ name: string;
68
+ iv: Uint8Array;
69
+ tagLength: number;
70
+ }, key: CTCryptoKey, data: Uint8Array): Promise<ArrayBuffer>;
71
+ digestSHA256(data: Uint8Array): Promise<ArrayBuffer>;
72
+ randomBytes(size: number): Uint8Array;
73
+ }
74
+ export declare function toCryptoRuntime(cryptoOpts?: Partial<CryptoRuntime>): CryptoRuntime;
75
+ export {};
76
+ //# sourceMappingURL=crypto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/crypto.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,GAAG,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAC3B,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;AAC3D,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,YAAY,GAAG,WAAW,GAAG,SAAS,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE1H,MAAM,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AmB,GAAG,kBAAkB,GAAG,iBAAiB,EACzH,WAAW,EAAE,OAAO,EACpB,SAAS,EAAE,UAAU,EAAE,GACtB,OAAO,CAAC,WAAW,CAAC,CAAC;IACxB,SAAS,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,GAAG,WAAW,CAAC,CAAC;IAGtF,OAAO,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,UAAU,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAC7H,OAAO,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,UAAU,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAC7H,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IACrD,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;CACvC;AAcD,wBAAgB,eAAe,CAAC,UAAU,GAAE,OAAO,CAAC,aAAa,CAAM,GAAG,aAAa,CAWtF"}
package/ts/crypto.js ADDED
@@ -0,0 +1,22 @@
1
+ function randomBytes(size) {
2
+ const bytes = new Uint8Array(size);
3
+ if (size > 0) {
4
+ crypto.getRandomValues(bytes);
5
+ }
6
+ return bytes;
7
+ }
8
+ function digestSHA256(data) {
9
+ return Promise.resolve(crypto.subtle.digest("SHA-256", data));
10
+ }
11
+ export function toCryptoRuntime(cryptoOpts = {}) {
12
+ const runtime = {
13
+ importKey: cryptoOpts.importKey || crypto.subtle.importKey.bind(crypto.subtle),
14
+ exportKey: cryptoOpts.exportKey || crypto.subtle.exportKey.bind(crypto.subtle),
15
+ encrypt: cryptoOpts.encrypt || crypto.subtle.encrypt.bind(crypto.subtle),
16
+ decrypt: cryptoOpts.decrypt || crypto.subtle.decrypt.bind(crypto.subtle),
17
+ randomBytes: cryptoOpts.randomBytes || randomBytes,
18
+ digestSHA256: cryptoOpts.digestSHA256 || digestSHA256,
19
+ };
20
+ return runtime;
21
+ }
22
+ //# sourceMappingURL=crypto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../src/crypto.ts"],"names":[],"mappings":"AAqGA,SAAS,WAAW,CAAC,IAAY;IAC/B,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;QACb,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,YAAY,CAAC,IAAgB;IACpC,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,aAAqC,EAAE;IACrE,MAAM,OAAO,GAAG;QACd,SAAS,EAAE,UAAU,CAAC,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;QAC9E,SAAS,EAAE,UAAU,CAAC,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;QAC9E,OAAO,EAAE,UAAU,CAAC,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;QACxE,OAAO,EAAE,UAAU,CAAC,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;QACxE,WAAW,EAAE,UAAU,CAAC,WAAW,IAAI,WAAW;QAClD,YAAY,EAAE,UAAU,CAAC,YAAY,IAAI,YAAY;KACtD,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=crypto.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.test.d.ts","sourceRoot":"","sources":["../../src/crypto.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import { toCryptoRuntime } from "./crypto.js";
2
+ it("not extractable import -> export", async () => {
3
+ const cp = toCryptoRuntime();
4
+ const key = cp.randomBytes(32);
5
+ const x = await cp.importKey("raw", key, "AES-CBC", false, ["encrypt"]);
6
+ expect(cp.exportKey("raw", x)).rejects.toThrowError(/key is not extractable/i);
7
+ });
8
+ it("extractable import -> export", async () => {
9
+ const cp = toCryptoRuntime();
10
+ const key = cp.randomBytes(32);
11
+ const x = await cp.importKey("raw", key, "AES-CBC", true, ["encrypt"]);
12
+ expect(new Uint8Array((await cp.exportKey("raw", x)))).toEqual(key);
13
+ });
14
+ //# sourceMappingURL=crypto.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.test.js","sourceRoot":"","sources":["../../src/crypto.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,EAAE,CAAC,kCAAkC,EAAE,KAAK,IAAI,EAAE;IAChD,MAAM,EAAE,GAAG,eAAe,EAAE,CAAC;IAC7B,MAAM,GAAG,GAAG,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAC/B,MAAM,CAAC,GAAG,MAAM,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IACxE,MAAM,CAAC,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,yBAAyB,CAAC,CAAC;AACjF,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,8BAA8B,EAAE,KAAK,IAAI,EAAE;IAC5C,MAAM,EAAE,GAAG,eAAe,EAAE,CAAC;IAC7B,MAAM,GAAG,GAAG,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAC/B,MAAM,CAAC,GAAG,MAAM,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IACvE,MAAM,CAAC,IAAI,UAAU,CAAC,CAAC,MAAM,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,CAAgB,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AACrF,CAAC,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ export interface NamedWritableStream {
2
+ readonly name: string;
3
+ readonly stream: WritableStream<Uint8Array>;
4
+ }
5
+ export interface FileService {
6
+ readonly baseDir: string;
7
+ create(fname: string): Promise<NamedWritableStream>;
8
+ readFileString(fname: string): Promise<string>;
9
+ writeFileString(fname: string, content: string): Promise<void>;
10
+ abs(fname: string): string;
11
+ join(...paths: string[]): string;
12
+ relative(from: string, to?: string): string;
13
+ dirname(fname: string): string;
14
+ basename(fname: string): string;
15
+ isAbsolute(fname: string): boolean;
16
+ }
17
+ //# sourceMappingURL=file-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-service.d.ts","sourceRoot":"","sources":["../../src/file-service.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;CAC7C;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACpD,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/C,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/D,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAE3B,IAAI,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAEjC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAE5C,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAIhC,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;CACpC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=file-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-service.js","sourceRoot":"","sources":["../../src/file-service.ts"],"names":[],"mappings":""}
package/ts/future.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ export declare class Future<T> {
2
+ #private;
3
+ constructor();
4
+ asPromise(): Promise<T>;
5
+ resolve(value: T): void;
6
+ reject(reason: unknown): void;
7
+ }
8
+ //# sourceMappingURL=future.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"future.d.ts","sourceRoot":"","sources":["../../src/future.ts"],"names":[],"mappings":"AAAA,qBAAa,MAAM,CAAC,CAAC;;;IAgBb,SAAS,IAAI,OAAO,CAAC,CAAC,CAAC;IAI7B,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI;IAGvB,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;CAG9B"}
package/ts/future.js ADDED
@@ -0,0 +1,38 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _Future_promise, _Future_resolveFn, _Future_rejectFn;
13
+ export class Future {
14
+ constructor() {
15
+ _Future_promise.set(this, void 0);
16
+ _Future_resolveFn.set(this, () => {
17
+ throw new Error("This Promise is not working as expected.");
18
+ });
19
+ _Future_rejectFn.set(this, () => {
20
+ throw new Error("This Promise is not working as expected.");
21
+ });
22
+ __classPrivateFieldSet(this, _Future_promise, new Promise((resolve, reject) => {
23
+ __classPrivateFieldSet(this, _Future_resolveFn, resolve, "f");
24
+ __classPrivateFieldSet(this, _Future_rejectFn, reject, "f");
25
+ }), "f");
26
+ }
27
+ async asPromise() {
28
+ return __classPrivateFieldGet(this, _Future_promise, "f");
29
+ }
30
+ resolve(value) {
31
+ __classPrivateFieldGet(this, _Future_resolveFn, "f").call(this, value);
32
+ }
33
+ reject(reason) {
34
+ __classPrivateFieldGet(this, _Future_rejectFn, "f").call(this, reason);
35
+ }
36
+ }
37
+ _Future_promise = new WeakMap(), _Future_resolveFn = new WeakMap(), _Future_rejectFn = new WeakMap();
38
+ //# sourceMappingURL=future.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"future.js","sourceRoot":"","sources":["../../src/future.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,MAAM,OAAO,MAAM;IASjB;QARS,kCAAqB;QAC9B,4BAAiC,GAAG,EAAE;YACpC,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC9D,CAAC,EAAC;QACF,2BAAuC,GAAG,EAAE;YAC1C,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC9D,CAAC,EAAC;QAGA,uBAAA,IAAI,mBAAY,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACjD,uBAAA,IAAI,qBAAc,OAAO,MAAA,CAAC;YAC1B,uBAAA,IAAI,oBAAa,MAAM,MAAA,CAAC;QAC1B,CAAC,CAAC,MAAA,CAAC;IACL,CAAC;IAED,KAAK,CAAC,SAAS;QACb,OAAO,uBAAA,IAAI,uBAAS,CAAC;IACvB,CAAC;IAED,OAAO,CAAC,KAAQ;QACd,uBAAA,IAAI,yBAAW,MAAf,IAAI,EAAY,KAAK,CAAC,CAAC;IACzB,CAAC;IACD,MAAM,CAAC,MAAe;QACpB,uBAAA,IAAI,wBAAU,MAAd,IAAI,EAAW,MAAM,CAAC,CAAC;IACzB,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=future.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"future.test.d.ts","sourceRoot":"","sources":["../../src/future.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,28 @@
1
+ import { Future } from "@adviser/cement";
2
+ it("Create Future Happy", async () => {
3
+ const future = new Future();
4
+ const promise = future.asPromise();
5
+ expect(promise).toBeInstanceOf(Promise);
6
+ const asynced = new Promise((resolve, reject) => {
7
+ promise.then(resolve).catch(reject);
8
+ });
9
+ future.resolve("Hello World");
10
+ expect(await asynced).toBe("Hello World");
11
+ });
12
+ it("Create Future Sad", async () => {
13
+ const future = new Future();
14
+ const promise = future.asPromise();
15
+ expect(promise).toBeInstanceOf(Promise);
16
+ const asynced = new Promise((resolve, reject) => {
17
+ promise.then(resolve).catch(reject);
18
+ });
19
+ future.reject("Sad World");
20
+ try {
21
+ await asynced;
22
+ expect("Why").toBe("Sad World");
23
+ }
24
+ catch (error) {
25
+ expect(error).toBe("Sad World");
26
+ }
27
+ });
28
+ //# sourceMappingURL=future.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"future.test.js","sourceRoot":"","sources":["../../src/future.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,EAAE,CAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;IACnC,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;IAC5B,MAAM,OAAO,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC;IACnC,MAAM,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAExC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC9C,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAE9B,MAAM,CAAC,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;AAC5C,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,mBAAmB,EAAE,KAAK,IAAI,EAAE;IACjC,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;IAC5B,MAAM,OAAO,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC;IACnC,MAAM,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAExC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC9C,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAE3B,IAAI,CAAC;QACH,MAAM,OAAO,CAAC;QACd,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAClC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAClC,CAAC;AACH,CAAC,CAAC,CAAC"}
package/ts/index.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ export * from "./file-service.js";
2
+ export * from "./logger-impl.js";
3
+ export * from "./logger.js";
4
+ export * from "./sys-abstraction.js";
5
+ export * from "./sys-env.js";
6
+ export * from "./time.js";
7
+ export * from "./test/log-write-stream.js";
8
+ export * from "./test/mock-logger.js";
9
+ export * from "./txt-en-decoder.js";
10
+ export * from "./log-level-impl.js";
11
+ export * from "./result.js";
12
+ export * from "./option.js";
13
+ export * from "./future.js";
14
+ export * from "./tracer.js";
15
+ export * from "./resolve-once.js";
16
+ export * from "./runtime.js";
17
+ export * from "./uri.js";
18
+ export * from "./crypto.js";
19
+ export * from "./base-sys-abstraction.js";
20
+ export * from "./bin2text.js";
21
+ export * from "./version.js";
22
+ export * as utils from "./utils/index.js";
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC"}
package/ts/index.js ADDED
@@ -0,0 +1,23 @@
1
+ export * from "./file-service.js";
2
+ export * from "./logger-impl.js";
3
+ export * from "./logger.js";
4
+ export * from "./sys-abstraction.js";
5
+ export * from "./sys-env.js";
6
+ export * from "./time.js";
7
+ export * from "./test/log-write-stream.js";
8
+ export * from "./test/mock-logger.js";
9
+ export * from "./txt-en-decoder.js";
10
+ export * from "./log-level-impl.js";
11
+ export * from "./result.js";
12
+ export * from "./option.js";
13
+ export * from "./future.js";
14
+ export * from "./tracer.js";
15
+ export * from "./resolve-once.js";
16
+ export * from "./runtime.js";
17
+ export * from "./uri.js";
18
+ export * from "./crypto.js";
19
+ export * from "./base-sys-abstraction.js";
20
+ export * from "./bin2text.js";
21
+ export * from "./version.js";
22
+ export * as utils from "./utils/index.js";
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { LevelHandler, Level } from "./logger.js";
2
+ export declare class LevelHandlerImpl implements LevelHandler {
3
+ readonly _globalLevels: Set<Level>;
4
+ readonly _modules: Map<string, Set<Level>>;
5
+ isStackExposed: boolean;
6
+ enableLevel(level: Level, ...modules: string[]): void;
7
+ disableLevel(level: Level, ...modules: string[]): void;
8
+ setExposeStack(enable?: boolean): void;
9
+ forModules(level: Level, fnAction: (p: string) => void, ...modules: (string | string[])[]): void;
10
+ setDebug(...modules: (string | string[])[]): void;
11
+ isEnabled(ilevel: unknown, module: unknown): boolean;
12
+ }
13
+ export declare function LevelHandlerSingleton(): LevelHandler;
14
+ //# sourceMappingURL=log-level-impl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log-level-impl.d.ts","sourceRoot":"","sources":["../../src/log-level-impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAElD,qBAAa,gBAAiB,YAAW,YAAY;IACnD,QAAQ,CAAC,aAAa,EAAE,GAAG,CAAC,KAAK,CAAC,CAAyD;IAC3F,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAiC;IAC3E,cAAc,UAAS;IACvB,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IAarD,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IActD,cAAc,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI;IAItC,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,GAAG,IAAI;IAchG,QAAQ,CAAC,GAAG,OAAO,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,GAAG,IAAI;IASjD,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO;CAoBrD;AAID,wBAAgB,qBAAqB,IAAI,YAAY,CAEpD"}