@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/ts/uri.d.ts ADDED
@@ -0,0 +1,67 @@
1
+ import { Result } from "./result.js";
2
+ type NullOrUndef = null | undefined;
3
+ export declare function isURL(value: unknown): value is URL;
4
+ export declare class MutableURL extends URL {
5
+ private readonly _sysURL;
6
+ private _protocol;
7
+ private _pathname;
8
+ private _hasHostpart;
9
+ readonly hash: string;
10
+ constructor(urlStr: string);
11
+ clone(): MutableURL;
12
+ get host(): string;
13
+ get port(): string;
14
+ set port(p: string);
15
+ get hostname(): string;
16
+ set hostname(h: string);
17
+ set pathname(p: string);
18
+ get pathname(): string;
19
+ get protocol(): string;
20
+ set protocol(p: string);
21
+ get searchParams(): URLSearchParams;
22
+ toString(): string;
23
+ }
24
+ export declare class BuildURI {
25
+ _url: MutableURL;
26
+ private constructor();
27
+ static is(value: unknown): value is BuildURI;
28
+ static from(strURLUri?: CoerceURI, defaultProtocol?: string): BuildURI;
29
+ port(p: string): BuildURI;
30
+ hostname(h: string): BuildURI;
31
+ protocol(p: string): BuildURI;
32
+ pathname(p: string): BuildURI;
33
+ delParam(key: string): BuildURI;
34
+ defParam(key: string, str: string): BuildURI;
35
+ setParam(key: string, str: string): BuildURI;
36
+ hasParam(key: string): boolean;
37
+ getParam(key: string): string | undefined;
38
+ toString(): string;
39
+ toJSON(): string;
40
+ URI(): URI;
41
+ }
42
+ export type CoerceURI = string | URI | MutableURL | URL | BuildURI | NullOrUndef;
43
+ export declare const protocols: Set<string>;
44
+ export declare class URI {
45
+ static protocolHasHostpart(protocol: string): () => void;
46
+ static merge(into: CoerceURI, from: CoerceURI, defaultProtocol?: string): URI;
47
+ static is(value: unknown): value is URI;
48
+ static from(strURLUri?: CoerceURI, defaultProtocol?: string): URI;
49
+ static fromResult(strURLUri?: CoerceURI, defaultProtocol?: string): Result<URI>;
50
+ readonly _url: MutableURL;
51
+ private constructor();
52
+ build(): BuildURI;
53
+ get hostname(): string;
54
+ get port(): string;
55
+ get host(): string;
56
+ get protocol(): string;
57
+ get pathname(): string;
58
+ get getParams(): Iterable<[string, string]>;
59
+ hasParam(key: string): boolean;
60
+ getParam(key: string): string | undefined;
61
+ clone(): URI;
62
+ asURL(): URL;
63
+ toString(): string;
64
+ toJSON(): string;
65
+ }
66
+ export {};
67
+ //# sourceMappingURL=uri.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uri.d.ts","sourceRoot":"","sources":["../../src/uri.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,MAAM,EAAE,MAAM,aAAa,CAAC;AAEvD,KAAK,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;AAsBpC,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,GAAG,CAQlD;AAID,qBAAa,UAAW,SAAQ,GAAG;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,CAAC,CAE1C;IAED,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAG9B,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIzC,KAAK,IAAI,GAAG;IAIZ,KAAK,IAAI,GAAG;IAMZ,QAAQ,IAAI,MAAM;IAIlB,MAAM,IAAI,MAAM;CAGjB"}
package/ts/uri.js ADDED
@@ -0,0 +1,283 @@
1
+ import { exception2Result } from "./result.js";
2
+ function falsy2undef(value) {
3
+ return value === undefined || value === null ? undefined : value;
4
+ }
5
+ function ensureURLWithDefaultProto(url, defaultProtocol) {
6
+ if (!url) {
7
+ return new MutableURL(`${defaultProtocol}//`);
8
+ }
9
+ if (typeof url === "string") {
10
+ try {
11
+ return new MutableURL(url);
12
+ }
13
+ catch (e) {
14
+ return new MutableURL(`${defaultProtocol}//${url}`);
15
+ }
16
+ }
17
+ else {
18
+ return new MutableURL(url.toString());
19
+ }
20
+ }
21
+ export function isURL(value) {
22
+ return (value instanceof URL ||
23
+ (!!value &&
24
+ typeof value.searchParams === "object" &&
25
+ typeof value.searchParams.sort === "function" &&
26
+ typeof value.hash === "string"));
27
+ }
28
+ export class MutableURL extends URL {
29
+ constructor(urlStr) {
30
+ super("defect://does.not.exist");
31
+ const partedURL = urlStr.split(":");
32
+ this._hasHostpart = protocols.has(partedURL[0]);
33
+ let hostPartUrl = ["http", ...partedURL.slice(1)].join(":");
34
+ if (!this._hasHostpart) {
35
+ const pathname = hostPartUrl.replace(/http:\/\/[/]*/, "").replace(/[#?].*$/, "");
36
+ hostPartUrl = hostPartUrl.replace(/http:\/\//, `http://localhost/${pathname}`);
37
+ }
38
+ try {
39
+ this._sysURL = new URL(hostPartUrl);
40
+ }
41
+ catch (ie) {
42
+ const e = ie;
43
+ e.message = `${e.message} for URL: ${urlStr}`;
44
+ throw e;
45
+ }
46
+ this._protocol = `${partedURL[0]}:`;
47
+ if (this._hasHostpart) {
48
+ this._pathname = this._sysURL.pathname;
49
+ }
50
+ else {
51
+ this._pathname = urlStr.replace(new RegExp(`^${this._protocol}//`), "").replace(/[#?].*$/, "");
52
+ }
53
+ this.hash = this._sysURL.hash;
54
+ }
55
+ clone() {
56
+ return new MutableURL(this.toString());
57
+ }
58
+ get host() {
59
+ if (!this._hasHostpart) {
60
+ throw new Error(`you can use hostname only if protocol is ${this.toString()} ${JSON.stringify(Array.from(protocols.keys()))}`);
61
+ }
62
+ return this._sysURL.host;
63
+ }
64
+ get port() {
65
+ if (!this._hasHostpart) {
66
+ throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(protocols.keys()))}`);
67
+ }
68
+ return this._sysURL.port;
69
+ }
70
+ set port(p) {
71
+ if (!this._hasHostpart) {
72
+ throw new Error(`you can use port only if protocol is ${JSON.stringify(Array.from(protocols.keys()))}`);
73
+ }
74
+ this._sysURL.port = p;
75
+ }
76
+ get hostname() {
77
+ if (!this._hasHostpart) {
78
+ throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(protocols.keys()))}`);
79
+ }
80
+ return this._sysURL.hostname;
81
+ }
82
+ set hostname(h) {
83
+ if (!this._hasHostpart) {
84
+ throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(protocols.keys()))}`);
85
+ }
86
+ this._sysURL.hostname = h;
87
+ }
88
+ set pathname(p) {
89
+ this._pathname = p;
90
+ }
91
+ get pathname() {
92
+ return this._pathname;
93
+ }
94
+ get protocol() {
95
+ return this._protocol;
96
+ }
97
+ set protocol(p) {
98
+ if (!p.endsWith(":")) {
99
+ p = `${p}:`;
100
+ }
101
+ this._protocol = p;
102
+ }
103
+ get searchParams() {
104
+ return this._sysURL.searchParams;
105
+ }
106
+ toString() {
107
+ let search = "";
108
+ if (this._sysURL.searchParams.size) {
109
+ for (const [key, value] of Array.from(this._sysURL.searchParams.entries()).sort((a, b) => a[0].localeCompare(b[0]))) {
110
+ search += `${!search.length ? "?" : "&"}${key}=${encodeURIComponent(value)}`;
111
+ }
112
+ }
113
+ let hostpart = "";
114
+ if (this._hasHostpart) {
115
+ hostpart = this._sysURL.hostname;
116
+ if (this._sysURL.port) {
117
+ hostpart += `:${this._sysURL.port}`;
118
+ }
119
+ if (!this._pathname.startsWith("/")) {
120
+ hostpart += "/";
121
+ }
122
+ }
123
+ return `${this._protocol}//${hostpart}${this._pathname}${search}`;
124
+ }
125
+ }
126
+ function from(fac, strURLUri, defaultProtocol) {
127
+ switch (typeof falsy2undef(strURLUri)) {
128
+ case "undefined":
129
+ return fac(new MutableURL(`${defaultProtocol}///`));
130
+ case "string":
131
+ return fac(ensureURLWithDefaultProto(strURLUri, defaultProtocol));
132
+ case "object":
133
+ if (BuildURI.is(strURLUri)) {
134
+ return fac(new MutableURL(strURLUri._url.toString()));
135
+ }
136
+ else if (URI.is(strURLUri)) {
137
+ return fac(new MutableURL(strURLUri._url.toString()));
138
+ }
139
+ else if (isURL(strURLUri)) {
140
+ return fac(new MutableURL(strURLUri.toString()));
141
+ }
142
+ throw new Error(`unknown object type: ${strURLUri}`);
143
+ default:
144
+ throw new Error(`Invalid argument: ${typeof strURLUri}`);
145
+ }
146
+ }
147
+ export class BuildURI {
148
+ constructor(url) {
149
+ this._url = url;
150
+ }
151
+ static is(value) {
152
+ return (value instanceof BuildURI ||
153
+ (!!value && typeof value.delParam === "function" && typeof value.setParam === "function"));
154
+ }
155
+ static from(strURLUri, defaultProtocol = "file:") {
156
+ return from((url) => new BuildURI(url), strURLUri, defaultProtocol);
157
+ }
158
+ port(p) {
159
+ this._url.port = p;
160
+ return this;
161
+ }
162
+ hostname(h) {
163
+ this._url.hostname = h;
164
+ return this;
165
+ }
166
+ protocol(p) {
167
+ this._url.protocol = p;
168
+ return this;
169
+ }
170
+ pathname(p) {
171
+ this._url.pathname = p;
172
+ return this;
173
+ }
174
+ delParam(key) {
175
+ this._url.searchParams.delete(key);
176
+ return this;
177
+ }
178
+ defParam(key, str) {
179
+ if (!this._url.searchParams.has(key)) {
180
+ this._url.searchParams.set(key, str);
181
+ }
182
+ return this;
183
+ }
184
+ setParam(key, str) {
185
+ this._url.searchParams.set(key, str);
186
+ return this;
187
+ }
188
+ hasParam(key) {
189
+ return this._url.searchParams.has(key);
190
+ }
191
+ getParam(key) {
192
+ return falsy2undef(this._url.searchParams.get(key));
193
+ }
194
+ toString() {
195
+ this._url.searchParams.sort();
196
+ return this._url.toString();
197
+ }
198
+ toJSON() {
199
+ return this.toString();
200
+ }
201
+ URI() {
202
+ return URI.from(this._url);
203
+ }
204
+ }
205
+ export const protocols = new Set(["http", "https", "ws", "wss"]);
206
+ export class URI {
207
+ static protocolHasHostpart(protocol) {
208
+ protocol = protocol.replace(/:$/, "");
209
+ protocols.add(protocol);
210
+ return () => {
211
+ protocols.delete(protocol);
212
+ };
213
+ }
214
+ static merge(into, from, defaultProtocol = "file:") {
215
+ const intoUrl = BuildURI.from(into, defaultProtocol);
216
+ const fromUrl = URI.from(from, defaultProtocol);
217
+ intoUrl.protocol(fromUrl.protocol);
218
+ const fPath = fromUrl.pathname;
219
+ if (!(fPath.length === 0 || fPath === "/" || fPath === "./")) {
220
+ intoUrl.pathname(fromUrl.pathname);
221
+ }
222
+ for (const [key, value] of fromUrl.getParams) {
223
+ intoUrl.setParam(key, value);
224
+ }
225
+ return intoUrl.URI();
226
+ }
227
+ static is(value) {
228
+ return (value instanceof URI ||
229
+ (!!value &&
230
+ typeof value.asURL === "function" &&
231
+ typeof value.getParam === "function" &&
232
+ typeof value.hasParam === "function"));
233
+ }
234
+ static from(strURLUri, defaultProtocol = "file:") {
235
+ return from((url) => new URI(url), strURLUri, defaultProtocol);
236
+ }
237
+ static fromResult(strURLUri, defaultProtocol = "file:") {
238
+ return exception2Result(() => from((url) => new URI(url), strURLUri, defaultProtocol));
239
+ }
240
+ constructor(url) {
241
+ this._url = url.clone();
242
+ }
243
+ build() {
244
+ return BuildURI.from(this._url);
245
+ }
246
+ get hostname() {
247
+ return this._url.hostname;
248
+ }
249
+ get port() {
250
+ return this._url.port;
251
+ }
252
+ get host() {
253
+ return this._url.host;
254
+ }
255
+ get protocol() {
256
+ return this._url.protocol;
257
+ }
258
+ get pathname() {
259
+ return this._url.pathname;
260
+ }
261
+ get getParams() {
262
+ return this._url.searchParams.entries();
263
+ }
264
+ hasParam(key) {
265
+ return this._url.searchParams.has(key);
266
+ }
267
+ getParam(key) {
268
+ return falsy2undef(this._url.searchParams.get(key));
269
+ }
270
+ clone() {
271
+ return new URI(this._url);
272
+ }
273
+ asURL() {
274
+ return this._url.clone();
275
+ }
276
+ toString() {
277
+ return this._url.toString();
278
+ }
279
+ toJSON() {
280
+ return this.toString();
281
+ }
282
+ }
283
+ //# sourceMappingURL=uri.js.map
package/ts/uri.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uri.js","sourceRoot":"","sources":["../../src/uri.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAU,MAAM,aAAa,CAAC;AAIvD,SAAS,WAAW,CAAI,KAAsB;IAC5C,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC;AACnE,CAAC;AAED,SAAS,yBAAyB,CAAC,GAAiB,EAAE,eAAuB;IAC3E,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,IAAI,UAAU,CAAC,GAAG,eAAe,IAAI,CAAC,CAAC;IAChD,CAAC;IACD,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,IAAI,CAAC;YACH,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC;QAE7B,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,IAAI,UAAU,CAAC,GAAG,eAAe,KAAK,GAAG,EAAE,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;IACxC,CAAC;AACH,CAAC;AA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/uri.test.js ADDED
@@ -0,0 +1,119 @@
1
+ import { BuildURI, MutableURL, URI } from "@adviser/cement";
2
+ describe("BuildURI", () => {
3
+ let uri;
4
+ beforeEach(() => {
5
+ uri = BuildURI.from(new MutableURL("http://example.com"));
6
+ uri.hostname("example");
7
+ uri.setParam("key", "value");
8
+ });
9
+ it("toString", () => {
10
+ expect(uri.toString()).toBe("http://example/?key=value");
11
+ });
12
+ it("build", () => {
13
+ expect(uri.URI().toString()).toBe("http://example/?key=value");
14
+ });
15
+ it("defParam", () => {
16
+ uri.defParam("key", "value2");
17
+ uri.defParam("key2", "value2");
18
+ expect(uri.toString()).toBe("http://example/?key=value&key2=value2");
19
+ });
20
+ it("searchParams sorted in toString", () => {
21
+ uri.setParam("z", "value");
22
+ uri.setParam("a", "value");
23
+ uri.setParam("m", "value");
24
+ expect(uri.toString()).toBe("http://example/?a=value&key=value&m=value&z=value");
25
+ });
26
+ });
27
+ describe("URI", () => {
28
+ it("from str with default", () => {
29
+ const uri = URI.from("/example/wurst");
30
+ expect(uri.toString()).toBe("file:///example/wurst");
31
+ });
32
+ it("from URL str", () => {
33
+ expect(URI.from("bla://example/com?key=value").toString()).toBe("bla://example/com?key=value");
34
+ });
35
+ it("from URL", () => {
36
+ expect(URI.from(new MutableURL("blix://example.com?key=value")).toString()).toBe("blix://example.com?key=value");
37
+ });
38
+ it("from URI", () => {
39
+ expect(URI.from(URI.from("blix://example.com?key=value")).toString()).toBe("blix://example.com?key=value");
40
+ });
41
+ it("from undef", () => {
42
+ expect(URI.from(null).toString()).toBe("file:///");
43
+ });
44
+ it("build", () => {
45
+ expect(URI.from("blix://example.com?key=value").build().toString()).toBe("blix://example.com?key=value");
46
+ });
47
+ it("clone", () => {
48
+ expect(URI.from("blix://example.com?key=value").clone().toString()).toBe("blix://example.com?key=value");
49
+ });
50
+ it("asURL", () => {
51
+ expect(URI.from("blix://example.com?key=value").asURL().toString()).toBe("blix://example.com?key=value");
52
+ });
53
+ it("toString", () => {
54
+ expect(URI.from("blix://example.com?key=value").toString()).toBe("blix://example.com?key=value");
55
+ });
56
+ it("searchParams sorted in toString", () => {
57
+ expect(URI.from("blix://example.com?z=value&a=value&m=value").toString()).toBe("blix://example.com?a=value&m=value&z=value");
58
+ });
59
+ it("searchParams sorted in asURL", () => {
60
+ expect(URI.from("blix://example.com?z=value&a=value&m=value").asURL().toString()).toBe("blix://example.com?a=value&m=value&z=value");
61
+ });
62
+ it("merge", () => {
63
+ expect(URI.merge("blix://example.com?key=value&into=4", "murk://bla/com?key=from&z=value").toString()).toBe("murk://bla/com?into=4&key=from&z=value");
64
+ });
65
+ it("merge empty", () => {
66
+ expect(URI.merge("blix://example/com?key=value&into=4", "murk://?key=from&z=value").toString()).toBe("murk://example/com?into=4&key=from&z=value");
67
+ });
68
+ it("firefox file relative into", () => {
69
+ expect(URI.from("file://./dist/tests/key.bag").toString()).toBe("file://./dist/tests/key.bag");
70
+ });
71
+ it("from empty", () => {
72
+ expect(URI.merge(`file://./dist/tests/key.bag`, "").toString()).toBe("file://./dist/tests/key.bag");
73
+ });
74
+ it("merge thing about", () => {
75
+ const result = URI.merge("./dist/what?byKey=4444", "murk://bla.com?key=from&z=value");
76
+ expect(result.toString()).toBe("murk://bla.com?byKey=4444&key=from&z=value");
77
+ });
78
+ it("isURI real", () => {
79
+ expect(URI.is(URI.from())).toBe(true);
80
+ });
81
+ it("isURI fake", () => {
82
+ expect(URI.is({
83
+ asURL: () => new URL("http://example.com"),
84
+ hasParam: () => false,
85
+ getParam: () => "",
86
+ })).toBe(true);
87
+ });
88
+ it("safari has a different pathname behavior", () => {
89
+ const uri = URI.from("indexdb://fp/?name=test&store=meta");
90
+ expect(uri.pathname).toBe("fp/");
91
+ });
92
+ it("passing URL to fetch", async () => {
93
+ const uri = URI.from("https://jsonplaceholder.typicode.com/todos/1");
94
+ const res = await fetch(uri.asURL());
95
+ expect(res.status).toBeGreaterThan(199);
96
+ });
97
+ it("MutableURL is instance of URL", () => {
98
+ expect(new MutableURL("http://example.com") instanceof URL).toBe(true);
99
+ });
100
+ it("file url", () => {
101
+ const uri = URI.from("file://fp?storagekey=zTvTPEPQRWij8rfb3FrFqBm");
102
+ expect(uri.pathname).toBe("fp");
103
+ });
104
+ it("unregistered protocol with hostPart", () => {
105
+ const withoutHostpart = URI.from("indexdb://fp:bla/test/?name=test&store=meta");
106
+ expect(() => withoutHostpart.hostname).toThrowError('you can use hostname only if protocol is ["http","https","ws","wss"]');
107
+ });
108
+ it("register protocol with hostPart", () => {
109
+ const unreg = URI.protocolHasHostpart("indexdb:");
110
+ const withHostpart = URI.from("indexdb://fp1:88/test/wurst?name=test&store=meta");
111
+ expect(withHostpart.host).toBe("fp1:88");
112
+ expect(withHostpart.pathname).toBe("/test/wurst");
113
+ const withHostpartNoPath = URI.from("indexdb://fp2:88?name=test&store=meta");
114
+ expect(withHostpartNoPath.host).toBe("fp2:88");
115
+ expect(withHostpartNoPath.pathname).toBe("/");
116
+ unreg();
117
+ });
118
+ });
119
+ //# sourceMappingURL=uri.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uri.test.js","sourceRoot":"","sources":["../../src/uri.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE5D,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACxB,IAAI,GAAa,CAAC;IAClB,UAAU,CAAC,GAAG,EAAE;QACd,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,oBAAoB,CAAC,CAAC,CAAC;QAC1D,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACxB,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,UAAU,EAAE,GAAG,EAAE;QAClB,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,C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kB,GAAG,GAAG,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;QAC7E,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC/C,MAAM,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC9C,KAAK,EAAE,CAAC;IACV,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,21 @@
1
+ export declare class ConsoleWriterStreamDefaultWriter implements WritableStreamDefaultWriter<Uint8Array> {
2
+ private stream;
3
+ readonly desiredSize: number | null;
4
+ readonly decoder: TextDecoder;
5
+ closed: Promise<undefined>;
6
+ ready: Promise<undefined>;
7
+ readonly _stream: ConsoleWriterStream;
8
+ constructor(stream: ConsoleWriterStream);
9
+ abort(reason?: any): Promise<void>;
10
+ close(): Promise<void>;
11
+ releaseLock(): void;
12
+ write(chunk?: Uint8Array | undefined): Promise<void>;
13
+ }
14
+ export declare class ConsoleWriterStream implements WritableStream<Uint8Array> {
15
+ locked: boolean;
16
+ _writer?: WritableStreamDefaultWriter<Uint8Array>;
17
+ abort(reason?: any): Promise<void>;
18
+ close(): Promise<void>;
19
+ getWriter(): WritableStreamDefaultWriter<Uint8Array>;
20
+ }
21
+ //# sourceMappingURL=console-write-stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"console-write-stream.d.ts","sourceRoot":"","sources":["../../../src/utils/console-write-stream.ts"],"names":[],"mappings":"AAAA,qBAAa,gCAAiC,YAAW,2BAA2B,CAAC,UAAU,CAAC;IAQlF,OAAO,CAAC,MAAM;IAP1B,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAQ;IAC3C,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAqB;IAElD,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAC3B,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC;gBAElB,MAAM,EAAE,mBAAmB;IAM/C,KAAK,CAAC,MAAM,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAG5B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAG5B,WAAW,IAAI,IAAI;IAKb,KAAK,CAAC,KAAK,CAAC,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;CAwB3D;AAED,qBAAa,mBAAoB,YAAW,cAAc,CAAC,UAAU,CAAC;IACpE,MAAM,UAAS;IACf,OAAO,CAAC,EAAE,2BAA2B,CAAC,UAAU,CAAC,CAAC;IAElD,KAAK,CAAC,MAAM,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAG5B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAG5B,SAAS,IAAI,2BAA2B,CAAC,UAAU,CAAC;CAUrD"}
@@ -0,0 +1,62 @@
1
+ export class ConsoleWriterStreamDefaultWriter {
2
+ constructor(stream) {
3
+ this.stream = stream;
4
+ this.desiredSize = null;
5
+ this.decoder = new TextDecoder();
6
+ this._stream = stream;
7
+ this.ready = Promise.resolve(undefined);
8
+ this.closed = Promise.resolve(undefined);
9
+ }
10
+ abort(reason) {
11
+ throw new Error("Method not implemented.");
12
+ }
13
+ async close() {
14
+ }
15
+ releaseLock() {
16
+ this._stream.locked = false;
17
+ this.ready = Promise.resolve(undefined);
18
+ this.closed = Promise.resolve(undefined);
19
+ }
20
+ async write(chunk) {
21
+ const str = this.decoder.decode(chunk).trimEnd();
22
+ let output = "log";
23
+ try {
24
+ const decode = JSON.parse(str);
25
+ output = decode.level;
26
+ }
27
+ catch (e) {
28
+ }
29
+ switch (output) {
30
+ case "error":
31
+ console.error(str);
32
+ break;
33
+ case "warn":
34
+ console.warn(str);
35
+ break;
36
+ default:
37
+ console.log(str);
38
+ }
39
+ }
40
+ }
41
+ export class ConsoleWriterStream {
42
+ constructor() {
43
+ this.locked = false;
44
+ }
45
+ abort(reason) {
46
+ throw new Error("Method not implemented.");
47
+ }
48
+ async close() {
49
+ return;
50
+ }
51
+ getWriter() {
52
+ if (this.locked) {
53
+ throw new Error("Stream is locked");
54
+ }
55
+ this.locked = true;
56
+ if (!this._writer) {
57
+ this._writer = new ConsoleWriterStreamDefaultWriter(this);
58
+ }
59
+ return this._writer;
60
+ }
61
+ }
62
+ //# sourceMappingURL=console-write-stream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"console-write-stream.js","sourceRoot":"","sources":["../../../src/utils/console-write-stream.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,gCAAgC;IAQ3C,YAAoB,MAA2B;QAA3B,WAAM,GAAN,MAAM,CAAqB;QAPtC,gBAAW,GAAkB,IAAI,CAAC;QAClC,YAAO,GAAgB,IAAI,WAAW,EAAE,CAAC;QAOhD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACxC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,MAAY;QAChB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IACD,KAAK,CAAC,KAAK;IAEX,CAAC;IACD,WAAW;QACT,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC;QAC5B,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACxC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC3C,CAAC;IACD,KAAK,CAAC,KAAK,CAAC,KAA8B;QACxC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;QACjD,IAAI,MAAM,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC/B,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC;QAExB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;QAEb,CAAC;QACD,QAAQ,MAAM,EAAE,CAAC;YACf,KAAK,OAAO;gBAEV,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACnB,MAAM;YACR,KAAK,MAAM;gBAET,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAClB,MAAM;YACR;gBAEE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;CACF;AAED,MAAM,OAAO,mBAAmB;IAAhC;QACE,WAAM,GAAG,KAAK,CAAC;IAmBjB,CAAC;IAhBC,KAAK,CAAC,MAAY;QAChB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IACD,KAAK,CAAC,KAAK;QACT,OAAO;IACT,CAAC;IACD,SAAS;QACP,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;QACtC,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,IAAI,CAAC,OAAO,GAAG,IAAI,gCAAgC,CAAC,IAAI,CAAC,CAAC;QAC5D,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ export declare class FanoutWriteStream implements WritableStreamDefaultWriter<Uint8Array> {
2
+ readonly _writers: WritableStreamDefaultWriter<Uint8Array>[];
3
+ readonly ready: Promise<undefined>;
4
+ readonly closed: Promise<undefined>;
5
+ readonly desiredSize: number | null;
6
+ constructor(writers: WritableStreamDefaultWriter<Uint8Array>[]);
7
+ abort(reason?: any): Promise<void>;
8
+ close(): Promise<void>;
9
+ releaseLock(): void;
10
+ write(chunk?: Uint8Array | undefined): Promise<void>;
11
+ }
12
+ //# sourceMappingURL=fanout-write-stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fanout-write-stream.d.ts","sourceRoot":"","sources":["../../../src/utils/fanout-write-stream.ts"],"names":[],"mappings":"AAAA,qBAAa,iBAAkB,YAAW,2BAA2B,CAAC,UAAU,CAAC;IAC/E,QAAQ,CAAC,QAAQ,EAAE,2BAA2B,CAAC,UAAU,CAAC,EAAE,CAAC;IAC7D,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IACpC,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAQ;gBAC/B,OAAO,EAAE,2BAA2B,CAAC,UAAU,CAAC,EAAE;IAO9D,KAAK,CAAC,MAAM,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAKlC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAKtB,WAAW,IAAI,IAAI;IAInB,KAAK,CAAC,KAAK,CAAC,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;CAKrD"}
@@ -0,0 +1,24 @@
1
+ export class FanoutWriteStream {
2
+ constructor(writers) {
3
+ this.desiredSize = null;
4
+ this._writers = writers;
5
+ this.ready = Promise.all(this._writers.map((w) => w.ready)).then(() => undefined);
6
+ this.closed = Promise.all(this._writers.map((w) => w.closed)).then(() => undefined);
7
+ }
8
+ abort(reason) {
9
+ return Promise.all(this._writers.map((w) => w.abort(reason))).then(() => {
10
+ });
11
+ }
12
+ close() {
13
+ return Promise.all(this._writers.map((w) => w.close())).then(() => {
14
+ });
15
+ }
16
+ releaseLock() {
17
+ this._writers.map((w) => w.releaseLock());
18
+ }
19
+ write(chunk) {
20
+ return Promise.all(this._writers.map((w) => w.write(chunk))).then(() => {
21
+ });
22
+ }
23
+ }
24
+ //# sourceMappingURL=fanout-write-stream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fanout-write-stream.js","sourceRoot":"","sources":["../../../src/utils/fanout-write-stream.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,iBAAiB;IAK5B,YAAY,OAAkD;QADrD,gBAAW,GAAkB,IAAI,CAAC;QAEzC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAClF,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IACtF,CAAC;IAGD,KAAK,CAAC,MAAY;QAChB,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;QAExE,CAAC,CAAC,CAAC;IACL,CAAC;IACD,KAAK;QACH,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;QAElE,CAAC,CAAC,CAAC;IACL,CAAC;I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