@adviser/cement 0.4.7 → 0.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (505) hide show
  1. package/base-basic-sys-abstraction.test.d.ts +2 -0
  2. package/base-basic-sys-abstraction.test.d.ts.map +1 -0
  3. package/base-basic-sys-abstraction.test.js +88 -0
  4. package/base-basic-sys-abstraction.test.js.map +1 -0
  5. package/{base-sys-abstraction-h0dB3nZ5.d.ts → base-sys-abstraction.d.ts} +23 -22
  6. package/base-sys-abstraction.d.ts.map +1 -0
  7. package/base-sys-abstraction.js +193 -0
  8. package/base-sys-abstraction.js.map +1 -0
  9. package/bin2text.d.ts +3 -0
  10. package/bin2text.d.ts.map +1 -0
  11. package/bin2text.js +43 -0
  12. package/bin2text.js.map +1 -0
  13. package/bin2text.test.d.ts +2 -0
  14. package/bin2text.test.d.ts.map +1 -0
  15. package/bin2text.test.js +51 -0
  16. package/bin2text.test.js.map +1 -0
  17. package/cf/cf-basic-sys-abstraction.d.ts +14 -0
  18. package/cf/cf-basic-sys-abstraction.d.ts.map +1 -0
  19. package/cf/cf-basic-sys-abstraction.js +67 -0
  20. package/cf/cf-basic-sys-abstraction.js.map +1 -0
  21. package/cf/cf-env-actions.d.ts +16 -0
  22. package/cf/cf-env-actions.d.ts.map +1 -0
  23. package/cf/cf-env-actions.js +53 -0
  24. package/cf/cf-env-actions.js.map +1 -0
  25. package/cf/index.d.ts +3 -30
  26. package/cf/index.d.ts.map +1 -0
  27. package/cf/index.js +2 -11
  28. package/cf/index.js.map +1 -1
  29. package/cf-test-main.d.ts +5 -0
  30. package/cf-test-main.d.ts.map +1 -0
  31. package/cf-test-main.js +12 -0
  32. package/cf-test-main.js.map +1 -0
  33. package/coerce-binary.d.ts +6 -0
  34. package/coerce-binary.d.ts.map +1 -0
  35. package/coerce-binary.js +32 -0
  36. package/coerce-binary.js.map +1 -0
  37. package/coerce-binary.test.d.ts +2 -0
  38. package/coerce-binary.test.d.ts.map +1 -0
  39. package/coerce-binary.test.js +39 -0
  40. package/coerce-binary.test.js.map +1 -0
  41. package/crypto.d.ts +76 -0
  42. package/crypto.d.ts.map +1 -0
  43. package/crypto.js +22 -0
  44. package/crypto.js.map +1 -0
  45. package/crypto.test.d.ts +2 -0
  46. package/crypto.test.d.ts.map +1 -0
  47. package/crypto.test.js +21 -0
  48. package/crypto.test.js.map +1 -0
  49. package/deno/deno-basic-sys-abstraction.d.ts +14 -0
  50. package/deno/deno-basic-sys-abstraction.d.ts.map +1 -0
  51. package/deno/deno-basic-sys-abstraction.js +35 -0
  52. package/deno/deno-basic-sys-abstraction.js.map +1 -0
  53. package/deno/deno-env-actions.d.ts +23 -0
  54. package/deno/deno-env-actions.d.ts.map +1 -0
  55. package/deno/deno-env-actions.js +40 -0
  56. package/deno/deno-env-actions.js.map +1 -0
  57. package/deno/deno-file-service.d.ts +17 -0
  58. package/deno/deno-file-service.d.ts.map +1 -0
  59. package/deno/deno-file-service.js +67 -0
  60. package/deno/deno-file-service.js.map +1 -0
  61. package/deno/deno-sys-abstraction.d.ts +19 -0
  62. package/deno/deno-sys-abstraction.d.ts.map +1 -0
  63. package/deno/deno-sys-abstraction.js +96 -0
  64. package/deno/deno-sys-abstraction.js.map +1 -0
  65. package/deno/index.d.ts +3 -37
  66. package/deno/index.d.ts.map +1 -0
  67. package/deno/index.js +2 -179
  68. package/deno/index.js.map +1 -1
  69. package/file-service.d.ts +17 -0
  70. package/file-service.d.ts.map +1 -0
  71. package/file-service.js +2 -0
  72. package/file-service.js.map +1 -0
  73. package/future.d.ts +8 -0
  74. package/future.d.ts.map +1 -0
  75. package/future.js +25 -0
  76. package/future.js.map +1 -0
  77. package/future.test.d.ts +2 -0
  78. package/future.test.d.ts.map +1 -0
  79. package/future.test.js +32 -0
  80. package/future.test.js.map +1 -0
  81. package/http_header.d.ts +29 -0
  82. package/http_header.d.ts.map +1 -0
  83. package/http_header.js +157 -0
  84. package/http_header.js.map +1 -0
  85. package/http_header.test.d.ts +2 -0
  86. package/http_header.test.d.ts.map +1 -0
  87. package/http_header.test.js +96 -0
  88. package/http_header.test.js.map +1 -0
  89. package/index.d.ts +29 -396
  90. package/index.d.ts.map +1 -0
  91. package/index.js +28 -609
  92. package/index.js.map +1 -1
  93. package/is-promise.d.ts +4 -0
  94. package/is-promise.d.ts.map +1 -0
  95. package/is-promise.js +10 -0
  96. package/is-promise.js.map +1 -0
  97. package/is-promise.test.d.ts +2 -0
  98. package/is-promise.test.d.ts.map +1 -0
  99. package/is-promise.test.js +48 -0
  100. package/is-promise.test.js.map +1 -0
  101. package/json-en-decoder.d.ts +12 -0
  102. package/json-en-decoder.d.ts.map +1 -0
  103. package/json-en-decoder.js +42 -0
  104. package/json-en-decoder.js.map +1 -0
  105. package/json-en-decoder.test.d.ts +2 -0
  106. package/json-en-decoder.test.d.ts.map +1 -0
  107. package/json-en-decoder.test.js +18 -0
  108. package/json-en-decoder.test.js.map +1 -0
  109. package/log-level-impl.d.ts +17 -0
  110. package/log-level-impl.d.ts.map +1 -0
  111. package/log-level-impl.js +75 -0
  112. package/log-level-impl.js.map +1 -0
  113. package/log-writer-impl.d.ts +11 -0
  114. package/log-writer-impl.d.ts.map +1 -0
  115. package/log-writer-impl.js +52 -0
  116. package/log-writer-impl.js.map +1 -0
  117. package/logger-impl.d.ts +75 -0
  118. package/logger-impl.d.ts.map +1 -0
  119. package/logger-impl.js +505 -0
  120. package/logger-impl.js.map +1 -0
  121. package/logger.d.ts +97 -0
  122. package/logger.d.ts.map +1 -0
  123. package/logger.js +150 -0
  124. package/logger.js.map +1 -0
  125. package/logger.test.d.ts +2 -0
  126. package/logger.test.d.ts.map +1 -0
  127. package/logger.test.js +1577 -0
  128. package/logger.test.js.map +1 -0
  129. package/lru-map-set.d.ts +33 -0
  130. package/lru-map-set.d.ts.map +1 -0
  131. package/lru-map-set.js +116 -0
  132. package/lru-map-set.js.map +1 -0
  133. package/lru-map-set.test.d.ts +2 -0
  134. package/lru-map-set.test.d.ts.map +1 -0
  135. package/lru-map-set.test.js +81 -0
  136. package/lru-map-set.test.js.map +1 -0
  137. package/node/index.d.ts +4 -45
  138. package/node/index.d.ts.map +1 -0
  139. package/node/index.js +3 -222
  140. package/node/index.js.map +1 -1
  141. package/node/mock-file-service.d.ts +11 -0
  142. package/node/mock-file-service.d.ts.map +1 -0
  143. package/node/mock-file-service.js +31 -0
  144. package/node/mock-file-service.js.map +1 -0
  145. package/node/mock-file-service.test.d.ts +2 -0
  146. package/node/mock-file-service.test.d.ts.map +1 -0
  147. package/node/mock-file-service.test.js +31 -0
  148. package/node/mock-file-service.test.js.map +1 -0
  149. package/node/node-basic-sys-abstraction.d.ts +25 -0
  150. package/node/node-basic-sys-abstraction.d.ts.map +1 -0
  151. package/node/node-basic-sys-abstraction.js +45 -0
  152. package/node/node-basic-sys-abstraction.js.map +1 -0
  153. package/node/node-env-actions.d.ts +15 -0
  154. package/node/node-env-actions.d.ts.map +1 -0
  155. package/node/node-env-actions.js +38 -0
  156. package/node/node-env-actions.js.map +1 -0
  157. package/node/node-file-service.d.ts +16 -0
  158. package/node/node-file-service.d.ts.map +1 -0
  159. package/node/node-file-service.js +72 -0
  160. package/node/node-file-service.js.map +1 -0
  161. package/node/node-sys-abstraction.d.ts +19 -0
  162. package/node/node-sys-abstraction.d.ts.map +1 -0
  163. package/node/node-sys-abstraction.js +95 -0
  164. package/node/node-sys-abstraction.js.map +1 -0
  165. package/node/node-sys-abstraction.test.d.ts +2 -0
  166. package/node/node-sys-abstraction.test.d.ts.map +1 -0
  167. package/node/node-sys-abstraction.test.js +83 -0
  168. package/node/node-sys-abstraction.test.js.map +1 -0
  169. package/option.d.ts +26 -0
  170. package/option.d.ts.map +1 -0
  171. package/option.js +54 -0
  172. package/option.js.map +1 -0
  173. package/package.json +4 -10
  174. package/path-ops.d.ts +7 -0
  175. package/path-ops.d.ts.map +1 -0
  176. package/path-ops.js +35 -0
  177. package/path-ops.js.map +1 -0
  178. package/path-ops.test.d.ts +2 -0
  179. package/path-ops.test.d.ts.map +1 -0
  180. package/path-ops.test.js +39 -0
  181. package/path-ops.test.js.map +1 -0
  182. package/resolve-once.d.ts +59 -0
  183. package/resolve-once.d.ts.map +1 -0
  184. package/resolve-once.js +212 -0
  185. package/resolve-once.js.map +1 -0
  186. package/resolve-once.test.d.ts +2 -0
  187. package/resolve-once.test.d.ts.map +1 -0
  188. package/resolve-once.test.js +392 -0
  189. package/resolve-once.test.js.map +1 -0
  190. package/result.d.ts +34 -0
  191. package/result.d.ts.map +1 -0
  192. package/result.js +94 -0
  193. package/result.js.map +1 -0
  194. package/result.test.d.ts +2 -0
  195. package/result.test.d.ts.map +1 -0
  196. package/result.test.js +83 -0
  197. package/result.test.js.map +1 -0
  198. package/runtime.d.ts +9 -0
  199. package/runtime.d.ts.map +1 -0
  200. package/runtime.js +33 -0
  201. package/runtime.js.map +1 -0
  202. package/src/jsr.json +1 -1
  203. package/src/uri.ts +62 -37
  204. package/sys-abstraction.d.ts +43 -0
  205. package/sys-abstraction.d.ts.map +1 -0
  206. package/sys-abstraction.js +28 -0
  207. package/sys-abstraction.js.map +1 -0
  208. package/sys-env.d.ts +46 -0
  209. package/sys-env.d.ts.map +1 -0
  210. package/sys-env.js +161 -0
  211. package/sys-env.js.map +1 -0
  212. package/sys-env.test.d.ts +2 -0
  213. package/sys-env.test.d.ts.map +1 -0
  214. package/sys-env.test.js +170 -0
  215. package/sys-env.test.js.map +1 -0
  216. package/test/index.d.ts +3 -4
  217. package/test/index.d.ts.map +1 -0
  218. package/test/index.js +2 -13
  219. package/test/index.js.map +1 -1
  220. package/test/log-write-stream.d.ts +27 -0
  221. package/test/log-write-stream.d.ts.map +1 -0
  222. package/test/log-write-stream.js +78 -0
  223. package/test/log-write-stream.js.map +1 -0
  224. package/test/mock-logger.d.ts +14 -0
  225. package/test/mock-logger.d.ts.map +1 -0
  226. package/test/mock-logger.js +29 -0
  227. package/test/mock-logger.js.map +1 -0
  228. package/test/mock-logger.test.d.ts +2 -0
  229. package/test/mock-logger.test.d.ts.map +1 -0
  230. package/test/mock-logger.test.js +63 -0
  231. package/test/mock-logger.test.js.map +1 -0
  232. package/test/test-exit-handler.d.ts +2 -0
  233. package/test/test-exit-handler.d.ts.map +1 -0
  234. package/test/test-exit-handler.js +61 -0
  235. package/test/test-exit-handler.js.map +1 -0
  236. package/time.d.ts +14 -0
  237. package/time.d.ts.map +1 -0
  238. package/time.js +13 -0
  239. package/time.js.map +1 -0
  240. package/tracer.d.ts +59 -0
  241. package/tracer.d.ts.map +1 -0
  242. package/tracer.js +174 -0
  243. package/tracer.js.map +1 -0
  244. package/tracer.test.d.ts +2 -0
  245. package/tracer.test.d.ts.map +1 -0
  246. package/tracer.test.js +304 -0
  247. package/tracer.test.js.map +1 -0
  248. package/ts/smoke/smoke.js +1 -1
  249. package/ts/smoke/smoke.js.map +1 -1
  250. package/ts/src/base-sys-abstraction.js +20 -8
  251. package/ts/src/base-sys-abstraction.js.map +1 -1
  252. package/ts/src/cf/cf-basic-sys-abstraction.js +3 -3
  253. package/ts/src/cf/cf-basic-sys-abstraction.js.map +1 -1
  254. package/ts/src/cf/cf-env-actions.js +3 -1
  255. package/ts/src/cf/cf-env-actions.js.map +1 -1
  256. package/ts/src/coerce-binary.js +1 -1
  257. package/ts/src/coerce-binary.js.map +1 -1
  258. package/ts/src/deno/deno-basic-sys-abstraction.js +3 -3
  259. package/ts/src/deno/deno-basic-sys-abstraction.js.map +1 -1
  260. package/ts/src/deno/deno-env-actions.js +3 -9
  261. package/ts/src/deno/deno-env-actions.js.map +1 -1
  262. package/ts/src/deno/deno-file-service.js +2 -0
  263. package/ts/src/deno/deno-file-service.js.map +1 -1
  264. package/ts/src/deno/deno-sys-abstraction.js +21 -21
  265. package/ts/src/deno/deno-sys-abstraction.js.map +1 -1
  266. package/ts/src/future.js +13 -26
  267. package/ts/src/future.js.map +1 -1
  268. package/ts/src/http_header.js +2 -3
  269. package/ts/src/http_header.js.map +1 -1
  270. package/ts/src/json-en-decoder.js +3 -2
  271. package/ts/src/json-en-decoder.js.map +1 -1
  272. package/ts/src/log-level-impl.js +4 -6
  273. package/ts/src/log-level-impl.js.map +1 -1
  274. package/ts/src/log-writer-impl.js +9 -5
  275. package/ts/src/log-writer-impl.js.map +1 -1
  276. package/ts/src/logger-impl.js +15 -5
  277. package/ts/src/logger-impl.js.map +1 -1
  278. package/ts/src/logger.js +3 -3
  279. package/ts/src/logger.js.map +1 -1
  280. package/ts/src/logger.test.js +7 -19
  281. package/ts/src/logger.test.js.map +1 -1
  282. package/ts/src/lru-map-set.js +3 -1
  283. package/ts/src/lru-map-set.js.map +1 -1
  284. package/ts/src/node/mock-file-service.js +1 -4
  285. package/ts/src/node/mock-file-service.js.map +1 -1
  286. package/ts/src/node/node-basic-sys-abstraction.js +4 -3
  287. package/ts/src/node/node-basic-sys-abstraction.js.map +1 -1
  288. package/ts/src/node/node-env-actions.js +3 -9
  289. package/ts/src/node/node-env-actions.js.map +1 -1
  290. package/ts/src/node/node-file-service.js +1 -0
  291. package/ts/src/node/node-file-service.js.map +1 -1
  292. package/ts/src/node/node-sys-abstraction.js +21 -21
  293. package/ts/src/node/node-sys-abstraction.js.map +1 -1
  294. package/ts/src/option.js +1 -0
  295. package/ts/src/option.js.map +1 -1
  296. package/ts/src/path-ops.js +21 -30
  297. package/ts/src/path-ops.js.map +1 -1
  298. package/ts/src/resolve-once.js +17 -13
  299. package/ts/src/resolve-once.js.map +1 -1
  300. package/ts/src/result.js +2 -0
  301. package/ts/src/result.js.map +1 -1
  302. package/ts/src/sys-abstraction.js +1 -1
  303. package/ts/src/sys-abstraction.js.map +1 -1
  304. package/ts/src/sys-env.js +2 -1
  305. package/ts/src/sys-env.js.map +1 -1
  306. package/ts/src/sys-env.test.js +6 -19
  307. package/ts/src/sys-env.test.js.map +1 -1
  308. package/ts/src/test/log-write-stream.js +10 -6
  309. package/ts/src/test/log-write-stream.js.map +1 -1
  310. package/ts/src/test/mock-logger.js +6 -6
  311. package/ts/src/test/mock-logger.js.map +1 -1
  312. package/ts/src/test/test-exit-handler.js +1 -2
  313. package/ts/src/test/test-exit-handler.js.map +1 -1
  314. package/ts/src/tracer.js +10 -3
  315. package/ts/src/tracer.js.map +1 -1
  316. package/ts/src/tracer.test.js +5 -9
  317. package/ts/src/tracer.test.js.map +1 -1
  318. package/ts/src/txt-en-decoder.js +2 -4
  319. package/ts/src/txt-en-decoder.js.map +1 -1
  320. package/ts/src/types.js +2 -6
  321. package/ts/src/types.js.map +1 -1
  322. package/ts/src/uri.d.ts +4 -0
  323. package/ts/src/uri.d.ts.map +1 -1
  324. package/ts/src/uri.js +54 -34
  325. package/ts/src/uri.js.map +1 -1
  326. package/ts/src/uri.test.js +27 -0
  327. package/ts/src/uri.test.js.map +1 -1
  328. package/ts/src/utils/console-write-stream.js +8 -5
  329. package/ts/src/utils/console-write-stream.js.map +1 -1
  330. package/ts/src/utils/fanout-write-stream.js +4 -1
  331. package/ts/src/utils/fanout-write-stream.js.map +1 -1
  332. package/ts/src/utils/rebuffer.test.js +1 -1
  333. package/ts/src/utils/rebuffer.test.js.map +1 -1
  334. package/ts/src/utils/relative-path.js +1 -0
  335. package/ts/src/utils/relative-path.js.map +1 -1
  336. package/ts/src/utils/stream-map.test.js +1 -1
  337. package/ts/src/utils/stream-map.test.js.map +1 -1
  338. package/ts/src/web/web-basic-sys-abstraction.js +3 -3
  339. package/ts/src/web/web-basic-sys-abstraction.js.map +1 -1
  340. package/ts/src/web/web-env-actions.js +2 -1
  341. package/ts/src/web/web-env-actions.js.map +1 -1
  342. package/txt-en-decoder.d.ts +11 -0
  343. package/txt-en-decoder.d.ts.map +1 -0
  344. package/txt-en-decoder.js +37 -0
  345. package/txt-en-decoder.js.map +1 -0
  346. package/txt-en-decoder.test.d.ts +2 -0
  347. package/txt-en-decoder.test.d.ts.map +1 -0
  348. package/txt-en-decoder.test.js +48 -0
  349. package/txt-en-decoder.test.js.map +1 -0
  350. package/types.d.ts +16 -0
  351. package/types.d.ts.map +1 -0
  352. package/types.js +11 -0
  353. package/types.js.map +1 -0
  354. package/uri.d.ts +137 -0
  355. package/uri.d.ts.map +1 -0
  356. package/uri.js +567 -0
  357. package/uri.js.map +1 -0
  358. package/uri.test.d.ts +2 -0
  359. package/uri.test.d.ts.map +1 -0
  360. package/uri.test.js +633 -0
  361. package/uri.test.js.map +1 -0
  362. package/utils/coerce-uint8.d.ts +8 -0
  363. package/utils/coerce-uint8.d.ts.map +1 -0
  364. package/utils/coerce-uint8.js +34 -0
  365. package/utils/coerce-uint8.js.map +1 -0
  366. package/utils/console-write-stream.d.ts +21 -0
  367. package/utils/console-write-stream.d.ts.map +1 -0
  368. package/utils/console-write-stream.js +66 -0
  369. package/utils/console-write-stream.js.map +1 -0
  370. package/utils/fanout-write-stream.d.ts +12 -0
  371. package/utils/fanout-write-stream.d.ts.map +1 -0
  372. package/utils/fanout-write-stream.js +27 -0
  373. package/utils/fanout-write-stream.js.map +1 -0
  374. package/utils/get-params-result.d.ts +8 -0
  375. package/utils/get-params-result.d.ts.map +1 -0
  376. package/utils/get-params-result.js +45 -0
  377. package/utils/get-params-result.js.map +1 -0
  378. package/utils/index.d.ts +12 -3
  379. package/utils/index.d.ts.map +1 -0
  380. package/utils/index.js +11 -50
  381. package/utils/index.js.map +1 -1
  382. package/utils/rebuffer.d.ts +3 -0
  383. package/utils/rebuffer.d.ts.map +1 -0
  384. package/utils/rebuffer.js +66 -0
  385. package/utils/rebuffer.js.map +1 -0
  386. package/utils/rebuffer.test.d.ts +2 -0
  387. package/utils/rebuffer.test.d.ts.map +1 -0
  388. package/utils/rebuffer.test.js +77 -0
  389. package/utils/rebuffer.test.js.map +1 -0
  390. package/utils/relative-path.d.ts +18 -0
  391. package/utils/relative-path.d.ts.map +1 -0
  392. package/utils/relative-path.js +148 -0
  393. package/utils/relative-path.js.map +1 -0
  394. package/utils/relative-path.test.d.ts +2 -0
  395. package/utils/relative-path.test.d.ts.map +1 -0
  396. package/utils/relative-path.test.js +187 -0
  397. package/utils/relative-path.test.js.map +1 -0
  398. package/utils/sorted-objec.test.d.ts +2 -0
  399. package/utils/sorted-objec.test.d.ts.map +1 -0
  400. package/utils/sorted-objec.test.js +20 -0
  401. package/utils/sorted-objec.test.js.map +1 -0
  402. package/utils/sorted-object.d.ts +4 -0
  403. package/utils/sorted-object.d.ts.map +1 -0
  404. package/utils/sorted-object.js +16 -0
  405. package/utils/sorted-object.js.map +1 -0
  406. package/utils/stream-map.d.ts +9 -0
  407. package/utils/stream-map.d.ts.map +1 -0
  408. package/utils/stream-map.js +63 -0
  409. package/utils/stream-map.js.map +1 -0
  410. package/utils/stream-map.test.d.ts +2 -0
  411. package/utils/stream-map.test.d.ts.map +1 -0
  412. package/utils/stream-map.test.js +87 -0
  413. package/utils/stream-map.test.js.map +1 -0
  414. package/utils/stream-test-helper.d.ts +17 -0
  415. package/utils/stream-test-helper.d.ts.map +1 -0
  416. package/utils/stream-test-helper.js +45 -0
  417. package/utils/stream-test-helper.js.map +1 -0
  418. package/utils/stream2string.d.ts +3 -0
  419. package/utils/stream2string.d.ts.map +1 -0
  420. package/utils/stream2string.js +48 -0
  421. package/utils/stream2string.js.map +1 -0
  422. package/utils/stream2string.test.d.ts +2 -0
  423. package/utils/stream2string.test.d.ts.map +1 -0
  424. package/utils/stream2string.test.js +29 -0
  425. package/utils/stream2string.test.js.map +1 -0
  426. package/utils/string2stream.d.ts +4 -0
  427. package/utils/string2stream.d.ts.map +1 -0
  428. package/utils/string2stream.js +13 -0
  429. package/utils/string2stream.js.map +1 -0
  430. package/utils/string2stream.test.d.ts +2 -0
  431. package/utils/string2stream.test.d.ts.map +1 -0
  432. package/utils/string2stream.test.js +6 -0
  433. package/utils/string2stream.test.js.map +1 -0
  434. package/utils/stripper.d.ts +3 -0
  435. package/utils/stripper.d.ts.map +1 -0
  436. package/utils/stripper.js +59 -0
  437. package/utils/stripper.js.map +1 -0
  438. package/utils/stripper.test.d.ts +2 -0
  439. package/utils/stripper.test.d.ts.map +1 -0
  440. package/utils/stripper.test.js +128 -0
  441. package/utils/stripper.test.js.map +1 -0
  442. package/utils/uint8array-equal.d.ts +2 -0
  443. package/utils/uint8array-equal.d.ts.map +1 -0
  444. package/utils/uint8array-equal.js +12 -0
  445. package/utils/uint8array-equal.js.map +1 -0
  446. package/version.d.ts +2 -0
  447. package/version.d.ts.map +1 -0
  448. package/version.js +4 -0
  449. package/version.js.map +1 -0
  450. package/web/index.d.ts +2 -7
  451. package/web/index.d.ts.map +1 -0
  452. package/web/index.js +1 -7
  453. package/web/index.js.map +1 -1
  454. package/web/web-basic-sys-abstraction.d.ts +4 -0
  455. package/web/web-basic-sys-abstraction.d.ts.map +1 -0
  456. package/web/web-basic-sys-abstraction.js +45 -0
  457. package/web/web-basic-sys-abstraction.js.map +1 -0
  458. package/web/web-env-actions.d.ts +14 -0
  459. package/web/web-env-actions.d.ts.map +1 -0
  460. package/web/web-env-actions.js +36 -0
  461. package/web/web-env-actions.js.map +1 -0
  462. package/base-sys-abstraction-DgTynXGV.d.cts +0 -95
  463. package/cf/index.cjs +0 -1110
  464. package/cf/index.cjs.map +0 -1
  465. package/cf/index.d.cts +0 -30
  466. package/chunk-2DWEYXJH.js +0 -1681
  467. package/chunk-2DWEYXJH.js.map +0 -1
  468. package/chunk-FOALXQST.js +0 -89
  469. package/chunk-FOALXQST.js.map +0 -1
  470. package/chunk-FURW5CDL.js +0 -792
  471. package/chunk-FURW5CDL.js.map +0 -1
  472. package/chunk-NJMNJYN2.js +0 -270
  473. package/chunk-NJMNJYN2.js.map +0 -1
  474. package/chunk-NTOGMD33.js +0 -684
  475. package/chunk-NTOGMD33.js.map +0 -1
  476. package/deno/index.cjs +0 -1280
  477. package/deno/index.cjs.map +0 -1
  478. package/deno/index.d.cts +0 -37
  479. package/get-params-result-4xHM5s4_.d.cts +0 -71
  480. package/get-params-result-4xHM5s4_.d.ts +0 -71
  481. package/index-CMLb7JSe.d.ts +0 -97
  482. package/index-DH243CLH.d.cts +0 -297
  483. package/index-LQOsS7gM.d.cts +0 -97
  484. package/index-RMC1sv15.d.ts +0 -297
  485. package/index.cjs +0 -4009
  486. package/index.cjs.map +0 -1
  487. package/index.d.cts +0 -396
  488. package/metafile-cjs.json +0 -1
  489. package/metafile-esm.json +0 -1
  490. package/node/index.cjs +0 -1335
  491. package/node/index.cjs.map +0 -1
  492. package/node/index.d.cts +0 -45
  493. package/stripper-BpBUUZ9p.d.cts +0 -4
  494. package/stripper-BpBUUZ9p.d.ts +0 -4
  495. package/sys-abstraction-CeAxxg9H.d.ts +0 -117
  496. package/sys-abstraction-DDAwGTnk.d.cts +0 -117
  497. package/test/index.cjs +0 -2994
  498. package/test/index.cjs.map +0 -1
  499. package/test/index.d.cts +0 -4
  500. package/utils/index.cjs +0 -778
  501. package/utils/index.cjs.map +0 -1
  502. package/utils/index.d.cts +0 -3
  503. package/web/index.cjs +0 -1153
  504. package/web/index.cjs.map +0 -1
  505. package/web/index.d.cts +0 -7
package/index.cjs DELETED
@@ -1,4009 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __typeError = (msg) => {
9
- throw TypeError(msg);
10
- };
11
- var __export = (target, all) => {
12
- for (var name in all)
13
- __defProp(target, name, { get: all[name], enumerable: true });
14
- };
15
- var __copyProps = (to, from2, except, desc) => {
16
- if (from2 && typeof from2 === "object" || typeof from2 === "function") {
17
- for (let key of __getOwnPropNames(from2))
18
- if (!__hasOwnProp.call(to, key) && key !== except)
19
- __defProp(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc(from2, key)) || desc.enumerable });
20
- }
21
- return to;
22
- };
23
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
- // If the importer is in node compatibility mode or this is not an ESM
25
- // file that has been converted to a CommonJS file using a Babel-
26
- // compatible transform (i.e. "__esModule" has not been set), then set
27
- // "default" to the CommonJS "module.exports" for node compatibility.
28
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
- mod
30
- ));
31
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
33
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
34
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
35
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
36
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
37
-
38
- // src/index.ts
39
- var index_exports = {};
40
- __export(index_exports, {
41
- BaseBasicSysAbstraction: () => BaseBasicSysAbstraction,
42
- BaseSysAbstraction: () => BaseSysAbstraction,
43
- BasicSysAbstractionFactory: () => BasicSysAbstractionFactory,
44
- BuildURI: () => BuildURI,
45
- ConstTime: () => ConstTime,
46
- EnvImpl: () => EnvImpl,
47
- Future: () => Future,
48
- HeadersImpl: () => HeadersImpl,
49
- HttpHeader: () => HttpHeader,
50
- IDMode: () => IDMode,
51
- IdService: () => IdService,
52
- IsLogger: () => IsLogger,
53
- JSONEnDecoderSingleton: () => JSONEnDecoderSingleton,
54
- JSONFormatter: () => JSONFormatter,
55
- Keyed: () => Keyed,
56
- KeyedResolvOnce: () => KeyedResolvOnce,
57
- KeyedResolvSeq: () => KeyedResolvSeq,
58
- LRUMap: () => LRUMap,
59
- LRUSet: () => LRUSet,
60
- Level: () => Level,
61
- LevelHandlerImpl: () => LevelHandlerImpl,
62
- LevelHandlerSingleton: () => LevelHandlerSingleton,
63
- LogCollector: () => LogCollector,
64
- LogValue: () => LogValue,
65
- LogWriteStream: () => LogWriteStream,
66
- LoggerImpl: () => LoggerImpl,
67
- Metric: () => Metric,
68
- Metrics: () => Metrics,
69
- MockLogger: () => MockLogger,
70
- MutableURL: () => MutableURL,
71
- None: () => None,
72
- Option: () => Option,
73
- RandomMode: () => RandomMode,
74
- RandomService: () => RandomService,
75
- ResolveOnce: () => ResolveOnce,
76
- ResolveSeq: () => ResolveSeq,
77
- Result: () => Result,
78
- ResultError: () => ResultError,
79
- ResultOK: () => ResultOK,
80
- Some: () => Some,
81
- StepTime: () => StepTime,
82
- String2TimeMode: () => String2TimeMode,
83
- SysTime: () => SysTime,
84
- Time: () => Time,
85
- TimeFactory: () => TimeFactory,
86
- TimeMode: () => TimeMode,
87
- TimeUnits: () => TimeUnits,
88
- TraceNode: () => TraceNode,
89
- TxtEnDecoderSingleton: () => TxtEnDecoderSingleton,
90
- URI: () => URI,
91
- VERSION: () => VERSION,
92
- WrapperBasicSysAbstraction: () => WrapperBasicSysAbstraction,
93
- WrapperRuntimeSysAbstraction: () => WrapperRuntimeSysAbstraction,
94
- YAMLFormatter: () => YAMLFormatter,
95
- asyncLogValue: () => asyncLogValue,
96
- bin2string: () => bin2string,
97
- bin2text: () => bin2text,
98
- envFactory: () => envFactory,
99
- exception2Result: () => exception2Result,
100
- hasHostPartProtocols: () => hasHostPartProtocols,
101
- isCoerceURI: () => isCoerceURI,
102
- isPromise: () => isPromise,
103
- isURL: () => isURL,
104
- logValue: () => logValue,
105
- param: () => param,
106
- pathOps: () => pathOps,
107
- registerEnvAction: () => registerEnvAction,
108
- runtimeFn: () => runtimeFn,
109
- toCryptoRuntime: () => toCryptoRuntime,
110
- to_arraybuf: () => to_arraybuf,
111
- to_blob: () => to_blob,
112
- to_uint8: () => to_uint8,
113
- top_uint8: () => top_uint8,
114
- utils: () => utils_exports
115
- });
116
- module.exports = __toCommonJS(index_exports);
117
-
118
- // src/logger-impl.ts
119
- var import_yaml = __toESM(require("yaml"), 1);
120
-
121
- // src/is-promise.ts
122
- function isPromise(a) {
123
- const mayBe = a;
124
- return mayBe instanceof Promise || !!(mayBe && mayBe !== null && typeof mayBe.then === "function" && typeof mayBe.catch === "function" && typeof mayBe.finally === "function");
125
- }
126
-
127
- // src/bin2text.ts
128
- function bin2text(hex, lineFn, size = 0) {
129
- const arr = new Uint8Array(hex.buffer, hex.byteOffset, hex.byteLength);
130
- let cutted = " ";
131
- if (size == 0) {
132
- size = arr.length;
133
- }
134
- size = Math.min(size, arr.length);
135
- const cols = 16;
136
- for (let line = 0; line < size; line += cols) {
137
- if (line + cols <= size || arr.length == size) {
138
- } else {
139
- line = arr.length - arr.length % cols;
140
- size = arr.length;
141
- cutted = ">>";
142
- }
143
- const l = [line.toString(16).padStart(4, "0"), cutted];
144
- for (let col = 0; col < cols; col++) {
145
- if (line + col < size) {
146
- l.push(arr[line + col].toString(16).padStart(2, "0"));
147
- } else {
148
- l.push(" ");
149
- }
150
- l.push(" ");
151
- }
152
- for (let col = 0; col < cols; col++) {
153
- if (line + col < size) {
154
- const ch = arr[line + col];
155
- l.push(ch >= 32 && ch < 127 ? String.fromCharCode(ch) : ".");
156
- }
157
- }
158
- lineFn(l.join(""));
159
- }
160
- }
161
- function bin2string(hex, size = 0) {
162
- const collector = [];
163
- bin2text(
164
- hex,
165
- (line) => {
166
- collector.push(line);
167
- },
168
- size
169
- );
170
- return collector.join("\n");
171
- }
172
-
173
- // src/logger.ts
174
- var Level = {
175
- WARN: "warn",
176
- DEBUG: "debug",
177
- INFO: "info",
178
- ERROR: "error"
179
- };
180
- var LogValue = class {
181
- constructor(fn) {
182
- this.fn = fn;
183
- }
184
- value() {
185
- try {
186
- return this.fn();
187
- } catch (e) {
188
- return `LogValue:${e.message}`;
189
- }
190
- }
191
- toJSON() {
192
- return this.value();
193
- }
194
- };
195
- function asyncLogValue(val) {
196
- throw new Error("Not implemented");
197
- }
198
- function logValue(val, ctx) {
199
- return logValueInternal(val, {
200
- ...ctx,
201
- state: ctx.state || /* @__PURE__ */ new Set([Math.random()])
202
- });
203
- }
204
- function logValueInternal(val, ctx) {
205
- var _a, _b;
206
- ctx = {
207
- ...ctx,
208
- state: ctx.state || /* @__PURE__ */ new Set([Math.random()])
209
- };
210
- switch (typeof val) {
211
- case "function":
212
- return new LogValue(val);
213
- case "string": {
214
- try {
215
- const ret = JSON.parse(val);
216
- if (typeof ret === "object" && ret !== null) {
217
- return logValueInternal(ret, ctx);
218
- }
219
- } catch (e) {
220
- try {
221
- const url = new URL(val);
222
- return new LogValue(() => url.toString());
223
- } catch (e2) {
224
- }
225
- }
226
- if (val.match(/[\n\r]/)) {
227
- const lines = val.split(/[\n\r]+/).map((v) => v.trim());
228
- return new LogValue(() => lines);
229
- }
230
- return new LogValue(() => val.toString());
231
- }
232
- case "number":
233
- return new LogValue(() => val);
234
- case "boolean":
235
- return new LogValue(() => val);
236
- case "object": {
237
- if (val === null) {
238
- return new LogValue(() => "null");
239
- }
240
- if (ArrayBuffer.isView(val)) {
241
- try {
242
- const decoder = new TextDecoder();
243
- const asStr = decoder.decode(val);
244
- const obj = JSON.parse(asStr);
245
- return logValueInternal(obj, ctx);
246
- } catch (e) {
247
- return logValueInternal(bin2string(val, 512), ctx);
248
- }
249
- }
250
- if (Array.isArray(val)) {
251
- return new LogValue(
252
- () => val.map((v) => logValue(v, { ...ctx, state: void 0 }).value())
253
- );
254
- }
255
- if (val instanceof Headers) {
256
- return new LogValue(() => Object.fromEntries(val.entries()));
257
- }
258
- if (val instanceof ReadableStream) {
259
- return new LogValue(() => ">Stream<");
260
- }
261
- if (isPromise(val)) {
262
- return new LogValue(() => ">Promise<");
263
- }
264
- if ((_a = ctx.state) == null ? void 0 : _a.has(val)) {
265
- return new LogValue(() => "...");
266
- }
267
- (_b = ctx.state) == null ? void 0 : _b.add(val);
268
- if (typeof val.toJSON === "function") {
269
- return new LogValue(() => val.toJSON());
270
- }
271
- const res = {};
272
- const typedVal = val;
273
- for (const key in typedVal) {
274
- if (ctx.ignoreAttr.IsSome() && ctx.ignoreAttr.unwrap().test(key)) {
275
- continue;
276
- }
277
- const element = typedVal[key];
278
- if (element instanceof LogValue) {
279
- res[key] = element;
280
- } else {
281
- if (typeof element !== "function") {
282
- res[key] = logValueInternal(element, ctx);
283
- }
284
- }
285
- }
286
- return new LogValue(() => res);
287
- }
288
- default:
289
- if (!val) {
290
- return new LogValue(() => "--Falsy--");
291
- }
292
- throw new Error(`Invalid type:${typeof val}`);
293
- }
294
- }
295
- function IsLogger(obj) {
296
- return typeof obj === "object" && [
297
- "Module",
298
- "EnableLevel",
299
- "DisableLevel",
300
- "SetDebug",
301
- "Str",
302
- "Error",
303
- "Warn",
304
- "Debug",
305
- "Log",
306
- "WithLevel",
307
- "Err",
308
- "Info",
309
- "Timestamp",
310
- "Any",
311
- "Dur",
312
- "Uint64"
313
- ].map((fn) => typeof obj[fn] === "function").reduce((a, b) => a && b, true);
314
- }
315
-
316
- // src/result.ts
317
- var Result = class _Result {
318
- static Ok(t) {
319
- return new ResultOK(t);
320
- }
321
- static Err(t) {
322
- if (typeof t === "string") {
323
- return new ResultError(new Error(t));
324
- }
325
- if (_Result.Is(t)) {
326
- if (t.is_ok()) {
327
- return new ResultError(new Error("Result Error is Ok"));
328
- }
329
- return t;
330
- }
331
- return new ResultError(t);
332
- }
333
- static Is(t) {
334
- if (!t) {
335
- return false;
336
- }
337
- if (t instanceof _Result) {
338
- return true;
339
- }
340
- const rt = t;
341
- if ([typeof rt.is_ok, typeof rt.is_err, typeof rt.unwrap, typeof rt.unwrap_err].every((x) => x === "function")) {
342
- return true;
343
- }
344
- return false;
345
- }
346
- isOk() {
347
- return this.is_ok();
348
- }
349
- isErr() {
350
- return this.is_err();
351
- }
352
- Ok() {
353
- return this.unwrap();
354
- }
355
- Err() {
356
- return this.unwrap_err();
357
- }
358
- };
359
- var ResultOK = class extends Result {
360
- constructor(t) {
361
- super();
362
- this._t = t;
363
- }
364
- is_ok() {
365
- return true;
366
- }
367
- is_err() {
368
- return false;
369
- }
370
- unwrap_err() {
371
- throw new Error("Result is Ok");
372
- }
373
- unwrap() {
374
- return this._t;
375
- }
376
- };
377
- var ResultError = class extends Result {
378
- constructor(t) {
379
- super();
380
- this._error = t;
381
- }
382
- is_ok() {
383
- return false;
384
- }
385
- is_err() {
386
- return true;
387
- }
388
- unwrap() {
389
- throw new Error(`Result is Err: ${this._error}`);
390
- }
391
- unwrap_err() {
392
- return this._error;
393
- }
394
- };
395
- function exception2Result(fn) {
396
- try {
397
- const res = fn();
398
- if (isPromise(res)) {
399
- return res.then((value) => Result.Ok(value)).catch((e) => Result.Err(e));
400
- }
401
- return Result.Ok(res);
402
- } catch (e) {
403
- return Result.Err(e);
404
- }
405
- }
406
-
407
- // src/types.ts
408
- var _Required = class {
409
- constructor() {
410
- this.type = "REQUIRED";
411
- }
412
- };
413
- var _Optional = class {
414
- constructor() {
415
- this.type = "OPTIONAL";
416
- }
417
- };
418
- var param = {
419
- REQUIRED: new _Required(),
420
- OPTIONAL: new _Optional()
421
- };
422
-
423
- // src/utils/get-params-result.ts
424
- function getParamsResult(keys, getParam) {
425
- const keyDef = keys.flat().reduce(
426
- (acc, i) => {
427
- if (typeof i === "string") {
428
- acc.push({ key: i, def: void 0, isOptional: false });
429
- } else if (typeof i === "object") {
430
- acc.push(
431
- ...Object.keys(i).map((k) => ({
432
- key: k,
433
- def: typeof i[k] === "string" ? i[k] : void 0,
434
- isOptional: i[k] === param.OPTIONAL
435
- }))
436
- );
437
- }
438
- return acc;
439
- },
440
- []
441
- );
442
- const msgFn = keys.find((k) => typeof k === "function") || ((...keys2) => {
443
- const msg = keys2.join(",");
444
- return `missing parameters: ${msg}`;
445
- });
446
- const errors = [];
447
- const result = {};
448
- for (const kd of keyDef) {
449
- const val = getParam.getParam(kd.key);
450
- if (val === void 0) {
451
- if (typeof kd.def === "string") {
452
- result[kd.key] = kd.def;
453
- } else {
454
- if (!kd.isOptional) {
455
- errors.push(kd.key);
456
- }
457
- }
458
- } else {
459
- result[kd.key] = val;
460
- }
461
- }
462
- if (errors.length) {
463
- return Result.Err(msgFn(...errors));
464
- }
465
- return Result.Ok(result);
466
- }
467
-
468
- // src/utils/relative-path.ts
469
- var PartType = {
470
- Slash: 1,
471
- Root: 3,
472
- Up: 4,
473
- Noop: 8
474
- // RootUp = 0x8 /* ../ */,
475
- };
476
- var Path = class {
477
- constructor(parts = []) {
478
- this.parts = parts;
479
- }
480
- toString() {
481
- return this.parts.map((part) => {
482
- if (typeof part === "string") {
483
- return part;
484
- } else {
485
- switch (part) {
486
- case PartType.Slash:
487
- case PartType.Root:
488
- return "/";
489
- case PartType.Up:
490
- return "..";
491
- default:
492
- return part;
493
- }
494
- }
495
- }).join("");
496
- }
497
- add(part) {
498
- if (this.parts.includes(PartType.Root) && part === PartType.Root) {
499
- throw new Error("Cannot add absolute part to absolute path");
500
- }
501
- const last = this.parts[this.parts.length - 1];
502
- if (last & PartType.Slash && part === PartType.Slash) {
503
- return;
504
- }
505
- switch (part) {
506
- case ".":
507
- this.parts.push(PartType.Noop);
508
- return;
509
- case "..":
510
- part = PartType.Up;
511
- }
512
- if (last === PartType.Noop && part === PartType.Slash) {
513
- if (last === PartType.Noop) {
514
- this.parts.pop();
515
- }
516
- return;
517
- }
518
- this.parts.push(part);
519
- }
520
- };
521
- function splitPath(path) {
522
- const p = new Path();
523
- if (path === "") {
524
- return p;
525
- }
526
- for (let count = 0; path.length; count++) {
527
- if (path.match(/^\/+/)) {
528
- if (count === 0) {
529
- p.add(PartType.Root);
530
- } else {
531
- p.add(PartType.Slash);
532
- }
533
- path = path.replace(/^\/+/, "");
534
- } else {
535
- const part = path.replace(/\/.*$/, "");
536
- p.add(part);
537
- path = path.replace(/^[^/]+/, "");
538
- }
539
- }
540
- return p;
541
- }
542
- function pathJoin(...paths) {
543
- let prev = "";
544
- const res = [];
545
- for (let i = 0; i < paths.length; i++) {
546
- const path = paths[i];
547
- if (path === "") {
548
- continue;
549
- }
550
- if (!(prev.endsWith("/") || path.startsWith("/"))) {
551
- if (prev !== "") {
552
- res.push("/");
553
- }
554
- res.push(path);
555
- } else {
556
- res.push(path);
557
- }
558
- prev = path;
559
- }
560
- return res.join("");
561
- }
562
- function relativePath(path, relative) {
563
- const relativeParts = splitPath(relative);
564
- let result;
565
- if (relativeParts.parts[0] === PartType.Root) {
566
- result = relative;
567
- } else {
568
- result = pathJoin(path, relative);
569
- }
570
- const unoptPath = splitPath(result);
571
- const out = [];
572
- let topUp = false;
573
- for (const part of unoptPath.parts) {
574
- switch (part) {
575
- case PartType.Root:
576
- out.push(PartType.Root);
577
- break;
578
- case PartType.Up:
579
- if (out.length && !topUp) {
580
- const last = out.length - 1;
581
- if (typeof out[last] === "string" && out[last - 1] == PartType.Root) {
582
- out.pop();
583
- } else {
584
- out.pop();
585
- out.pop();
586
- }
587
- if (out.length === 0) {
588
- topUp = !topUp ? true : topUp;
589
- out.push(PartType.Up);
590
- }
591
- } else {
592
- out.push(PartType.Up);
593
- }
594
- break;
595
- case PartType.Slash:
596
- if (!(out[out.length - 1] & PartType.Slash)) {
597
- out.push(PartType.Slash);
598
- }
599
- break;
600
- default:
601
- out.push(part);
602
- break;
603
- }
604
- }
605
- return new Path(out).toString();
606
- }
607
-
608
- // src/utils/stripper.ts
609
- function stripper(strip, obj) {
610
- const strips = Array.isArray(strip) ? strip : [strip];
611
- const restrips = strips.map((s) => {
612
- if (typeof s === "string") {
613
- const escaped = s.replace(/[-\\[\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\^\\$\\|]/g, "\\$&");
614
- return new RegExp(`^${escaped}$`);
615
- }
616
- return s;
617
- });
618
- return localStripper(void 0, restrips, obj);
619
- }
620
- function localStripper(path, restrips, obj) {
621
- if (typeof obj !== "object" || obj === null) {
622
- return obj;
623
- }
624
- if (Array.isArray(obj)) {
625
- return obj.map((i) => localStripper(path, restrips, i));
626
- }
627
- const ret = { ...obj };
628
- const matcher = (key, nextPath) => {
629
- for (const re of restrips) {
630
- if (re.test(key) || re.test(nextPath)) {
631
- return true;
632
- }
633
- }
634
- return false;
635
- };
636
- for (const key in ret) {
637
- if (Object.prototype.hasOwnProperty.call(ret, key)) {
638
- let nextPath;
639
- if (path) {
640
- nextPath = [path, key].join(".");
641
- } else {
642
- nextPath = key;
643
- }
644
- if (matcher(key, nextPath)) {
645
- delete ret[key];
646
- continue;
647
- }
648
- if (typeof ret[key] === "object") {
649
- if (Array.isArray(ret[key])) {
650
- ret[key] = ret[key].reduce((acc, v, i) => {
651
- const toDelete = matcher(key, `${nextPath}[${i}]`);
652
- if (!toDelete) {
653
- acc.push(localStripper(`${nextPath}[${i}]`, restrips, v));
654
- }
655
- return acc;
656
- }, []);
657
- } else {
658
- ret[key] = localStripper(nextPath, restrips, ret[key]);
659
- }
660
- }
661
- }
662
- }
663
- return ret;
664
- }
665
-
666
- // src/uri.ts
667
- function match(iref, ioth) {
668
- const mr = {
669
- score: 0,
670
- protocol: false,
671
- hostname: false,
672
- port: false,
673
- pathname: false,
674
- pathParts: [],
675
- params: {}
676
- };
677
- const ref = URI.from(iref);
678
- const oth = URI.from(ioth);
679
- if (ref.protocol === oth.protocol) {
680
- mr.score += 1;
681
- mr.protocol = true;
682
- }
683
- try {
684
- const refH = ref.hostname;
685
- const refP = ref.port;
686
- if (refH === oth.hostname) {
687
- mr.score += 1;
688
- mr.hostname = true;
689
- }
690
- if (refP.length && refP === oth.port) {
691
- mr.score += 1;
692
- mr.port = true;
693
- }
694
- } catch (e) {
695
- }
696
- if (ref.pathname.length && ref.pathname !== "/") {
697
- const pref = ref.pathname.split("/").filter((p) => p.length);
698
- const poth = oth.pathname.split("/").filter((p) => p.length);
699
- for (let i = 0; i < pref.length && i < poth.length; i++) {
700
- if (poth[i] === pref[i]) {
701
- mr.score += 1;
702
- mr.pathname = true;
703
- mr.pathParts.push(pref[i]);
704
- }
705
- }
706
- }
707
- for (const [key, value] of ref.getParams) {
708
- if (oth.getParam(key) === value) {
709
- mr.score += 1;
710
- mr.params[key] = value;
711
- }
712
- }
713
- return mr;
714
- }
715
- function coerceKey(key, def) {
716
- if (typeof key === "object") {
717
- const keys = Object.keys(key);
718
- if (keys.length !== 1) {
719
- throw new Error(`Invalid key: ${JSON.stringify(key)}`);
720
- }
721
- return { key: keys[0], def: key[keys[0]] };
722
- }
723
- return { key, def };
724
- }
725
- function resolveHash(hash) {
726
- const searchParams = new URLSearchParams(hash.replace(/^#/, ""));
727
- return {
728
- getParam: (k) => {
729
- const ret = searchParams.get(k);
730
- return ret === null ? void 0 : ret;
731
- }
732
- };
733
- }
734
- function falsy2undef(value) {
735
- return value === void 0 || value === null ? void 0 : value;
736
- }
737
- function ensureURLWithDefaultProto(url, defaultProtocol) {
738
- if (!url) {
739
- return new MutableURL(`${defaultProtocol}//`);
740
- }
741
- if (typeof url === "string") {
742
- try {
743
- return new MutableURL(url);
744
- } catch (e) {
745
- return new MutableURL(`${defaultProtocol}//${url}`);
746
- }
747
- } else {
748
- return new MutableURL(url.toString());
749
- }
750
- }
751
- function isURL(value) {
752
- return value instanceof URL || !!value && typeof value.searchParams === "object" && typeof value.searchParams.sort === "function" && typeof value.hash === "string";
753
- }
754
- var customInspectSymbol = Symbol.for("nodejs.util.inspect.custom");
755
- var MutableURL = class _MutableURL extends URL {
756
- // override readonly hash: string;
757
- constructor(urlStr) {
758
- super("defect://does.not.exist");
759
- const partedURL = urlStr.split(":");
760
- this._hasHostpart = hasHostPartProtocols.has(partedURL[0]);
761
- let hostPartUrl = ["http", ...partedURL.slice(1)].join(":");
762
- if (!this._hasHostpart) {
763
- const pathname = hostPartUrl.replace(/http:\/\/[/]*/, "").replace(/[#?].*$/, "");
764
- hostPartUrl = hostPartUrl.replace(/http:\/\//, `http://localhost/${pathname}`);
765
- }
766
- try {
767
- this._sysURL = new URL(hostPartUrl);
768
- } catch (ie) {
769
- const e = ie;
770
- e.message = `${e.message} for URL: ${urlStr}`;
771
- throw e;
772
- }
773
- this._protocol = `${partedURL[0]}:`;
774
- if (this._hasHostpart) {
775
- this._pathname = this._sysURL.pathname;
776
- } else {
777
- this._pathname = urlStr.replace(new RegExp(`^${this._protocol}//`), "").replace(/[#?].*$/, "");
778
- }
779
- }
780
- [customInspectSymbol]() {
781
- return this.toString();
782
- }
783
- clone() {
784
- return new _MutableURL(this.toString());
785
- }
786
- get host() {
787
- if (!this._hasHostpart) {
788
- throw new Error(
789
- `you can use hostname only if protocol is ${this.toString()} ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`
790
- );
791
- }
792
- return this._sysURL.host;
793
- }
794
- get port() {
795
- if (!this._hasHostpart) {
796
- throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);
797
- }
798
- return this._sysURL.port;
799
- }
800
- set port(p) {
801
- if (!this._hasHostpart) {
802
- throw new Error(`you can use port only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);
803
- }
804
- this._sysURL.port = p;
805
- }
806
- get hostname() {
807
- if (!this._hasHostpart) {
808
- throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);
809
- }
810
- return this._sysURL.hostname;
811
- }
812
- set hostname(h) {
813
- if (!this._hasHostpart) {
814
- throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);
815
- }
816
- this._sysURL.hostname = h;
817
- }
818
- set pathname(p) {
819
- this._pathname = p;
820
- }
821
- get pathname() {
822
- return this._pathname;
823
- }
824
- get protocol() {
825
- return this._protocol;
826
- }
827
- set protocol(p) {
828
- if (!p.endsWith(":")) {
829
- p = `${p}:`;
830
- }
831
- this._protocol = p;
832
- }
833
- get hash() {
834
- return this._sysURL.hash;
835
- }
836
- set hash(h) {
837
- this._sysURL.hash = h;
838
- }
839
- get searchParams() {
840
- return this._sysURL.searchParams;
841
- }
842
- get search() {
843
- let search = "";
844
- if (this._sysURL.searchParams.size) {
845
- for (const [key, value] of Array.from(this._sysURL.searchParams.entries()).sort((a, b) => a[0].localeCompare(b[0]))) {
846
- search += `${!search.length ? "?" : "&"}${key}=${encodeURIComponent(value)}`;
847
- }
848
- }
849
- return search;
850
- }
851
- toString() {
852
- const search = this.search;
853
- let hostpart = "";
854
- if (this._hasHostpart) {
855
- hostpart = this._sysURL.hostname;
856
- if (this._sysURL.port) {
857
- hostpart += `:${this._sysURL.port}`;
858
- }
859
- if (!this._pathname.startsWith("/")) {
860
- hostpart += "/";
861
- }
862
- }
863
- return `${this._protocol}//${hostpart}${this._pathname}${search}${this.hash}`;
864
- }
865
- };
866
- function from(fac, strURLUri, defaultProtocol) {
867
- switch (typeof falsy2undef(strURLUri)) {
868
- case "undefined":
869
- return fac(new MutableURL(`${defaultProtocol}///`));
870
- case "string":
871
- return fac(ensureURLWithDefaultProto(strURLUri, defaultProtocol));
872
- case "object":
873
- if (BuildURI.is(strURLUri)) {
874
- return fac(new MutableURL(strURLUri._url.toString()));
875
- } else if (URI.is(strURLUri)) {
876
- return fac(new MutableURL(strURLUri._url.toString()));
877
- } else if (isURL(strURLUri)) {
878
- return fac(new MutableURL(strURLUri.toString()));
879
- }
880
- throw new Error(`unknown object type: ${strURLUri}`);
881
- default:
882
- throw new Error(`Invalid argument: ${typeof strURLUri}`);
883
- }
884
- }
885
- function getParamResult(key, val, msgFn = (key2) => {
886
- return `missing parameter: ${key2}`;
887
- }) {
888
- if (val === void 0) {
889
- return Result.Err(msgFn(key));
890
- }
891
- return Result.Ok(val);
892
- }
893
- var BuildURI = class _BuildURI {
894
- // pathname needs this
895
- constructor(url) {
896
- this._url = url;
897
- }
898
- static is(value) {
899
- return value instanceof _BuildURI || !!value && typeof value.delParam === "function" && typeof value.setParam === "function";
900
- }
901
- static from(strURLUri, defaultProtocol = "file:") {
902
- return from((url) => new _BuildURI(url), strURLUri, defaultProtocol);
903
- }
904
- match(other) {
905
- return match(this.URI(), URI.from(other));
906
- }
907
- port(p) {
908
- this._url.port = p;
909
- return this;
910
- }
911
- hostname(h) {
912
- this._url.hostname = h;
913
- return this;
914
- }
915
- protocol(p) {
916
- if (!p.endsWith(":")) {
917
- p = `${p}:`;
918
- }
919
- this._url.protocol = p;
920
- return this;
921
- }
922
- pathname(p) {
923
- this._url.pathname = p;
924
- return this;
925
- }
926
- hash(h) {
927
- this._url.hash = h;
928
- return this;
929
- }
930
- // could pass a relative path or a full URL
931
- // if relative path, it will be appended to the current path
932
- resolve(p) {
933
- if (!p) {
934
- return this;
935
- }
936
- if (typeof p === "string") {
937
- if (!p.match(/^[a-zA-Z0-9]+:/)) {
938
- if (p.startsWith("/")) {
939
- this.pathname(p);
940
- return this;
941
- }
942
- return this.appendRelative(p);
943
- }
944
- }
945
- this._url = new MutableURL(p.toString());
946
- return this;
947
- }
948
- appendRelative(p) {
949
- const appendUrl = URI.from(p);
950
- const pathname = "./" + appendUrl.pathname;
951
- const basePath = this._url.pathname;
952
- this.pathname(relativePath(basePath, pathname));
953
- for (const [key, value] of appendUrl.getParams) {
954
- this.setParam(key, value);
955
- }
956
- return this;
957
- }
958
- cleanParams(...remove) {
959
- const keys = new Set(remove.flat());
960
- for (const key of Array.from(this._url.searchParams.keys())) {
961
- if (keys.size === 0 || keys.has(key)) {
962
- this._url.searchParams.delete(key);
963
- }
964
- }
965
- return this;
966
- }
967
- hashParams(val, mode = "reset") {
968
- let preset;
969
- switch (mode) {
970
- case "reset":
971
- this._url.hash = "";
972
- preset = {};
973
- break;
974
- case "merge":
975
- default:
976
- preset = Object.fromEntries(new URLSearchParams(this._url.hash.replace(/^#/, "")).entries());
977
- break;
978
- }
979
- const out = new URLSearchParams("");
980
- for (const [key, value] of Object.entries({ ...preset, ...val }).sort((a, b) => a[0].localeCompare(b[0]))) {
981
- switch (typeof value) {
982
- case "string":
983
- out.set(key, value);
984
- break;
985
- case "number":
986
- out.set(key, value.toString());
987
- break;
988
- case "boolean":
989
- out.set(key, value ? "true" : "false");
990
- break;
991
- default:
992
- if (value instanceof Date) {
993
- out.set(key, value.toISOString());
994
- } else {
995
- console.error(`unsupported type: ${typeof value} ignore key: ${key}`);
996
- }
997
- break;
998
- }
999
- }
1000
- this._url.hash = out.toString();
1001
- return this;
1002
- }
1003
- delParam(key) {
1004
- this._url.searchParams.delete(key);
1005
- return this;
1006
- }
1007
- defParam(key, str) {
1008
- if (!this._url.searchParams.has(key)) {
1009
- this._url.searchParams.set(key, str);
1010
- }
1011
- return this;
1012
- }
1013
- setParam(key, str) {
1014
- this._url.searchParams.set(key, str);
1015
- return this;
1016
- }
1017
- hasParam(key) {
1018
- return this._url.searchParams.has(key);
1019
- }
1020
- get getParams() {
1021
- return this._url.searchParams.entries();
1022
- }
1023
- getParam(key, def) {
1024
- const { key: k, def: d } = coerceKey(key, def);
1025
- let val = this._url.searchParams.get(k);
1026
- if (!falsy2undef(val) && d) {
1027
- val = d;
1028
- }
1029
- return falsy2undef(val);
1030
- }
1031
- getParamResult(key, msgFn) {
1032
- return getParamResult(key, this.getParam(key), msgFn);
1033
- }
1034
- getParamsResult(...keys) {
1035
- return getParamsResult(keys, this);
1036
- }
1037
- getHashParams(...keys) {
1038
- return getParamsResult(keys, resolveHash(this._url.hash));
1039
- }
1040
- toString() {
1041
- this._url.searchParams.sort();
1042
- return this._url.toString();
1043
- }
1044
- toJSON() {
1045
- return this.toString();
1046
- }
1047
- asURL() {
1048
- return this.URI().asURL();
1049
- }
1050
- asObj(...strips) {
1051
- return this.URI().asObj(...strips);
1052
- }
1053
- clone() {
1054
- return _BuildURI.from(this.toString());
1055
- }
1056
- URI() {
1057
- return URI.from(this._url);
1058
- }
1059
- };
1060
- function isCoerceURI(value) {
1061
- if (!value) {
1062
- return false;
1063
- }
1064
- if (isURL(value)) {
1065
- return true;
1066
- }
1067
- if (URI.is(value)) {
1068
- return true;
1069
- }
1070
- if (BuildURI.is(value)) {
1071
- return true;
1072
- }
1073
- if (typeof value === "string") {
1074
- return true;
1075
- }
1076
- return false;
1077
- }
1078
- var hasHostPartProtocols = /* @__PURE__ */ new Set(["http", "https", "ws", "wss"]);
1079
- var URI = class _URI {
1080
- static protocolHasHostpart(protocol) {
1081
- protocol = protocol.replace(/:$/, "");
1082
- hasHostPartProtocols.add(protocol);
1083
- return () => {
1084
- hasHostPartProtocols.delete(protocol);
1085
- };
1086
- }
1087
- match(other) {
1088
- return match(this, other);
1089
- }
1090
- // if no protocol is provided, default to file:
1091
- static merge(into, from2, defaultProtocol = "file:") {
1092
- const intoUrl = BuildURI.from(into, defaultProtocol);
1093
- const fromUrl = _URI.from(from2, defaultProtocol);
1094
- intoUrl.protocol(fromUrl.protocol);
1095
- const fPath = fromUrl.pathname;
1096
- if (!(fPath.length === 0 || fPath === "/" || fPath === "./")) {
1097
- intoUrl.pathname(fromUrl.pathname);
1098
- }
1099
- for (const [key, value] of fromUrl.getParams) {
1100
- intoUrl.setParam(key, value);
1101
- }
1102
- return intoUrl.URI();
1103
- }
1104
- static is(value) {
1105
- return value instanceof _URI || !!value && typeof value.asURL === "function" && typeof value.getParam === "function" && typeof value.hasParam === "function";
1106
- }
1107
- // if no protocol is provided, default to file:
1108
- static from(strURLUri, defaultProtocol = "file:") {
1109
- return from((url) => new _URI(url), strURLUri, defaultProtocol);
1110
- }
1111
- static fromResult(strURLUri, defaultProtocol = "file:") {
1112
- return exception2Result(() => from((url) => new _URI(url), strURLUri, defaultProtocol));
1113
- }
1114
- constructor(url) {
1115
- this._url = url.clone();
1116
- }
1117
- build() {
1118
- return BuildURI.from(this._url);
1119
- }
1120
- get hostname() {
1121
- return this._url.hostname;
1122
- }
1123
- get onlyHostAndSchema() {
1124
- return this.build().pathname("").cleanParams().hash("").toString();
1125
- }
1126
- get withoutHostAndSchema() {
1127
- return this._url.pathname + this._url.search + this._url.hash;
1128
- }
1129
- // get password(): string {
1130
- // return this._url.password;
1131
- // }
1132
- get port() {
1133
- return this._url.port;
1134
- }
1135
- get host() {
1136
- return this._url.host;
1137
- }
1138
- // get username(): string {
1139
- // return this._url.username;
1140
- // }
1141
- // get search(): string {
1142
- // return this._url.search;
1143
- // }
1144
- get protocol() {
1145
- return this._url.protocol;
1146
- }
1147
- get pathname() {
1148
- return this._url.pathname;
1149
- }
1150
- get hash() {
1151
- return this._url.hash;
1152
- }
1153
- // get host(): string {
1154
- // return this._url.host;
1155
- // }
1156
- get getParams() {
1157
- return this._url.searchParams.entries();
1158
- }
1159
- get getHashes() {
1160
- return new URLSearchParams(this._url.hash.slice("#".length)).entries();
1161
- }
1162
- hasParam(key) {
1163
- return this._url.searchParams.has(key);
1164
- }
1165
- getParam(key, def) {
1166
- const { key: k, def: d } = coerceKey(key, def);
1167
- let val = this._url.searchParams.get(k);
1168
- if (!falsy2undef(val) && d) {
1169
- val = d;
1170
- }
1171
- return falsy2undef(val);
1172
- }
1173
- getParamResult(key, msgFn) {
1174
- return getParamResult(key, this.getParam(key), msgFn);
1175
- }
1176
- getParamsResult(...keys) {
1177
- return getParamsResult(keys, this);
1178
- }
1179
- getHashParams(...keys) {
1180
- return getParamsResult(keys, resolveHash(this._url.hash));
1181
- }
1182
- clone() {
1183
- return new _URI(this._url);
1184
- }
1185
- asURL() {
1186
- return this._url.clone();
1187
- }
1188
- toString() {
1189
- return this._url.toString();
1190
- }
1191
- toJSON() {
1192
- return this.toString();
1193
- }
1194
- asObj(...strips) {
1195
- const pathURI = {
1196
- style: "path",
1197
- protocol: this.protocol,
1198
- pathname: this.pathname,
1199
- searchParams: Object.fromEntries(this.getParams)
1200
- };
1201
- if (hasHostPartProtocols.has(this.protocol.replace(/:$/, ""))) {
1202
- return stripper(strips, {
1203
- ...pathURI,
1204
- style: "host",
1205
- hostname: this.hostname,
1206
- port: this.port
1207
- });
1208
- }
1209
- return stripper(strips, pathURI);
1210
- }
1211
- };
1212
-
1213
- // src/future.ts
1214
- var _promise, _resolveFn, _rejectFn;
1215
- var Future = class {
1216
- constructor() {
1217
- __privateAdd(this, _promise);
1218
- __privateAdd(this, _resolveFn, () => {
1219
- throw new Error("This Promise is not working as expected.");
1220
- });
1221
- __privateAdd(this, _rejectFn, () => {
1222
- throw new Error("This Promise is not working as expected.");
1223
- });
1224
- __privateSet(this, _promise, new Promise((resolve, reject) => {
1225
- __privateSet(this, _resolveFn, resolve);
1226
- __privateSet(this, _rejectFn, reject);
1227
- }));
1228
- }
1229
- async asPromise() {
1230
- return __privateGet(this, _promise);
1231
- }
1232
- resolve(value) {
1233
- __privateGet(this, _resolveFn).call(this, value);
1234
- }
1235
- reject(reason) {
1236
- __privateGet(this, _rejectFn).call(this, reason);
1237
- }
1238
- };
1239
- _promise = new WeakMap();
1240
- _resolveFn = new WeakMap();
1241
- _rejectFn = new WeakMap();
1242
-
1243
- // src/lru-map-set.ts
1244
- var LRUSet = class {
1245
- constructor(param2 = {}) {
1246
- this._lruMap = new LRUMap(param2);
1247
- }
1248
- setParam(param2 = {}) {
1249
- this._lruMap.setParam(param2);
1250
- }
1251
- get size() {
1252
- return this._lruMap.size;
1253
- }
1254
- has(key) {
1255
- return this._lruMap.has(key);
1256
- }
1257
- add(key) {
1258
- this._lruMap.set(key, key);
1259
- }
1260
- delete(key) {
1261
- this._lruMap.delete(key);
1262
- }
1263
- clear() {
1264
- this._lruMap.clear();
1265
- }
1266
- forEach(callbackfn) {
1267
- this._lruMap.forEach((value) => callbackfn(value, value));
1268
- }
1269
- entries() {
1270
- return this._lruMap.entries();
1271
- }
1272
- };
1273
- var LRUMap = class {
1274
- constructor(c = {}) {
1275
- this._map = /* @__PURE__ */ new Map();
1276
- this.param = {
1277
- maxEntries: c.maxEntries || 100,
1278
- maxAge: c.maxAge || 0
1279
- };
1280
- }
1281
- touch(key) {
1282
- if (!this._map.has(key)) {
1283
- throw new Error(`key not found in cache: ${key}`);
1284
- }
1285
- const value = this._map.get(key);
1286
- this._map.delete(key);
1287
- this._map.set(key, value);
1288
- return value;
1289
- }
1290
- setParam(param2 = {}) {
1291
- if (typeof param2.maxEntries === "number") {
1292
- this.param.maxEntries = param2.maxEntries;
1293
- if (param2.maxEntries > 0 && this._map.size > param2.maxEntries) {
1294
- const toDelete = [];
1295
- let cacheSize = this._map.size;
1296
- for (const key of this._map.keys()) {
1297
- if (cacheSize > param2.maxEntries) {
1298
- toDelete.push(key);
1299
- cacheSize--;
1300
- } else {
1301
- break;
1302
- }
1303
- }
1304
- for (const key of toDelete) {
1305
- this._map.delete(key);
1306
- }
1307
- }
1308
- }
1309
- }
1310
- has(key) {
1311
- return this._map.has(key);
1312
- }
1313
- get size() {
1314
- return this._map.size;
1315
- }
1316
- async getSet(key, createFN) {
1317
- const val = this.get(key);
1318
- if (val) {
1319
- return val;
1320
- } else {
1321
- const val2 = await createFN(key);
1322
- this.set(key, val2);
1323
- return val2;
1324
- }
1325
- }
1326
- get(key) {
1327
- if (this._map.has(key)) {
1328
- return this.touch(key);
1329
- }
1330
- return this._map.get(key);
1331
- }
1332
- set(key, value) {
1333
- this._map.delete(key);
1334
- if (this.param.maxEntries > 0 && this._map.size >= this.param.maxEntries) {
1335
- this._map.delete(this._map.keys().next().value);
1336
- this._map.set(key, value);
1337
- } else {
1338
- this._map.set(key, value);
1339
- }
1340
- }
1341
- delete(key) {
1342
- this._map.delete(key);
1343
- }
1344
- clear() {
1345
- this._map.clear();
1346
- }
1347
- forEach(callbackfn) {
1348
- this._map.forEach(callbackfn);
1349
- }
1350
- entries() {
1351
- return this._map.entries();
1352
- }
1353
- // *entries(): IterableIterator<[T, K]> {
1354
- // for (const x of this._cache.entries()) {
1355
- // yield x;
1356
- // }
1357
- // }
1358
- // getLeastRecent(): K {
1359
- // return Array.from(this.cache)[0];
1360
- // }
1361
- // getMostRecent(): K {
1362
- // return Array.from(this.cache)[this.cache.size - 1];
1363
- // }
1364
- };
1365
-
1366
- // src/resolve-once.ts
1367
- var ResolveSeq = class {
1368
- constructor(ctx) {
1369
- this._flushWaiting = [];
1370
- this._seqFutures = [];
1371
- this.ctx = ctx;
1372
- }
1373
- reset() {
1374
- }
1375
- flush() {
1376
- var _a;
1377
- if (this._seqFutures.length > 0) {
1378
- const waitForFlush = new Future();
1379
- (_a = this._flushWaiting) == null ? void 0 : _a.push(waitForFlush);
1380
- return waitForFlush.asPromise();
1381
- }
1382
- return Promise.resolve();
1383
- }
1384
- _step(item) {
1385
- var _a;
1386
- if (!item) {
1387
- this._flushWaiting.forEach((f) => f.resolve());
1388
- (_a = this._flushWaiting) == null ? void 0 : _a.splice(0, this._flushWaiting.length);
1389
- return Promise.resolve();
1390
- }
1391
- item.fn(this.ctx).then((value) => item.future.resolve(value)).catch((e) => item.future.reject(e)).finally(() => {
1392
- this._seqFutures.shift();
1393
- void this._step(this._seqFutures[0]);
1394
- });
1395
- return Promise.resolve();
1396
- }
1397
- async add(fn, id) {
1398
- const future = new Future();
1399
- this._seqFutures.push({ future, fn, id });
1400
- if (this._seqFutures.length === 1) {
1401
- void this._step(this._seqFutures[0]);
1402
- }
1403
- return future.asPromise();
1404
- }
1405
- };
1406
- var ResolveOnce = class {
1407
- constructor(ctx) {
1408
- this._onceDone = false;
1409
- this._onceFutures = [];
1410
- this._onceOk = false;
1411
- this._isPromise = false;
1412
- this.ctx = ctx;
1413
- }
1414
- get ready() {
1415
- return this._onceDone;
1416
- }
1417
- reset() {
1418
- this._onceDone = false;
1419
- this._onceOk = false;
1420
- this._onceValue = void 0;
1421
- this._onceError = void 0;
1422
- if (this._inProgress) {
1423
- const idx = this._onceFutures.findIndex((f) => f === this._inProgress);
1424
- if (idx >= 0) {
1425
- this._onceFutures.push(...this._onceFutures.splice(2).slice(1));
1426
- }
1427
- } else {
1428
- this._onceFutures.length = 0;
1429
- }
1430
- }
1431
- // T extends Option<infer U> ? U : T
1432
- once(fn) {
1433
- if (this._onceDone) {
1434
- if (this._onceError) {
1435
- if (this._isPromise) {
1436
- return Promise.reject(this._onceError);
1437
- } else {
1438
- throw this._onceError;
1439
- }
1440
- }
1441
- if (this._onceOk) {
1442
- if (this._isPromise) {
1443
- return Promise.resolve(this._onceValue);
1444
- } else {
1445
- return this._onceValue;
1446
- }
1447
- }
1448
- throw new Error("ResolveOnce.once impossible");
1449
- }
1450
- const future = new Future();
1451
- this._onceFutures.push(future);
1452
- if (this._onceFutures.length === 1) {
1453
- const okFn = (value) => {
1454
- this._onceValue = value;
1455
- this._onceOk = true;
1456
- this._onceDone = true;
1457
- if (this._isPromise) {
1458
- this._onceFutures.forEach((f) => f.resolve(this._onceValue));
1459
- }
1460
- this._onceFutures.length = 0;
1461
- };
1462
- const catchFn = (e) => {
1463
- this._onceError = e;
1464
- this._onceOk = false;
1465
- this._onceValue = void 0;
1466
- this._onceDone = true;
1467
- if (this._isPromise) {
1468
- this._onceFutures.forEach((f) => f.reject(this._onceError));
1469
- }
1470
- this._onceFutures.length = 0;
1471
- };
1472
- this._inProgress = future;
1473
- try {
1474
- const ret = fn(this.ctx);
1475
- if (typeof ret.then === "function") {
1476
- this._isPromise = true;
1477
- ret.then(okFn).catch(catchFn).finally(() => {
1478
- this._inProgress = void 0;
1479
- });
1480
- } else {
1481
- okFn(ret);
1482
- }
1483
- } catch (e) {
1484
- catchFn(e);
1485
- }
1486
- if (!this._isPromise) {
1487
- this._inProgress = void 0;
1488
- }
1489
- }
1490
- if (this._isPromise) {
1491
- return future.asPromise();
1492
- } else {
1493
- return this.once(fn);
1494
- }
1495
- }
1496
- };
1497
- var Keyed = class {
1498
- constructor(factory, params) {
1499
- var _a;
1500
- this.factory = factory;
1501
- this._map = new LRUMap((_a = params == null ? void 0 : params.lru) != null ? _a : { maxEntries: -1 });
1502
- }
1503
- setParam(params) {
1504
- this._map.setParam(params.lru);
1505
- }
1506
- async asyncGet(key) {
1507
- return this.get(await key());
1508
- }
1509
- get(key) {
1510
- if (typeof key === "function") {
1511
- key = key();
1512
- }
1513
- let keyed = this._map.get(key);
1514
- if (!keyed) {
1515
- keyed = this.factory(key);
1516
- this._map.set(key, keyed);
1517
- }
1518
- return keyed;
1519
- }
1520
- unget(key) {
1521
- const keyed = this._map.get(key);
1522
- keyed == null ? void 0 : keyed.reset();
1523
- this._map.delete(key);
1524
- }
1525
- reset() {
1526
- this._map.forEach((keyed) => keyed.reset());
1527
- this._map.clear();
1528
- }
1529
- };
1530
- var KeyedResolvOnce = class extends Keyed {
1531
- constructor(kp = {}) {
1532
- super((key) => new ResolveOnce(key), kp);
1533
- }
1534
- /**
1535
- *
1536
- * @returns The values of the resolved keys
1537
- */
1538
- values() {
1539
- return Array.from(this._map.entries()).filter(([_, v]) => v._onceDone).map(([k, v]) => {
1540
- if (v._onceDone) {
1541
- if (v._onceError) {
1542
- return {
1543
- key: k,
1544
- value: Result.Err(v._onceError)
1545
- };
1546
- }
1547
- return {
1548
- key: k,
1549
- value: Result.Ok(v._onceValue)
1550
- };
1551
- }
1552
- throw new Error("KeyedResolvOnce.values impossible");
1553
- });
1554
- }
1555
- };
1556
- var KeyedResolvSeq = class extends Keyed {
1557
- constructor(kp = {}) {
1558
- super((key) => new ResolveSeq(key), kp);
1559
- }
1560
- };
1561
-
1562
- // src/utils/coerce-uint8.ts
1563
- var globalBuffer = globalThis;
1564
- function coerceIntoUint8(raw) {
1565
- if (raw instanceof ArrayBuffer) {
1566
- return Result.Ok(new Uint8Array(raw));
1567
- }
1568
- if (ArrayBuffer.isView(raw)) {
1569
- return Result.Ok(new Uint8Array(raw.buffer, raw.byteOffset, raw.byteLength));
1570
- }
1571
- if (raw instanceof Blob) {
1572
- return Result.Err("Blob not supported");
1573
- }
1574
- if (globalBuffer.Buffer && globalBuffer.Buffer.isBuffer(raw)) {
1575
- return Result.Ok(new Uint8Array(raw.buffer, raw.byteOffset, raw.byteLength));
1576
- }
1577
- if (raw instanceof Uint8Array) {
1578
- return Result.Ok(raw);
1579
- }
1580
- if (Result.Is(raw)) {
1581
- if (raw.isErr()) {
1582
- return Result.Err(raw);
1583
- }
1584
- return coerceIntoUint8(raw.unwrap());
1585
- }
1586
- return Result.Err("Not a Uint8Array");
1587
- }
1588
- async function asyncCoerceIntoUint8(raw) {
1589
- let resolved = await raw;
1590
- if (resolved instanceof Blob) {
1591
- resolved = await resolved.arrayBuffer();
1592
- }
1593
- return coerceIntoUint8(resolved);
1594
- }
1595
-
1596
- // src/txt-en-decoder.ts
1597
- var TxtOps = class {
1598
- constructor() {
1599
- this.encoder = new TextEncoder();
1600
- this.decoder = new TextDecoder();
1601
- }
1602
- encode(str) {
1603
- return this.encoder.encode(str);
1604
- }
1605
- decode(data) {
1606
- if (Result.Is(data)) {
1607
- if (data.isErr()) {
1608
- throw data.Err();
1609
- }
1610
- const unwrapped = data.unwrap();
1611
- if (typeof unwrapped === "string") {
1612
- return this.decode(unwrapped);
1613
- }
1614
- }
1615
- if (typeof data === "string") {
1616
- return data;
1617
- }
1618
- return this.decoder.decode(coerceIntoUint8(data).Ok());
1619
- }
1620
- async asyncDecode(data) {
1621
- let resolved = await data;
1622
- if (resolved instanceof Blob) {
1623
- resolved = await resolved.arrayBuffer();
1624
- }
1625
- return this.decode(resolved);
1626
- }
1627
- };
1628
- var txtEnDecoder = new ResolveOnce();
1629
- function TxtEnDecoderSingleton() {
1630
- return txtEnDecoder.once(() => new TxtOps());
1631
- }
1632
-
1633
- // src/option.ts
1634
- var Option = class _Option {
1635
- static Some(t) {
1636
- return new Some(t);
1637
- }
1638
- static None() {
1639
- return new None();
1640
- }
1641
- static Is(t) {
1642
- return t instanceof _Option;
1643
- }
1644
- static From(t) {
1645
- if (!t) {
1646
- return new None();
1647
- }
1648
- return new Some(t);
1649
- }
1650
- IsNone() {
1651
- return this.is_none();
1652
- }
1653
- IsSome() {
1654
- return this.is_some();
1655
- }
1656
- Unwrap() {
1657
- return this.unwrap();
1658
- }
1659
- };
1660
- var Some = class extends Option {
1661
- constructor(_t) {
1662
- super();
1663
- this._t = _t;
1664
- }
1665
- is_none() {
1666
- return false;
1667
- }
1668
- is_some() {
1669
- return true;
1670
- }
1671
- unwrap() {
1672
- return this._t;
1673
- }
1674
- };
1675
- var None = class extends Option {
1676
- is_none() {
1677
- return true;
1678
- }
1679
- is_some() {
1680
- return false;
1681
- }
1682
- unwrap() {
1683
- throw new Error("None.unwrap");
1684
- }
1685
- };
1686
-
1687
- // src/log-level-impl.ts
1688
- var LevelHandlerImpl = class {
1689
- constructor() {
1690
- this._globalLevels = /* @__PURE__ */ new Set([Level.INFO, Level.ERROR, Level.WARN]);
1691
- this._modules = /* @__PURE__ */ new Map();
1692
- this.ignoreAttr = Option.Some(/^_/);
1693
- this.isStackExposed = false;
1694
- }
1695
- enableLevel(level, ...modules) {
1696
- if (modules.length == 0) {
1697
- this._globalLevels.add(level);
1698
- return;
1699
- }
1700
- this.forModules(
1701
- level,
1702
- (p) => {
1703
- this._modules.set(p, /* @__PURE__ */ new Set([...this._globalLevels, level]));
1704
- },
1705
- ...modules
1706
- );
1707
- }
1708
- disableLevel(level, ...modules) {
1709
- if (modules.length == 0) {
1710
- this._globalLevels.delete(level);
1711
- return;
1712
- }
1713
- this.forModules(
1714
- level,
1715
- (p) => {
1716
- this._modules.delete(p);
1717
- },
1718
- ...modules
1719
- );
1720
- }
1721
- setExposeStack(enable) {
1722
- this.isStackExposed = !!enable;
1723
- }
1724
- setIgnoreAttr(re) {
1725
- this.ignoreAttr = Option.From(re);
1726
- }
1727
- forModules(level, fnAction, ...modules) {
1728
- for (const m of modules.flat()) {
1729
- if (typeof m !== "string") {
1730
- continue;
1731
- }
1732
- const parts = m.split(",").map((s) => s.trim()).filter((s) => s.length);
1733
- for (const p of parts) {
1734
- fnAction(p);
1735
- }
1736
- }
1737
- }
1738
- setDebug(...modules) {
1739
- this.forModules(
1740
- Level.DEBUG,
1741
- (p) => {
1742
- this._modules.set(p, /* @__PURE__ */ new Set([...this._globalLevels, Level.DEBUG]));
1743
- },
1744
- ...modules
1745
- );
1746
- }
1747
- isEnabled(ilevel, module2) {
1748
- const level = ilevel;
1749
- if (typeof module2 === "string") {
1750
- const levels = this._modules.get(module2);
1751
- if (levels && levels.has(level)) {
1752
- return true;
1753
- }
1754
- }
1755
- const wlevel = this._modules.get("*");
1756
- if (wlevel && typeof level === "string") {
1757
- if (wlevel.has(level)) {
1758
- return true;
1759
- }
1760
- }
1761
- if (typeof level !== "string") {
1762
- return true;
1763
- }
1764
- return this._globalLevels.has(level);
1765
- }
1766
- };
1767
- var levelSingleton = new LevelHandlerImpl();
1768
- function LevelHandlerSingleton() {
1769
- return levelSingleton;
1770
- }
1771
-
1772
- // src/runtime.ts
1773
- function isSet(value, ref = globalThis) {
1774
- const [head, ...tail] = value.split(".");
1775
- if (["object", "function"].includes(typeof ref) && ref && ["object", "function"].includes(typeof ref[head]) && ref[head]) {
1776
- if (tail.length <= 1) {
1777
- return true;
1778
- }
1779
- return isSet(tail.join("."), ref[head]);
1780
- }
1781
- return false;
1782
- }
1783
- function runtimeFn() {
1784
- const gt = globalThis;
1785
- let isReactNative = (
1786
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1787
- isSet("navigator.product") && typeof gt["navigator"] === "object" && gt["navigator"]["product"] === "ReactNative"
1788
- );
1789
- let isNodeIsh = false;
1790
- if (!isSet("Deno")) {
1791
- isNodeIsh = isSet("process.versions.node") && !isReactNative;
1792
- }
1793
- let isDeno = isSet("Deno");
1794
- const isCFWorker = isSet("caches.default") && isSet("WebSocketPair");
1795
- if (isCFWorker) {
1796
- isDeno = false;
1797
- isNodeIsh = false;
1798
- isReactNative = false;
1799
- }
1800
- return {
1801
- isNodeIsh,
1802
- isBrowser: !(isNodeIsh || isDeno || isCFWorker || isReactNative),
1803
- isDeno,
1804
- isReactNative,
1805
- isCFWorker
1806
- };
1807
- }
1808
-
1809
- // src/sys-abstraction.ts
1810
- var TimeMode = {
1811
- REAL: "real",
1812
- CONST: "const",
1813
- STEP: "step"
1814
- };
1815
- var RandomMode = {
1816
- CONST: "const",
1817
- STEP: "step",
1818
- RANDOM: "random"
1819
- };
1820
- var IDMode = {
1821
- UUID: "uuid",
1822
- CONST: "const",
1823
- STEP: "step"
1824
- };
1825
- function String2TimeMode(s) {
1826
- switch (s == null ? void 0 : s.toLowerCase()) {
1827
- case "real":
1828
- return TimeMode.REAL;
1829
- case "const":
1830
- return TimeMode.CONST;
1831
- case "step":
1832
- return TimeMode.STEP;
1833
- default:
1834
- return TimeMode.REAL;
1835
- }
1836
- }
1837
-
1838
- // src/time.ts
1839
- var Time = class {
1840
- TimeSince(start) {
1841
- const now = this.Now();
1842
- return now.getTime() - start.getTime();
1843
- }
1844
- };
1845
- var TimeUnits = {
1846
- Microsecond: 1,
1847
- Second: 1e3 * 1,
1848
- //Microsecond,
1849
- Minute: 60 * 1e3 * 1,
1850
- //Second,
1851
- Hour: 60 * 60 * 1e3 * 1
1852
- // Minute,
1853
- };
1854
-
1855
- // src/deno/deno-env-actions.ts
1856
- var once = new ResolveOnce();
1857
- var _deno;
1858
- var _DenoEnvActions = class _DenoEnvActions {
1859
- constructor(opts) {
1860
- __privateAdd(this, _deno, globalThis);
1861
- this.opts = opts;
1862
- }
1863
- static new(opts) {
1864
- return once.once(() => new _DenoEnvActions(opts));
1865
- }
1866
- get _env() {
1867
- return __privateGet(this, _deno).Deno.env;
1868
- }
1869
- register(env) {
1870
- for (const key of env.keys()) {
1871
- this._env.set(key, env.get(key) || "");
1872
- }
1873
- return env;
1874
- }
1875
- active() {
1876
- return runtimeFn().isDeno;
1877
- }
1878
- keys() {
1879
- return Object.keys(this._env.toObject());
1880
- }
1881
- get(key) {
1882
- return this._env.get(key);
1883
- }
1884
- set(key, value) {
1885
- if (value) {
1886
- this._env.set(key, value);
1887
- }
1888
- }
1889
- delete(key) {
1890
- this._env.delete(key);
1891
- }
1892
- };
1893
- _deno = new WeakMap();
1894
- var DenoEnvActions = _DenoEnvActions;
1895
-
1896
- // src/node/node-env-actions.ts
1897
- var once2 = new ResolveOnce();
1898
- var _node;
1899
- var _NodeEnvActions = class _NodeEnvActions {
1900
- constructor(opts) {
1901
- __privateAdd(this, _node, globalThis);
1902
- this._env = this.active() ? __privateGet(this, _node).process.env : {};
1903
- this.opts = opts;
1904
- }
1905
- static new(opts) {
1906
- return once2.once(() => new _NodeEnvActions(opts));
1907
- }
1908
- register(env) {
1909
- for (const key of env.keys()) {
1910
- this._env[key] = env.get(key) || "";
1911
- }
1912
- return env;
1913
- }
1914
- active() {
1915
- return runtimeFn().isNodeIsh;
1916
- }
1917
- keys() {
1918
- return Object.keys(this._env);
1919
- }
1920
- get(key) {
1921
- return this._env[key];
1922
- }
1923
- set(key, value) {
1924
- if (value) {
1925
- this._env[key] = value;
1926
- }
1927
- }
1928
- delete(key) {
1929
- delete this._env[key];
1930
- }
1931
- };
1932
- _node = new WeakMap();
1933
- var NodeEnvActions = _NodeEnvActions;
1934
-
1935
- // src/web/web-env-actions.ts
1936
- var once3 = new ResolveOnce();
1937
- var BrowserEnvActions = class _BrowserEnvActions {
1938
- constructor(opts) {
1939
- this.env = /* @__PURE__ */ new Map();
1940
- this.opts = opts;
1941
- }
1942
- static new(opts) {
1943
- return once3.once(() => new _BrowserEnvActions(opts));
1944
- }
1945
- get(key) {
1946
- return this.env.get(key);
1947
- }
1948
- set(key, value) {
1949
- if (value) {
1950
- this.env.set(key, value);
1951
- }
1952
- }
1953
- delete(key) {
1954
- this.env.delete(key);
1955
- }
1956
- keys() {
1957
- return Array.from(this.env.keys());
1958
- }
1959
- active() {
1960
- return true;
1961
- }
1962
- register(env) {
1963
- const sym = Symbol.for(this.opts.symbol || "CP_ENV");
1964
- const browser = globalThis;
1965
- browser[sym] = env;
1966
- return env;
1967
- }
1968
- };
1969
-
1970
- // src/cf/cf-env-actions.ts
1971
- var once4 = new ResolveOnce();
1972
- var CFEnvActions = class _CFEnvActions {
1973
- constructor(env) {
1974
- this.injectOnRegister = {};
1975
- this.cfEnv = new Map(Object.entries(env.presetEnv || {}));
1976
- }
1977
- static new(opts) {
1978
- return once4.once(() => new _CFEnvActions(opts));
1979
- }
1980
- static inject(o) {
1981
- const env = _CFEnvActions.new({});
1982
- for (const key in o) {
1983
- const value = o[key];
1984
- if (typeof value === "string") {
1985
- if (env.env) {
1986
- env.env.set(key, value);
1987
- } else {
1988
- env.injectOnRegister[key] = value;
1989
- }
1990
- }
1991
- }
1992
- }
1993
- active() {
1994
- return runtimeFn().isCFWorker;
1995
- }
1996
- register(env) {
1997
- this.env = env;
1998
- for (const key in this.injectOnRegister) {
1999
- env.set(key, this.injectOnRegister[key]);
2000
- }
2001
- return env;
2002
- }
2003
- get(key) {
2004
- return this.cfEnv.get(key);
2005
- }
2006
- set(key, value) {
2007
- if (value) {
2008
- this.cfEnv.set(key, value);
2009
- }
2010
- }
2011
- delete(key) {
2012
- this.cfEnv.delete(key);
2013
- }
2014
- keys() {
2015
- return Array.from(this.cfEnv.keys());
2016
- }
2017
- };
2018
-
2019
- // src/sys-env.ts
2020
- var envActions = [
2021
- { id: "cf", fn: (opts) => CFEnvActions.new(opts) },
2022
- { id: "node", fn: (opts) => NodeEnvActions.new(opts) },
2023
- { id: "deno", fn: (opts) => DenoEnvActions.new(opts) },
2024
- { id: "browser", fn: (opts) => BrowserEnvActions.new(opts) }
2025
- ];
2026
- function registerEnvAction(fn) {
2027
- const id = `id-${Math.random()}`;
2028
- envActions.unshift({ id, fn });
2029
- _envFactories.unget(id);
2030
- return () => {
2031
- const index = envActions.findIndex((i) => i.id === id);
2032
- if (index >= 0) {
2033
- envActions.splice(index, 1);
2034
- }
2035
- };
2036
- }
2037
- var _envFactories = new KeyedResolvOnce();
2038
- function envFactory(opts = {}) {
2039
- const found = envActions.find((fi) => fi.fn(opts).active());
2040
- if (!found) {
2041
- throw new Error("SysContainer:envFactory: no env available");
2042
- }
2043
- return _envFactories.get(found.id).once(() => {
2044
- const action = found.fn(opts);
2045
- const ret = new EnvImpl(action, opts);
2046
- action.register(ret);
2047
- return ret;
2048
- });
2049
- }
2050
- function isIterable(obj) {
2051
- if (obj == null) {
2052
- return false;
2053
- }
2054
- return typeof obj[Symbol.iterator] === "function";
2055
- }
2056
- var EnvImpl = class {
2057
- constructor(map, opts = {}) {
2058
- this._onSet = [];
2059
- this._map = map;
2060
- this._updatePresets(opts.presetEnv);
2061
- }
2062
- gets(...kparams) {
2063
- return getParamsResult(kparams, {
2064
- getParam: (k) => this.get(k)
2065
- });
2066
- }
2067
- sets(...keys) {
2068
- keys.forEach((key) => {
2069
- if (Array.isArray(key)) {
2070
- if (key.length === 2) {
2071
- const [k, v] = key;
2072
- if (typeof k === "string" && typeof v === "string") {
2073
- this.set(k, v);
2074
- return;
2075
- }
2076
- }
2077
- for (const item of key) {
2078
- if (Array.isArray(item)) {
2079
- if (item.length === 2) {
2080
- const [k, v] = item;
2081
- if (typeof k === "string" && typeof v === "string") {
2082
- this.set(k, v);
2083
- }
2084
- }
2085
- }
2086
- }
2087
- } else {
2088
- if (isIterable(key)) {
2089
- for (const [k, v] of key) {
2090
- if (typeof k === "string" && typeof v === "string") {
2091
- this.set(k, v);
2092
- }
2093
- }
2094
- } else {
2095
- const rKey = key;
2096
- for (const k in rKey) {
2097
- const v = rKey[k];
2098
- if (typeof k === "string" && typeof v === "string") {
2099
- this.set(k, v);
2100
- }
2101
- }
2102
- }
2103
- }
2104
- });
2105
- }
2106
- _updatePresets(presetEnv) {
2107
- if (!presetEnv) {
2108
- return;
2109
- }
2110
- for (const [key, value] of presetEnv) {
2111
- this._map.set(key, value);
2112
- }
2113
- }
2114
- _applyOnSet(onSet, key, value) {
2115
- onSet.forEach((item) => {
2116
- let keys = [];
2117
- if (key) {
2118
- keys = [key];
2119
- } else {
2120
- keys = this._map.keys();
2121
- }
2122
- keys.filter((k) => {
2123
- if (item.filter.size === 0) {
2124
- return true;
2125
- }
2126
- if (item.filter.has(k)) {
2127
- return true;
2128
- }
2129
- return false;
2130
- }).forEach((k) => {
2131
- let v;
2132
- if (!key && !value) {
2133
- v = this._map.get(k);
2134
- } else if (key && !value) {
2135
- v = void 0;
2136
- } else {
2137
- v = value;
2138
- }
2139
- item.fn(k, v);
2140
- });
2141
- });
2142
- }
2143
- keys() {
2144
- return this._map.keys();
2145
- }
2146
- // filter is not set all sets passed
2147
- onSet(fn, ...filter) {
2148
- const item = { filter: new Set(filter), fn };
2149
- this._onSet.push(item);
2150
- this._applyOnSet([item]);
2151
- }
2152
- get(key) {
2153
- return this._map.get(key);
2154
- }
2155
- set(key, value) {
2156
- if (!value) {
2157
- return;
2158
- }
2159
- this._map.set(key, value);
2160
- this._applyOnSet(this._onSet, key, value);
2161
- }
2162
- delete(key) {
2163
- this._map.delete(key);
2164
- this._applyOnSet(this._onSet, key);
2165
- }
2166
- };
2167
-
2168
- // src/utils/console-write-stream.ts
2169
- var ConsoleWriterStreamDefaultWriter = class {
2170
- constructor(stream) {
2171
- this.stream = stream;
2172
- this.desiredSize = null;
2173
- this.decoder = new TextDecoder();
2174
- this._stream = stream;
2175
- this.ready = Promise.resolve(void 0);
2176
- this.closed = Promise.resolve(void 0);
2177
- }
2178
- // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
2179
- abort(reason) {
2180
- throw new Error("Method not implemented.");
2181
- }
2182
- async close() {
2183
- }
2184
- releaseLock() {
2185
- this._stream.locked = false;
2186
- this.ready = Promise.resolve(void 0);
2187
- this.closed = Promise.resolve(void 0);
2188
- }
2189
- write(chunk) {
2190
- let strObj = this.decoder.decode(chunk).trimEnd();
2191
- let output = "log";
2192
- try {
2193
- strObj = JSON.parse(strObj);
2194
- output = strObj.level;
2195
- } catch (e) {
2196
- }
2197
- switch (output) {
2198
- case "error":
2199
- console.error(strObj);
2200
- break;
2201
- case "warn":
2202
- console.warn(strObj);
2203
- break;
2204
- default:
2205
- console.log(strObj);
2206
- }
2207
- return Promise.resolve();
2208
- }
2209
- };
2210
- var ConsoleWriterStream = class {
2211
- constructor() {
2212
- this.locked = false;
2213
- }
2214
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
2215
- abort(reason) {
2216
- throw new Error("Method not implemented.");
2217
- }
2218
- close() {
2219
- return Promise.resolve();
2220
- }
2221
- getWriter() {
2222
- if (this.locked) {
2223
- throw new Error("Stream is locked");
2224
- }
2225
- this.locked = true;
2226
- if (!this._writer) {
2227
- this._writer = new ConsoleWriterStreamDefaultWriter(this);
2228
- }
2229
- return this._writer;
2230
- }
2231
- };
2232
-
2233
- // src/web/web-basic-sys-abstraction.ts
2234
- var WebSystemService = class {
2235
- constructor(ende) {
2236
- this._txtEnDe = ende;
2237
- }
2238
- Env() {
2239
- return envFactory();
2240
- }
2241
- Args() {
2242
- throw new Error("Args-Method not implemented.");
2243
- }
2244
- Stdout() {
2245
- return new ConsoleWriterStream();
2246
- }
2247
- Stderr() {
2248
- const decoder = this._txtEnDe;
2249
- return new WritableStream({
2250
- write(chunk) {
2251
- return new Promise((resolve) => {
2252
- const decoded = decoder.decode(chunk);
2253
- console.error(decoded.trimEnd());
2254
- resolve();
2255
- });
2256
- }
2257
- });
2258
- }
2259
- };
2260
- var baseSysAbstraction = new ResolveOnce();
2261
- function WebBasicSysAbstraction(param2) {
2262
- var _a;
2263
- const my = baseSysAbstraction.once(() => {
2264
- return new BaseBasicSysAbstraction({
2265
- TxtEnDecoder: (param2 == null ? void 0 : param2.TxtEnDecoder) || TxtEnDecoderSingleton()
2266
- });
2267
- });
2268
- return new WrapperBasicSysAbstraction(my, {
2269
- basicRuntimeService: new WebSystemService((_a = param2 == null ? void 0 : param2.TxtEnDecoder) != null ? _a : my._txtEnDe),
2270
- ...param2
2271
- });
2272
- }
2273
-
2274
- // src/cf/cf-basic-sys-abstraction.ts
2275
- var CFRuntimeService = class {
2276
- constructor(ende) {
2277
- this._txtEnDe = ende;
2278
- }
2279
- Env() {
2280
- return envFactory();
2281
- }
2282
- Args() {
2283
- throw new Error("Args-Method not implemented.");
2284
- }
2285
- Stdout() {
2286
- return CFWriteableStream((chunk) => {
2287
- const decoded = this._txtEnDe.decode(chunk);
2288
- console.log(decoded.trimEnd());
2289
- return Promise.resolve();
2290
- });
2291
- }
2292
- Stderr() {
2293
- return CFWriteableStream((chunk) => {
2294
- const decoded = this._txtEnDe.decode(chunk);
2295
- console.error(decoded.trimEnd());
2296
- return Promise.resolve();
2297
- });
2298
- }
2299
- };
2300
- function consumeReadableStream(reader, writeFn) {
2301
- reader.read().then(({ done, value }) => {
2302
- if (done) {
2303
- return;
2304
- }
2305
- writeFn(value).then(() => {
2306
- consumeReadableStream(reader, writeFn);
2307
- }).catch((e) => {
2308
- console.error("consumeReadableStream:writeFn", e);
2309
- });
2310
- }).catch((e) => {
2311
- console.error("consumeReadableStream:read", e);
2312
- });
2313
- }
2314
- function CFWriteableStream(writeFn) {
2315
- const ts = new TransformStream();
2316
- consumeReadableStream(ts.readable.getReader(), writeFn);
2317
- return ts.writable;
2318
- }
2319
- var baseSysAbstraction2 = new ResolveOnce();
2320
- function CFBasicSysAbstraction(param2) {
2321
- var _a;
2322
- const my = baseSysAbstraction2.once(() => {
2323
- return new BaseBasicSysAbstraction({
2324
- TxtEnDecoder: (param2 == null ? void 0 : param2.TxtEnDecoder) || TxtEnDecoderSingleton()
2325
- });
2326
- });
2327
- return new WrapperBasicSysAbstraction(my, {
2328
- basicRuntimeService: new CFRuntimeService((_a = param2 == null ? void 0 : param2.TxtEnDecoder) != null ? _a : my._txtEnDe),
2329
- ...param2
2330
- });
2331
- }
2332
-
2333
- // src/deno/deno-basic-sys-abstraction.ts
2334
- var DenoRuntimeService = class {
2335
- constructor(ende) {
2336
- this._txtEnDe = ende;
2337
- }
2338
- Env() {
2339
- return envFactory();
2340
- }
2341
- Args() {
2342
- return globalThis.Deno.args;
2343
- }
2344
- Stdout() {
2345
- return globalThis.Deno.stdout.writable;
2346
- }
2347
- Stderr() {
2348
- return globalThis.Deno.stderr.writable;
2349
- }
2350
- };
2351
- var baseSysAbstraction3 = new ResolveOnce();
2352
- function DenoBasicSysAbstraction(param2) {
2353
- var _a;
2354
- const my = baseSysAbstraction3.once(() => {
2355
- return new BaseBasicSysAbstraction({
2356
- TxtEnDecoder: (param2 == null ? void 0 : param2.TxtEnDecoder) || TxtEnDecoderSingleton()
2357
- });
2358
- });
2359
- return new WrapperBasicSysAbstraction(my, {
2360
- basicRuntimeService: new DenoRuntimeService((_a = param2 == null ? void 0 : param2.TxtEnDecoder) != null ? _a : my._txtEnDe),
2361
- ...param2
2362
- });
2363
- }
2364
-
2365
- // src/node/node-basic-sys-abstraction.ts
2366
- var NodeRuntimeService = class {
2367
- constructor(ende) {
2368
- this._txtEnDe = ende;
2369
- this._gthis = globalThis;
2370
- }
2371
- Env() {
2372
- return envFactory();
2373
- }
2374
- Args() {
2375
- return this._gthis.process.argv;
2376
- }
2377
- Stdout() {
2378
- return new WritableStream({
2379
- write: (chunk) => {
2380
- this._gthis.process.stdout.write(chunk);
2381
- }
2382
- });
2383
- }
2384
- Stderr() {
2385
- return new WritableStream({
2386
- write: (chunk) => {
2387
- this._gthis.process.stderr.write(chunk);
2388
- }
2389
- });
2390
- }
2391
- };
2392
- var baseSysAbstraction4 = new ResolveOnce();
2393
- function NodeBasicSysAbstraction(param2) {
2394
- var _a;
2395
- const my = baseSysAbstraction4.once(() => {
2396
- return new BaseBasicSysAbstraction({
2397
- TxtEnDecoder: (param2 == null ? void 0 : param2.TxtEnDecoder) || TxtEnDecoderSingleton()
2398
- });
2399
- });
2400
- return new WrapperBasicSysAbstraction(my, {
2401
- basicRuntimeService: new NodeRuntimeService((_a = param2 == null ? void 0 : param2.TxtEnDecoder) != null ? _a : my._txtEnDe),
2402
- ...param2
2403
- });
2404
- }
2405
-
2406
- // src/base-sys-abstraction.ts
2407
- var SysTime = class extends Time {
2408
- Now() {
2409
- return /* @__PURE__ */ new Date();
2410
- }
2411
- Sleep(duration) {
2412
- return new Promise((resolve) => {
2413
- setTimeout(() => {
2414
- resolve();
2415
- }, duration);
2416
- });
2417
- }
2418
- };
2419
- var ConstTime = class extends Time {
2420
- Now() {
2421
- return new Date(2021, 1, 1, 0, 0, 0, 0);
2422
- }
2423
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2424
- Sleep(duration) {
2425
- return Promise.resolve();
2426
- }
2427
- };
2428
- var StepTime = class extends Time {
2429
- constructor() {
2430
- super();
2431
- this._step = new ConstTime().Now();
2432
- this._start = this._step;
2433
- }
2434
- Now(steps = 1) {
2435
- for (let i = 0; steps > 0 && i < steps; i++) {
2436
- this._step = new Date(this._step.getTime() + 1e3);
2437
- }
2438
- if (steps < 1) {
2439
- this._step = new Date(this._start.getTime() + steps * -1e3);
2440
- }
2441
- return this._step;
2442
- }
2443
- Sleep(duration) {
2444
- this._step = new Date(this._step.getTime() + duration);
2445
- return Promise.resolve();
2446
- }
2447
- };
2448
- function TimeFactory(timeMode) {
2449
- switch (timeMode) {
2450
- case TimeMode.REAL:
2451
- return new SysTime();
2452
- case TimeMode.CONST:
2453
- return new ConstTime();
2454
- case TimeMode.STEP:
2455
- return new StepTime();
2456
- }
2457
- return new SysTime();
2458
- }
2459
- var RandomService = class {
2460
- constructor(mode) {
2461
- this._step = 0;
2462
- this._mode = mode;
2463
- }
2464
- Random0ToValue(value) {
2465
- switch (this._mode) {
2466
- case RandomMode.CONST:
2467
- return 0.5 * value;
2468
- case RandomMode.STEP:
2469
- this._step += 1e-4;
2470
- return this._step * value;
2471
- case RandomMode.RANDOM:
2472
- return Math.random() * value;
2473
- default:
2474
- throw new Error("Unknown RandomMode");
2475
- }
2476
- }
2477
- };
2478
- var IdService = class {
2479
- constructor(mode) {
2480
- this._step = 0;
2481
- if (!mode) {
2482
- mode = IDMode.UUID;
2483
- }
2484
- this._mode = mode;
2485
- }
2486
- NextId() {
2487
- switch (this._mode) {
2488
- case IDMode.UUID:
2489
- return crypto.randomUUID();
2490
- case IDMode.CONST:
2491
- return "VeryUniqueID";
2492
- case IDMode.STEP:
2493
- return `STEPId-${this._step++}`;
2494
- default:
2495
- throw new Error("Unknown IDMode");
2496
- }
2497
- }
2498
- };
2499
- var BaseBasicSysAbstraction = class {
2500
- constructor(params) {
2501
- this._time = new SysTime();
2502
- // system independent services
2503
- this._idService = new IdService();
2504
- this._randomService = new RandomService(RandomMode.RANDOM);
2505
- this._txtEnDe = params.TxtEnDecoder;
2506
- }
2507
- };
2508
- var BaseSysAbstraction = class extends BaseBasicSysAbstraction {
2509
- constructor(params) {
2510
- super(params);
2511
- this._fileSystem = params.FileSystem;
2512
- this._systemService = params.SystemService;
2513
- }
2514
- };
2515
- function BasicSysAbstractionFactory(params) {
2516
- const fn = runtimeFn();
2517
- switch (true) {
2518
- case fn.isBrowser:
2519
- return WebBasicSysAbstraction(params);
2520
- case fn.isDeno:
2521
- return DenoBasicSysAbstraction(params);
2522
- case fn.isCFWorker:
2523
- return CFBasicSysAbstraction(params);
2524
- case fn.isNodeIsh:
2525
- return NodeBasicSysAbstraction(params);
2526
- default:
2527
- throw new Error("Unknown runtime");
2528
- }
2529
- }
2530
- var WrapperBasicSysAbstraction = class {
2531
- constructor(base, params) {
2532
- this._time = base._time;
2533
- this._basicRuntimeService = params.basicRuntimeService;
2534
- this._idService = base._idService;
2535
- this._randomService = base._randomService;
2536
- if (params.TimeMode) {
2537
- this._time = TimeFactory(params.TimeMode);
2538
- }
2539
- if (params.IdMode) {
2540
- this._idService = new IdService(params.IdMode);
2541
- }
2542
- if (params.RandomMode) {
2543
- this._randomService = new RandomService(params.RandomMode);
2544
- }
2545
- }
2546
- Time() {
2547
- return this._time;
2548
- }
2549
- NextId() {
2550
- return this._idService.NextId();
2551
- }
2552
- Random0ToValue(value) {
2553
- return this._randomService.Random0ToValue(value);
2554
- }
2555
- Stdout() {
2556
- return this._basicRuntimeService.Stdout();
2557
- }
2558
- Stderr() {
2559
- return this._basicRuntimeService.Stderr();
2560
- }
2561
- Env() {
2562
- return this._basicRuntimeService.Env();
2563
- }
2564
- Args() {
2565
- return this._basicRuntimeService.Args();
2566
- }
2567
- // System(): SystemService {
2568
- // return this._systemService;
2569
- // }
2570
- // FileSystem(): FileService {
2571
- // return this._fileSystem;
2572
- // }
2573
- };
2574
- var WrapperRuntimeSysAbstraction = class extends WrapperBasicSysAbstraction {
2575
- constructor(base, params) {
2576
- var _a, _b;
2577
- super(base, params);
2578
- this._systemService = (_a = params.systemService) != null ? _a : base._systemService;
2579
- this._fileSystem = (_b = params.fileSystem) != null ? _b : base._fileSystem;
2580
- }
2581
- System() {
2582
- return this._systemService;
2583
- }
2584
- FileSystem() {
2585
- return this._fileSystem;
2586
- }
2587
- };
2588
-
2589
- // src/log-writer-impl.ts
2590
- var LogWriterStream = class {
2591
- constructor(out) {
2592
- this._toFlush = [];
2593
- this._flushIsRunning = false;
2594
- this._flushDoneFns = [];
2595
- this._out = out;
2596
- this._id = Math.random();
2597
- }
2598
- write(encoded) {
2599
- const my = async () => {
2600
- try {
2601
- const writer = this._out.getWriter();
2602
- await writer.ready;
2603
- await writer.write(encoded);
2604
- writer.releaseLock();
2605
- } catch (err) {
2606
- console.error("Chunk error:", err);
2607
- }
2608
- };
2609
- this._toFlush.push(my);
2610
- this._flush();
2611
- }
2612
- _flush(toFlush = void 0, done) {
2613
- if (done) {
2614
- this._flushDoneFns.push(done);
2615
- }
2616
- if (this._toFlush.length == 0) {
2617
- this._flushIsRunning = false;
2618
- this._flushDoneFns.forEach((fn) => fn());
2619
- this._flushDoneFns = [];
2620
- return;
2621
- }
2622
- if (!toFlush && this._toFlush.length == 1 && !this._flushIsRunning) {
2623
- this._flushIsRunning = true;
2624
- } else if (!toFlush) {
2625
- return;
2626
- }
2627
- const my = this._toFlush.shift();
2628
- my == null ? void 0 : my().catch((e) => {
2629
- console.error("Flush error:", e);
2630
- }).finally(() => {
2631
- this._flush(this._toFlush);
2632
- });
2633
- }
2634
- };
2635
-
2636
- // src/logger-impl.ts
2637
- function getLen(value, lvs) {
2638
- if (Array.isArray(value)) {
2639
- return logValue(() => value.length, lvs);
2640
- } else if (typeof value === "string") {
2641
- return logValue(() => value.length, lvs);
2642
- } else if (typeof value === "object" && value !== null) {
2643
- if (typeof value.size === "number") {
2644
- return logValue(() => value.size, lvs);
2645
- } else if (typeof value.length === "number") {
2646
- return logValue(() => value.length, lvs);
2647
- }
2648
- return logValue(() => Object.keys(value).length, lvs);
2649
- }
2650
- return logValue(() => -1, lvs);
2651
- }
2652
- function toLogValue(lop) {
2653
- if (lop && typeof lop.then === "function") {
2654
- throw new Error("async logValue Not implemented");
2655
- }
2656
- return lop;
2657
- }
2658
- var JSONFormatter = class {
2659
- constructor(txtEnde, space) {
2660
- this._txtEnDe = txtEnde;
2661
- this._space = space;
2662
- }
2663
- format(attr) {
2664
- let ret;
2665
- try {
2666
- ret = JSON.stringify(attr, null, this._space);
2667
- } catch (e) {
2668
- ret = JSON.stringify({ internal: { message: e.message, stack: e.stack } });
2669
- }
2670
- return this._txtEnDe.encode(ret + "\n");
2671
- }
2672
- };
2673
- var YAMLFormatter = class {
2674
- constructor(txtEnde, space) {
2675
- this._txtEnDe = txtEnde;
2676
- this._space = space;
2677
- }
2678
- format(attr) {
2679
- return this._txtEnDe.encode("---\n" + import_yaml.default.stringify(attr, null, this._space) + "\n");
2680
- }
2681
- };
2682
- function toLogValueCtx(lvh) {
2683
- return {
2684
- ignoreAttr: lvh.ignoreAttr
2685
- };
2686
- }
2687
- var LoggerImpl = class _LoggerImpl {
2688
- // readonly _id: string = "logger-" + Math.random().toString(36)
2689
- constructor(params) {
2690
- this._attributes = {};
2691
- if (!params) {
2692
- params = {};
2693
- }
2694
- if (!params.sys) {
2695
- this._sys = BasicSysAbstractionFactory();
2696
- } else {
2697
- this._sys = params.sys;
2698
- }
2699
- if (!params.txtEnDe) {
2700
- this._txtEnDe = TxtEnDecoderSingleton();
2701
- } else {
2702
- this._txtEnDe = params.txtEnDe;
2703
- }
2704
- if (!params.formatter) {
2705
- this._formatter = new JSONFormatter(this._txtEnDe);
2706
- } else {
2707
- this._formatter = params.formatter;
2708
- }
2709
- if (params.logWriter) {
2710
- this._logWriter = params.logWriter;
2711
- } else {
2712
- if (!params.out) {
2713
- this._logWriter = new LogWriterStream(this._sys.Stdout());
2714
- } else {
2715
- this._logWriter = new LogWriterStream(params.out);
2716
- }
2717
- }
2718
- if (!params.withAttributes) {
2719
- this._withAttributes = {};
2720
- } else {
2721
- this._withAttributes = { ...params.withAttributes };
2722
- }
2723
- this._attributes = { ...this._withAttributes };
2724
- if (params.levelHandler) {
2725
- this.levelHandler = params.levelHandler;
2726
- } else {
2727
- this.levelHandler = LevelHandlerSingleton();
2728
- }
2729
- }
2730
- TxtEnDe() {
2731
- return this._txtEnDe;
2732
- }
2733
- Attributes() {
2734
- return JSON.parse(JSON.stringify(this._attributes, null));
2735
- }
2736
- SetExposeStack(enable) {
2737
- this.levelHandler.setExposeStack(enable);
2738
- return this;
2739
- }
2740
- EnableLevel(level, ...modules) {
2741
- this.levelHandler.enableLevel(level, ...modules);
2742
- return this;
2743
- }
2744
- DisableLevel(level, ...modules) {
2745
- this.levelHandler.disableLevel(level, ...modules);
2746
- return this;
2747
- }
2748
- Module(key) {
2749
- this._attributes["module"] = logValue(key, toLogValueCtx(this.levelHandler));
2750
- this._withAttributes["module"] = logValue(key, toLogValueCtx(this.levelHandler));
2751
- return this;
2752
- }
2753
- // if the string is "*" it will enable for all modules
2754
- SetDebug(...modules) {
2755
- this.levelHandler.setDebug(...modules);
2756
- return this;
2757
- }
2758
- SetIgnoreAttribute(re) {
2759
- this.levelHandler.setIgnoreAttr(re);
2760
- return this;
2761
- }
2762
- SetFormatter(formatter) {
2763
- this._formatter = formatter;
2764
- return this;
2765
- }
2766
- Timestamp() {
2767
- this._attributes["ts"] = logValue(() => this._sys.Time().Now().toISOString(), toLogValueCtx(this.levelHandler));
2768
- return this;
2769
- }
2770
- Warn() {
2771
- this._attributes["level"] = logValue(Level.WARN, toLogValueCtx(this.levelHandler));
2772
- return this;
2773
- }
2774
- Log() {
2775
- return this;
2776
- }
2777
- Debug() {
2778
- this._attributes["level"] = logValue(Level.DEBUG, toLogValueCtx(this.levelHandler));
2779
- return this;
2780
- }
2781
- Error() {
2782
- this._attributes["level"] = logValue(Level.ERROR, toLogValueCtx(this.levelHandler));
2783
- return this;
2784
- }
2785
- Info() {
2786
- this._attributes["level"] = logValue(Level.INFO, toLogValueCtx(this.levelHandler));
2787
- return this;
2788
- }
2789
- Err(err) {
2790
- var _a;
2791
- let key = "error";
2792
- if (Result.Is(err)) {
2793
- if (err.isOk()) {
2794
- key = "noerror";
2795
- err = err.Ok();
2796
- } else {
2797
- err = err.Err();
2798
- }
2799
- }
2800
- if (err instanceof Error) {
2801
- if (err.cause) {
2802
- this.coerceKey(key, {
2803
- message: err.message,
2804
- cause: err.cause
2805
- });
2806
- } else {
2807
- this._attributes[key] = logValue(err.message, toLogValueCtx(this.levelHandler));
2808
- }
2809
- if (this.levelHandler.isStackExposed) {
2810
- this._attributes["stack"] = logValue(
2811
- (_a = err.stack) == null ? void 0 : _a.split(/[\r\n]+/).map((s) => s.trim()),
2812
- toLogValueCtx(this.levelHandler)
2813
- );
2814
- }
2815
- } else {
2816
- this.Any(key, err);
2817
- }
2818
- return this;
2819
- }
2820
- WithLevel(l) {
2821
- this._attributes["level"] = logValue(l, toLogValueCtx(this.levelHandler));
2822
- return this;
2823
- }
2824
- Ref(key, action) {
2825
- if (typeof action === "function") {
2826
- this._attributes[key] = logValue(action, toLogValueCtx(this.levelHandler));
2827
- } else if (typeof action.toString === "function") {
2828
- this._attributes[key] = logValue(() => action.toString(), toLogValueCtx(this.levelHandler));
2829
- } else {
2830
- this._attributes[key] = logValue("INVALID REF", toLogValueCtx(this.levelHandler));
2831
- }
2832
- return this;
2833
- }
2834
- Bool(key, value) {
2835
- this.coerceKey(key, !!value);
2836
- return this;
2837
- }
2838
- Http(...mix) {
2839
- const key = mix.find((x) => typeof x === "string");
2840
- mix = mix.filter((x) => typeof x !== "string");
2841
- const resErrors = mix.filter((x) => Result.Is(x) && x.isErr());
2842
- if (resErrors.length) {
2843
- this.Err(resErrors.map((x) => x.Err().message).join("\n"));
2844
- return this;
2845
- }
2846
- const req = mix.map((reqOrResult) => Result.Is(reqOrResult) ? reqOrResult.Ok() : reqOrResult).find((req2) => typeof req2.status !== "number");
2847
- const res = mix.map((resOrResult) => Result.Is(resOrResult) ? resOrResult.Ok() : resOrResult).find((res2) => typeof res2.status === "number");
2848
- let reqAndOrres;
2849
- if (res && req) {
2850
- reqAndOrres = { res, req };
2851
- } else if (!res && !req) {
2852
- reqAndOrres = void 0;
2853
- } else if (res) {
2854
- reqAndOrres = res;
2855
- } else if (req) {
2856
- reqAndOrres = req;
2857
- }
2858
- if (reqAndOrres) {
2859
- this.Any(key || "Http", reqAndOrres);
2860
- }
2861
- return this;
2862
- }
2863
- Pair(x) {
2864
- for (const key of Object.keys(x)) {
2865
- const value = x[key];
2866
- if (value instanceof LogValue) {
2867
- this._attributes[key] = value;
2868
- continue;
2869
- }
2870
- if (Result.Is(value)) {
2871
- this.Result(key, value);
2872
- continue;
2873
- }
2874
- this.Any(key, value);
2875
- }
2876
- return this;
2877
- }
2878
- Result(key, res) {
2879
- if (res.isOk()) {
2880
- this._attributes[key] = logValue(res.Ok(), toLogValueCtx(this.levelHandler));
2881
- } else {
2882
- this.Err(res.Err());
2883
- }
2884
- return this;
2885
- }
2886
- Len(value, key = "len") {
2887
- this._attributes[key] = getLen(value, toLogValueCtx(this.levelHandler));
2888
- return this;
2889
- }
2890
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2891
- Hash(value, key = "hash") {
2892
- throw new Error("Not implemented");
2893
- }
2894
- Url(url, key = "url") {
2895
- this.Ref(key, () => URI.from(url).toString());
2896
- return this;
2897
- }
2898
- coerceKey(key, value) {
2899
- if (typeof key === "string") {
2900
- this._attributes[key] = logValue(value, toLogValueCtx(this.levelHandler));
2901
- } else {
2902
- this.Pair(key);
2903
- }
2904
- }
2905
- Str(key, value) {
2906
- this.coerceKey(key, value);
2907
- return this;
2908
- }
2909
- Any(key, value) {
2910
- this.coerceKey(key, value);
2911
- return this;
2912
- }
2913
- Dur(key, nsec) {
2914
- this._attributes[key] = logValue(`${nsec}ms`, toLogValueCtx(this.levelHandler));
2915
- return this;
2916
- }
2917
- Uint64(key, value) {
2918
- this.coerceKey(key, value);
2919
- return this;
2920
- }
2921
- Int(key, value) {
2922
- return this.Uint64(key, value);
2923
- }
2924
- async Flush() {
2925
- return new Promise((resolve) => {
2926
- this._logWriter._flush(void 0, resolve);
2927
- });
2928
- }
2929
- With() {
2930
- return new WithLoggerBuilder(
2931
- new _LoggerImpl({
2932
- logWriter: this._logWriter,
2933
- sys: this._sys,
2934
- levelHandler: this.levelHandler,
2935
- formatter: this._formatter,
2936
- withAttributes: {
2937
- module: this._attributes["module"],
2938
- ...this._withAttributes
2939
- }
2940
- })
2941
- );
2942
- }
2943
- _resetAttributes(fn) {
2944
- const ret = fn();
2945
- Object.keys(this._attributes).forEach((key) => {
2946
- delete this._attributes[key];
2947
- });
2948
- Object.assign(this._attributes, this._withAttributes);
2949
- return ret;
2950
- }
2951
- Msg(...args) {
2952
- const fnError = this._resetAttributes(() => {
2953
- var _a, _b;
2954
- const doWrite = this.levelHandler.isEnabled(
2955
- (_a = toLogValue(this._attributes["level"])) == null ? void 0 : _a.value(),
2956
- (_b = toLogValue(this._attributes["module"])) == null ? void 0 : _b.value()
2957
- );
2958
- this._attributes["msg"] = logValue(args.join(" "), toLogValueCtx(this.levelHandler));
2959
- const msg = this._attributes["msg"].value();
2960
- if (typeof msg === "string" && !msg.trim().length) {
2961
- delete this._attributes["msg"];
2962
- }
2963
- let fnRet = () => this._formatter.format({ ...this._attributes });
2964
- if (doWrite) {
2965
- const encoded = fnRet();
2966
- this._logWriter.write(encoded);
2967
- fnRet = () => encoded;
2968
- }
2969
- return fnRet;
2970
- });
2971
- const asError = () => new Error(this._txtEnDe.decode(fnError()));
2972
- return {
2973
- ResultError: () => Result.Err(asError()),
2974
- AsError: asError
2975
- };
2976
- }
2977
- };
2978
- var WithLoggerBuilder = class {
2979
- constructor(li) {
2980
- this._li = li;
2981
- this.levelHandler = li.levelHandler;
2982
- }
2983
- TxtEnDe() {
2984
- return this._li.TxtEnDe();
2985
- }
2986
- Logger() {
2987
- Object.assign(this._li._withAttributes, this._li._attributes);
2988
- return this._li;
2989
- }
2990
- Attributes() {
2991
- return { ...this._li._attributes };
2992
- }
2993
- SetExposeStack(enable) {
2994
- this._li.levelHandler.setExposeStack(enable);
2995
- return this;
2996
- }
2997
- SetIgnoreAttribute(re) {
2998
- this._li.levelHandler.setIgnoreAttr(re);
2999
- return this;
3000
- }
3001
- SetFormatter(fmt) {
3002
- this._li.SetFormatter(fmt);
3003
- return this;
3004
- }
3005
- EnableLevel(level, ...modules) {
3006
- this._li.levelHandler.enableLevel(level, ...modules);
3007
- return this;
3008
- }
3009
- DisableLevel(level, ...modules) {
3010
- this._li.levelHandler.enableLevel(level, ...modules);
3011
- return this;
3012
- }
3013
- Module(key) {
3014
- this._li.Module(key);
3015
- return this;
3016
- }
3017
- SetDebug(...modules) {
3018
- this._li.SetDebug(...modules);
3019
- return this;
3020
- }
3021
- Http(...mix) {
3022
- this._li.Http(...mix);
3023
- return this;
3024
- }
3025
- Pair(x) {
3026
- this._li.Pair(x);
3027
- return this;
3028
- }
3029
- Str(key, value) {
3030
- this._li.Str(key, value);
3031
- return this;
3032
- }
3033
- Len(value, key) {
3034
- this._li.Len(value, key);
3035
- return this;
3036
- }
3037
- Hash(value, key) {
3038
- this._li.Hash(value, key);
3039
- return this;
3040
- }
3041
- Ref(key, action) {
3042
- this._li.Ref(key, action);
3043
- return this;
3044
- }
3045
- Bool(key, value) {
3046
- this._li.Bool(key, value);
3047
- return this;
3048
- }
3049
- Result(key, res) {
3050
- this._li.Result(key, res);
3051
- return this;
3052
- }
3053
- Url(url, key) {
3054
- this._li.Url(url, key);
3055
- return this;
3056
- }
3057
- Int(key, value) {
3058
- this._li.Int(key, value);
3059
- return this;
3060
- }
3061
- Log() {
3062
- this._li.Log();
3063
- return this;
3064
- }
3065
- WithLevel(level) {
3066
- this._li.WithLevel(level);
3067
- return this;
3068
- }
3069
- Error() {
3070
- this._li.Error();
3071
- return this;
3072
- }
3073
- Warn() {
3074
- this._li.Error();
3075
- return this;
3076
- }
3077
- Debug() {
3078
- this._li.Debug();
3079
- return this;
3080
- }
3081
- Err(err) {
3082
- this._li.Err(err);
3083
- return this;
3084
- }
3085
- Info() {
3086
- this._li.Info();
3087
- return this;
3088
- }
3089
- Timestamp() {
3090
- this._li.Timestamp();
3091
- return this;
3092
- }
3093
- Any(key, value) {
3094
- this._li.Any(key, value);
3095
- return this;
3096
- }
3097
- Dur(key, nsec) {
3098
- this._li.Dur(key, nsec);
3099
- return this;
3100
- }
3101
- Uint64(key, value) {
3102
- this._li.Uint64(key, value);
3103
- return this;
3104
- }
3105
- };
3106
-
3107
- // src/utils/fanout-write-stream.ts
3108
- var FanoutWriteStream = class {
3109
- constructor(writers) {
3110
- this.desiredSize = null;
3111
- this._writers = writers;
3112
- this.ready = Promise.all(this._writers.map((w) => w.ready)).then(() => void 0);
3113
- this.closed = Promise.all(this._writers.map((w) => w.closed)).then(() => void 0);
3114
- }
3115
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3116
- abort(reason) {
3117
- return Promise.all(this._writers.map((w) => w.abort(reason))).then(() => {
3118
- });
3119
- }
3120
- close() {
3121
- return Promise.all(this._writers.map((w) => w.close())).then(() => {
3122
- });
3123
- }
3124
- releaseLock() {
3125
- this._writers.map((w) => w.releaseLock());
3126
- }
3127
- write(chunk) {
3128
- return Promise.all(this._writers.map((w) => w.write(chunk))).then(() => {
3129
- });
3130
- }
3131
- };
3132
-
3133
- // src/test/log-write-stream.ts
3134
- var LogWriteStream = class {
3135
- constructor(bufferArr) {
3136
- this._resolveClosed = new Future();
3137
- this.closed = this._resolveClosed.asPromise();
3138
- this.desiredSize = null;
3139
- this.ready = Promise.resolve(void 0);
3140
- this._bufferArr = bufferArr;
3141
- }
3142
- // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
3143
- abort(reason) {
3144
- throw new Error("Method not implemented.");
3145
- }
3146
- async close() {
3147
- await this.closed;
3148
- return Promise.resolve(void 0);
3149
- }
3150
- releaseLock() {
3151
- }
3152
- async write(chunk) {
3153
- if (chunk) {
3154
- this._bufferArr.push(chunk);
3155
- }
3156
- return Promise.resolve(void 0);
3157
- }
3158
- };
3159
- var LogCollector = class {
3160
- constructor(pass, txtEnDe) {
3161
- this.locked = false;
3162
- this._bufferArr = [];
3163
- this._pass = pass;
3164
- this._txtEnDe = txtEnDe || TxtEnDecoderSingleton();
3165
- }
3166
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3167
- abort(reason) {
3168
- throw new Error("Method not implemented.");
3169
- }
3170
- async close() {
3171
- if (this._writer) {
3172
- const ret = await this._writer.close();
3173
- this._writer = void 0;
3174
- return ret;
3175
- }
3176
- return Promise.resolve(void 0);
3177
- }
3178
- getWriter() {
3179
- if (!this._writer) {
3180
- const dests = [new LogWriteStream(this._bufferArr)];
3181
- if (this._pass) {
3182
- dests.push(this._pass);
3183
- }
3184
- this._writer = new FanoutWriteStream(dests);
3185
- }
3186
- return this._writer;
3187
- }
3188
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3189
- Logs(notJsonLine = false) {
3190
- if (!this._writer) {
3191
- return [];
3192
- }
3193
- const jsonNlStr = this._txtEnDe.decode(
3194
- new Uint8Array(
3195
- function* (res) {
3196
- for (const x of res) {
3197
- yield* x;
3198
- }
3199
- }(this._bufferArr)
3200
- )
3201
- );
3202
- if (!notJsonLine) {
3203
- const splitStr = jsonNlStr.split("\n");
3204
- const filterStr = splitStr.filter((a) => a.length);
3205
- const mapStr = filterStr.map((a) => JSON.parse(a));
3206
- return mapStr;
3207
- }
3208
- return jsonNlStr.split("\n").filter((a) => a.length);
3209
- }
3210
- };
3211
-
3212
- // src/test/mock-logger.ts
3213
- function MockLogger(params) {
3214
- const lc = new LogCollector(params == null ? void 0 : params.pass);
3215
- let modNames = ["MockLogger"];
3216
- if (typeof (params == null ? void 0 : params.moduleName) === "string") {
3217
- modNames = [params == null ? void 0 : params.moduleName];
3218
- } else if (Array.isArray(params == null ? void 0 : params.moduleName)) {
3219
- modNames = [...params.moduleName, ...modNames];
3220
- }
3221
- const logger = new LoggerImpl({
3222
- out: lc,
3223
- sys: params == null ? void 0 : params.sys,
3224
- levelHandler: new LevelHandlerImpl()
3225
- }).With().Module(modNames[0]).Logger();
3226
- if (!(params == null ? void 0 : params.disableDebug)) {
3227
- logger.SetDebug(...modNames);
3228
- }
3229
- return {
3230
- logCollector: lc,
3231
- logger
3232
- };
3233
- }
3234
-
3235
- // src/tracer.ts
3236
- var Metric = class {
3237
- constructor(path) {
3238
- this.path = path;
3239
- }
3240
- set(value) {
3241
- this.value = value;
3242
- }
3243
- add(value) {
3244
- if (typeof value === "number") {
3245
- if (this.value === void 0) {
3246
- this.value = 0;
3247
- }
3248
- this.value = this.value + value;
3249
- } else if (Array.isArray(value)) {
3250
- if (!Array.isArray(this.value)) {
3251
- this.value = [];
3252
- }
3253
- this.value.push(...value);
3254
- } else {
3255
- throw new Error("add only support number or array");
3256
- }
3257
- }
3258
- };
3259
- var Metrics = class {
3260
- constructor(tracenode) {
3261
- this.spanRefs = /* @__PURE__ */ new Map();
3262
- this.tracenode = tracenode;
3263
- this.map = tracenode.ctx.metrics;
3264
- }
3265
- toJSON() {
3266
- const obj = {};
3267
- for (const [key, value] of this.map) {
3268
- obj[key] = value.value;
3269
- }
3270
- return obj;
3271
- }
3272
- get(ipath) {
3273
- const path = ipath.replace(/[/]+/g, "/").trim();
3274
- if (path.startsWith("/")) {
3275
- if (path.slice(1).length === 0) {
3276
- throw new Error(`Metrics path must contain value /:${path}`);
3277
- }
3278
- let metric = this.map.get(path);
3279
- if (!metric) {
3280
- metric = new Metric(path);
3281
- this.map.set(path, metric);
3282
- }
3283
- this.spanRefs.set(path, metric);
3284
- return metric;
3285
- } else if (path.includes("/")) {
3286
- throw new Error(`Metrics path must start with /:${path}`);
3287
- }
3288
- const rootPath = this.tracenode.getRootPath();
3289
- return this.get(`${rootPath}/${path}`);
3290
- }
3291
- };
3292
- var TraceNode = class _TraceNode {
3293
- constructor(ctx) {
3294
- this.childs = /* @__PURE__ */ new Map();
3295
- this.invokations = [];
3296
- this.spanId = ctx.spanId;
3297
- this.ctx = ctx;
3298
- this.metrics = new Metrics(this);
3299
- }
3300
- static root(time, logger) {
3301
- return new _TraceNode({
3302
- spanId: "root",
3303
- time,
3304
- logger,
3305
- metrics: /* @__PURE__ */ new Map(),
3306
- parent: void 0
3307
- });
3308
- }
3309
- getRootPath(rpath = []) {
3310
- if (!this.ctx.parent) {
3311
- return "/" + rpath.reverse().join("/");
3312
- }
3313
- return this.ctx.parent.getRootPath(rpath.concat(this.ctx.spanId));
3314
- }
3315
- invokes() {
3316
- const cleanCtx = { ...this.ctx };
3317
- delete cleanCtx.parent;
3318
- delete cleanCtx.time;
3319
- delete cleanCtx.logger;
3320
- delete cleanCtx.metrics;
3321
- const spanRefs = this.metrics.toJSON.call({ map: this.metrics.spanRefs });
3322
- const metricsRefs = Object.keys(spanRefs).length > 0 ? { metricRefs: spanRefs } : {};
3323
- return {
3324
- ctx: cleanCtx,
3325
- invokations: this.invokations,
3326
- ...metricsRefs
3327
- };
3328
- }
3329
- ctxWith(spanId, logger) {
3330
- const ctx = {
3331
- ...this.ctx,
3332
- spanId
3333
- };
3334
- if (logger) {
3335
- ctx.logger = logger;
3336
- }
3337
- return ctx;
3338
- }
3339
- // <V extends () => Promise<T> | T, T>(id: string, fn: V): ReturnType<V>
3340
- span(inSpanId, fn) {
3341
- let ctx;
3342
- if (typeof inSpanId === "string") {
3343
- ctx = {
3344
- ...this.ctx,
3345
- spanId: inSpanId,
3346
- parent: this
3347
- };
3348
- } else {
3349
- ctx = {
3350
- ...this.ctx,
3351
- ...inSpanId,
3352
- parent: this
3353
- };
3354
- }
3355
- if (ctx.logger) {
3356
- ctx = {
3357
- ...ctx,
3358
- ...ctx.logger.Attributes()
3359
- };
3360
- }
3361
- const spanId = ctx.spanId;
3362
- let spanTrace = this.childs.get(spanId);
3363
- if (!spanTrace) {
3364
- spanTrace = new _TraceNode(ctx);
3365
- this.childs.set(spanId.toString(), spanTrace);
3366
- }
3367
- const invokation = {
3368
- start: this.ctx.time.Now().getTime(),
3369
- end: 0,
3370
- result: "success"
3371
- };
3372
- spanTrace.invokations.push(invokation);
3373
- try {
3374
- const possiblePromise = fn(spanTrace);
3375
- if (isPromise(possiblePromise)) {
3376
- return possiblePromise.then((v) => {
3377
- return v;
3378
- }).catch((e) => {
3379
- invokation.result = "error";
3380
- throw e;
3381
- }).finally(() => {
3382
- invokation.end = this.ctx.time.Now().getTime();
3383
- });
3384
- }
3385
- invokation.end = this.ctx.time.Now().getTime();
3386
- return possiblePromise;
3387
- } catch (e) {
3388
- invokation.result = "error";
3389
- invokation.end = this.ctx.time.Now().getTime();
3390
- throw e;
3391
- }
3392
- }
3393
- };
3394
-
3395
- // src/crypto.ts
3396
- function randomBytes(size) {
3397
- const bytes = new Uint8Array(size);
3398
- if (size > 0) {
3399
- crypto.getRandomValues(bytes);
3400
- }
3401
- return bytes;
3402
- }
3403
- function digestSHA256(data) {
3404
- return Promise.resolve(crypto.subtle.digest("SHA-256", data));
3405
- }
3406
- function toCryptoRuntime(cryptoOpts = {}) {
3407
- const runtime = {
3408
- importKey: cryptoOpts.importKey || crypto.subtle.importKey.bind(crypto.subtle),
3409
- exportKey: cryptoOpts.exportKey || crypto.subtle.exportKey.bind(crypto.subtle),
3410
- encrypt: cryptoOpts.encrypt || crypto.subtle.encrypt.bind(crypto.subtle),
3411
- decrypt: cryptoOpts.decrypt || crypto.subtle.decrypt.bind(crypto.subtle),
3412
- randomBytes: cryptoOpts.randomBytes || randomBytes,
3413
- digestSHA256: cryptoOpts.digestSHA256 || digestSHA256
3414
- };
3415
- return runtime;
3416
- }
3417
-
3418
- // src/version.ts
3419
- var VERSION = Object.keys({
3420
- __packageVersion__: "xxxx"
3421
- })[0];
3422
-
3423
- // src/http_header.ts
3424
- var HeadersImpl = class extends Headers {
3425
- constructor(init) {
3426
- super();
3427
- this._headers = init;
3428
- }
3429
- [Symbol.iterator]() {
3430
- return this.entries();
3431
- }
3432
- entries() {
3433
- return this._headers.entries();
3434
- }
3435
- keys() {
3436
- return this._headers.keys();
3437
- }
3438
- values() {
3439
- return this._headers.values();
3440
- }
3441
- append(key, value) {
3442
- const values = this._headers.get(key);
3443
- if (typeof value === "undefined") {
3444
- value = "";
3445
- }
3446
- if (Array.isArray(value)) {
3447
- this._headers.set(key, [values, ...value].filter((i) => i).join(", "));
3448
- } else {
3449
- this._headers.set(key, [values, value].filter((i) => i).join(", "));
3450
- }
3451
- return this;
3452
- }
3453
- };
3454
- var HttpHeader = class _HttpHeader {
3455
- constructor() {
3456
- this._headers = /* @__PURE__ */ new Map();
3457
- }
3458
- static from(headers) {
3459
- if (headers instanceof _HttpHeader) {
3460
- return headers.Clone();
3461
- }
3462
- const h = new _HttpHeader();
3463
- if (headers) {
3464
- if (Array.isArray(headers)) {
3465
- for (const [k, v] of headers) {
3466
- if (v) {
3467
- h.Add(k, v);
3468
- }
3469
- }
3470
- } else if (headers instanceof Headers) {
3471
- for (const [k, v] of headers.entries()) {
3472
- if (v) {
3473
- h.Add(
3474
- k,
3475
- v.split(",").map((v2) => v2.trim())
3476
- );
3477
- }
3478
- }
3479
- } else {
3480
- for (const k in headers) {
3481
- const v = headers[k];
3482
- (Array.isArray(v) ? v : [v]).forEach((v2) => {
3483
- h.Add(k, v2);
3484
- });
3485
- }
3486
- }
3487
- }
3488
- return h;
3489
- }
3490
- _asStringString() {
3491
- const ret = /* @__PURE__ */ new Map();
3492
- for (const [key, values] of this._headers) {
3493
- ret.set(key, values.join(", "));
3494
- }
3495
- return ret;
3496
- }
3497
- _key(key) {
3498
- return key.toLowerCase();
3499
- }
3500
- Values(key) {
3501
- const values = this._headers.get(this._key(key));
3502
- return values || [];
3503
- }
3504
- Get(key) {
3505
- const values = this._headers.get(this._key(key));
3506
- if (values === void 0 || values.length === 0) {
3507
- return void 0;
3508
- }
3509
- return values[0];
3510
- }
3511
- Set(key, valueOr) {
3512
- const value = Array.isArray(valueOr) ? valueOr : [valueOr];
3513
- this._headers.set(this._key(key), value);
3514
- return this;
3515
- }
3516
- Add(key, value) {
3517
- if (typeof value === "undefined") {
3518
- return this;
3519
- }
3520
- const vs = Array.isArray(value) ? value : [value];
3521
- const values = this._headers.get(this._key(key));
3522
- if (values === void 0) {
3523
- this._headers.set(this._key(key), vs);
3524
- } else {
3525
- values.push(...vs);
3526
- }
3527
- return this;
3528
- }
3529
- Del(ey) {
3530
- this._headers.delete(this._key(ey));
3531
- return this;
3532
- }
3533
- Items() {
3534
- return Array.from(this._headers).filter(([_, vs]) => vs.length > 0);
3535
- }
3536
- SortItems() {
3537
- return this.Items().sort(([[a]], [[b]]) => a.localeCompare(b));
3538
- }
3539
- Clone() {
3540
- const clone = new _HttpHeader();
3541
- for (const [key, values] of this._headers.entries()) {
3542
- clone._headers.set(key, values.slice());
3543
- }
3544
- return clone;
3545
- }
3546
- AsRecordStringStringArray() {
3547
- const obj = {};
3548
- for (const [key, values] of this._headers.entries()) {
3549
- obj[key] = [...values];
3550
- }
3551
- return obj;
3552
- }
3553
- AsRecordStringString() {
3554
- const obj = {};
3555
- for (const [key, values] of this._headers.entries()) {
3556
- obj[key] = values.join(", ");
3557
- }
3558
- return obj;
3559
- }
3560
- AsHeaderInit() {
3561
- const obj = {};
3562
- for (const [key, values] of this._headers.entries()) {
3563
- obj[key] = values[0];
3564
- }
3565
- return obj;
3566
- }
3567
- AsHeaders() {
3568
- return new HeadersImpl(this._asStringString());
3569
- }
3570
- Merge(other) {
3571
- const ret = this.Clone();
3572
- if (other) {
3573
- for (const [key, values] of other.Items()) {
3574
- ret.Add(key, values);
3575
- }
3576
- }
3577
- return ret;
3578
- }
3579
- };
3580
-
3581
- // src/path-ops.ts
3582
- var _pathOpsImpl_instances, parts_fn;
3583
- var pathOpsImpl = class {
3584
- constructor() {
3585
- __privateAdd(this, _pathOpsImpl_instances);
3586
- }
3587
- join(...paths) {
3588
- const parts = __privateMethod(this, _pathOpsImpl_instances, parts_fn).call(this, paths.filter((i) => i).join("/"));
3589
- if (parts.dirname === "" || parts.dirname === ".") {
3590
- return parts.basename ? parts.basename : ".";
3591
- }
3592
- return parts.dirname + "/" + parts.basename;
3593
- }
3594
- dirname(path) {
3595
- return __privateMethod(this, _pathOpsImpl_instances, parts_fn).call(this, path).dirname;
3596
- }
3597
- basename(path) {
3598
- return __privateMethod(this, _pathOpsImpl_instances, parts_fn).call(this, path).basename;
3599
- }
3600
- };
3601
- _pathOpsImpl_instances = new WeakSet();
3602
- parts_fn = function(path) {
3603
- path = path.replace(/\/+/g, "/").replace(/(\/\.\/)+/g, "/").replace(/\/+$/, "");
3604
- const splitted = path.split("/");
3605
- if (splitted.length === 1) {
3606
- return {
3607
- dirname: ".",
3608
- basename: splitted[0] === "." ? "" : splitted[0]
3609
- };
3610
- }
3611
- const basename = splitted.pop();
3612
- return {
3613
- dirname: splitted.join("/").replace(/^\.\//, ""),
3614
- basename
3615
- };
3616
- };
3617
- var pathOps = new pathOpsImpl();
3618
-
3619
- // src/json-en-decoder.ts
3620
- var JSONOps = class {
3621
- constructor(txtOps) {
3622
- this.txtOps = txtOps;
3623
- }
3624
- async asyncStringify(input, replacer, space) {
3625
- const resolved = await input;
3626
- return this.stringify(resolved, replacer, space);
3627
- }
3628
- async asyncUint8ify(input, replacer, space) {
3629
- const resolved = await input;
3630
- return this.uint8ify(resolved, replacer, space);
3631
- }
3632
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3633
- async asyncParse(input, reviver) {
3634
- return this.parse(await this.txtOps.asyncDecode(input), reviver);
3635
- }
3636
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3637
- stringify(input, replacer, space) {
3638
- return JSON.stringify(Result.Is(input) ? input.unwrap() : input, replacer, space);
3639
- }
3640
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3641
- uint8ify(input, replacer, space) {
3642
- return this.txtOps.encode(this.stringify(input, replacer, space));
3643
- }
3644
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3645
- parse(input, reviver) {
3646
- return exception2Result(() => JSON.parse(this.txtOps.decode(input), reviver));
3647
- }
3648
- };
3649
- var jsonEnDecoder;
3650
- function JSONEnDecoderSingleton(txtEnde) {
3651
- let needNew = false;
3652
- if (txtEnde && txtEnde !== TxtEnDecoderSingleton()) {
3653
- needNew = !!txtEnde;
3654
- txtEnde = txtEnde != null ? txtEnde : TxtEnDecoderSingleton();
3655
- }
3656
- if (needNew && txtEnde) {
3657
- return new JSONOps(txtEnde);
3658
- }
3659
- jsonEnDecoder = jsonEnDecoder != null ? jsonEnDecoder : new JSONOps(TxtEnDecoderSingleton());
3660
- return jsonEnDecoder;
3661
- }
3662
-
3663
- // src/coerce-binary.ts
3664
- async function top_uint8(input) {
3665
- if (input instanceof Blob) {
3666
- return new Uint8Array(await input.arrayBuffer());
3667
- }
3668
- return to_uint8(input);
3669
- }
3670
- function to_uint8(input, encoder) {
3671
- if (typeof input === "string") {
3672
- return (encoder != null ? encoder : new TextEncoder()).encode(input);
3673
- }
3674
- if (input instanceof ArrayBuffer) {
3675
- return new Uint8Array(input);
3676
- }
3677
- if (input instanceof Uint8Array) {
3678
- return input;
3679
- }
3680
- return new Uint8Array(input);
3681
- }
3682
- function to_blob(input, encoder) {
3683
- if (input instanceof Blob) {
3684
- return input;
3685
- }
3686
- return new Blob([to_uint8(input, encoder)]);
3687
- }
3688
- function to_arraybuf(input, encoder) {
3689
- if (input instanceof ArrayBuffer) {
3690
- return input;
3691
- }
3692
- const u8 = to_uint8(input, encoder);
3693
- return u8.buffer.slice(u8.byteOffset, u8.byteOffset + u8.byteLength);
3694
- }
3695
-
3696
- // src/utils/index.ts
3697
- var utils_exports = {};
3698
- __export(utils_exports, {
3699
- ConsoleWriterStream: () => ConsoleWriterStream,
3700
- ConsoleWriterStreamDefaultWriter: () => ConsoleWriterStreamDefaultWriter,
3701
- FanoutWriteStream: () => FanoutWriteStream,
3702
- UInt8ArrayEqual: () => UInt8ArrayEqual,
3703
- array2stream: () => array2stream,
3704
- asyncCoerceIntoUint8: () => asyncCoerceIntoUint8,
3705
- coerceIntoUint8: () => coerceIntoUint8,
3706
- devnull: () => devnull,
3707
- getParamsResult: () => getParamsResult,
3708
- rebuffer: () => rebuffer,
3709
- rebufferArray: () => rebufferArray,
3710
- stream2array: () => stream2array,
3711
- stream2string: () => stream2string,
3712
- stream2uint8array: () => stream2uint8array,
3713
- streamMap: () => streamMap,
3714
- string2stream: () => string2stream,
3715
- stripper: () => stripper,
3716
- toSortedArray: () => toSortedArray,
3717
- toSortedObject: () => toSortedObject,
3718
- toSortedObjectArray: () => toSortedObjectArray,
3719
- uint8array2stream: () => uint8array2stream
3720
- });
3721
-
3722
- // src/utils/stream-map.ts
3723
- function streamMap(s, sm) {
3724
- const state = { reader: s.getReader(), streamMap: sm, idx: 0 };
3725
- return new ReadableStream({
3726
- async pull(controller) {
3727
- const { done, value } = await state.reader.read();
3728
- if (done) {
3729
- if (state.streamMap.Close) {
3730
- state.streamMap.Close();
3731
- }
3732
- controller.close();
3733
- return;
3734
- }
3735
- const promiseOrU = state.streamMap.Map(value, state.idx++);
3736
- let mapped;
3737
- if (isPromise(promiseOrU)) {
3738
- mapped = await promiseOrU;
3739
- } else {
3740
- mapped = promiseOrU;
3741
- }
3742
- controller.enqueue(mapped);
3743
- }
3744
- });
3745
- }
3746
- async function devnull(a) {
3747
- const reader = a.getReader();
3748
- let cnt = 0;
3749
- while (true) {
3750
- const { done } = await reader.read();
3751
- if (done) {
3752
- break;
3753
- }
3754
- cnt++;
3755
- }
3756
- return cnt;
3757
- }
3758
- function array2stream(a) {
3759
- let i = 0;
3760
- return new ReadableStream({
3761
- pull(controller) {
3762
- if (i >= a.length) {
3763
- controller.close();
3764
- return;
3765
- }
3766
- controller.enqueue(a[i]);
3767
- i++;
3768
- }
3769
- });
3770
- }
3771
- async function stream2array(a) {
3772
- const ret = [];
3773
- const reader = a.getReader();
3774
- while (true) {
3775
- const { done, value } = await reader.read();
3776
- if (done) {
3777
- break;
3778
- }
3779
- ret.push(value);
3780
- }
3781
- return ret;
3782
- }
3783
-
3784
- // src/utils/rebuffer.ts
3785
- async function rebufferArray(a, chunkSize) {
3786
- return stream2array(rebuffer(array2stream(a), chunkSize));
3787
- }
3788
- function reChunk(cs, chunkSize) {
3789
- const len = cs.reduce((acc, v) => acc + v.length, 0);
3790
- const last = cs[cs.length - 1];
3791
- const lastOfs = len - last.length;
3792
- const rest = last.subarray(chunkSize - lastOfs);
3793
- cs[cs.length - 1] = last.subarray(0, chunkSize - lastOfs);
3794
- const chunk = new Uint8Array(chunkSize);
3795
- let ofs = 0;
3796
- for (const c of cs) {
3797
- chunk.set(c, ofs);
3798
- ofs += c.length;
3799
- }
3800
- return { rest, chunk };
3801
- }
3802
- function pump(ps, controller, next) {
3803
- ps.reader.read().then(({ done, value }) => {
3804
- if (done) {
3805
- if (ps.tmpLen > 0) {
3806
- controller.enqueue(reChunk(ps.tmp, ps.tmpLen).chunk);
3807
- }
3808
- controller.close();
3809
- next();
3810
- return;
3811
- }
3812
- if (ps.tmpLen + value.length > ps.chunkSize) {
3813
- ps.tmp.push(value);
3814
- const res = reChunk(ps.tmp, ps.chunkSize);
3815
- controller.enqueue(res.chunk);
3816
- ps.tmp = [res.rest];
3817
- ps.tmpLen = res.rest.length;
3818
- next();
3819
- return;
3820
- } else if (value.length) {
3821
- ps.tmp.push(value);
3822
- ps.tmpLen += value.length;
3823
- }
3824
- pump(ps, controller, next);
3825
- }).catch((err) => {
3826
- controller.error(err);
3827
- next();
3828
- });
3829
- }
3830
- function rebuffer(a, chunkSize) {
3831
- const state = {
3832
- reader: a.getReader(),
3833
- tmp: [],
3834
- tmpLen: 0,
3835
- chunkSize
3836
- };
3837
- return new ReadableStream({
3838
- async pull(controller) {
3839
- return new Promise((resolve) => {
3840
- pump(state, controller, resolve);
3841
- });
3842
- }
3843
- });
3844
- }
3845
-
3846
- // src/utils/stream2string.ts
3847
- async function stream2string(stream, maxSize) {
3848
- if (!stream) {
3849
- return Promise.resolve("");
3850
- }
3851
- const reader = stream.getReader();
3852
- let res = "";
3853
- const decoder = new TextDecoder();
3854
- let rSize = 0;
3855
- while (typeof maxSize === "undefined" || rSize < maxSize) {
3856
- try {
3857
- const read = await reader.read();
3858
- if (read.done) {
3859
- break;
3860
- }
3861
- if (maxSize && rSize + read.value.length > maxSize) {
3862
- read.value = read.value.slice(0, maxSize - rSize);
3863
- }
3864
- const block = decoder.decode(read.value, { stream: true });
3865
- rSize += read.value.length;
3866
- res += block;
3867
- } catch (err) {
3868
- return Promise.reject(err);
3869
- }
3870
- }
3871
- return Promise.resolve(res);
3872
- }
3873
- async function stream2uint8array(stream) {
3874
- if (!stream) {
3875
- return Promise.resolve(new Uint8Array());
3876
- }
3877
- const reader = stream.getReader();
3878
- let res = new Uint8Array();
3879
- while (1) {
3880
- try {
3881
- const { done, value } = await reader.read();
3882
- if (done) {
3883
- break;
3884
- }
3885
- res = new Uint8Array([...res, ...value]);
3886
- } catch (err) {
3887
- return Promise.reject(err);
3888
- }
3889
- }
3890
- return Promise.resolve(res);
3891
- }
3892
-
3893
- // src/utils/string2stream.ts
3894
- function string2stream(str, ende = TxtEnDecoderSingleton()) {
3895
- return uint8array2stream(ende.encode(str));
3896
- }
3897
- function uint8array2stream(str) {
3898
- return new ReadableStream({
3899
- start(controller) {
3900
- controller.enqueue(str);
3901
- controller.close();
3902
- }
3903
- });
3904
- }
3905
-
3906
- // src/utils/sorted-object.ts
3907
- function toSortedObjectArray(set) {
3908
- if (!set) return [];
3909
- return toSortedArray(set).map(([k, v]) => ({ [k]: v }));
3910
- }
3911
- function toSortedArray(set) {
3912
- if (!set) return [];
3913
- return Object.entries(set).sort(([a], [b]) => a.localeCompare(b));
3914
- }
3915
- function toSortedObject(set) {
3916
- if (!set) return set;
3917
- return Object.fromEntries(toSortedArray(set));
3918
- }
3919
-
3920
- // src/utils/uint8array-equal.ts
3921
- function UInt8ArrayEqual(a, b) {
3922
- if (a.length !== b.length) {
3923
- return false;
3924
- }
3925
- for (let i = 0; i < a.length; i++) {
3926
- if (a[i] !== b[i]) {
3927
- return false;
3928
- }
3929
- }
3930
- return true;
3931
- }
3932
- // Annotate the CommonJS export names for ESM import in node:
3933
- 0 && (module.exports = {
3934
- BaseBasicSysAbstraction,
3935
- BaseSysAbstraction,
3936
- BasicSysAbstractionFactory,
3937
- BuildURI,
3938
- ConstTime,
3939
- EnvImpl,
3940
- Future,
3941
- HeadersImpl,
3942
- HttpHeader,
3943
- IDMode,
3944
- IdService,
3945
- IsLogger,
3946
- JSONEnDecoderSingleton,
3947
- JSONFormatter,
3948
- Keyed,
3949
- KeyedResolvOnce,
3950
- KeyedResolvSeq,
3951
- LRUMap,
3952
- LRUSet,
3953
- Level,
3954
- LevelHandlerImpl,
3955
- LevelHandlerSingleton,
3956
- LogCollector,
3957
- LogValue,
3958
- LogWriteStream,
3959
- LoggerImpl,
3960
- Metric,
3961
- Metrics,
3962
- MockLogger,
3963
- MutableURL,
3964
- None,
3965
- Option,
3966
- RandomMode,
3967
- RandomService,
3968
- ResolveOnce,
3969
- ResolveSeq,
3970
- Result,
3971
- ResultError,
3972
- ResultOK,
3973
- Some,
3974
- StepTime,
3975
- String2TimeMode,
3976
- SysTime,
3977
- Time,
3978
- TimeFactory,
3979
- TimeMode,
3980
- TimeUnits,
3981
- TraceNode,
3982
- TxtEnDecoderSingleton,
3983
- URI,
3984
- VERSION,
3985
- WrapperBasicSysAbstraction,
3986
- WrapperRuntimeSysAbstraction,
3987
- YAMLFormatter,
3988
- asyncLogValue,
3989
- bin2string,
3990
- bin2text,
3991
- envFactory,
3992
- exception2Result,
3993
- hasHostPartProtocols,
3994
- isCoerceURI,
3995
- isPromise,
3996
- isURL,
3997
- logValue,
3998
- param,
3999
- pathOps,
4000
- registerEnvAction,
4001
- runtimeFn,
4002
- toCryptoRuntime,
4003
- to_arraybuf,
4004
- to_blob,
4005
- to_uint8,
4006
- top_uint8,
4007
- utils
4008
- });
4009
- //# sourceMappingURL=index.cjs.map