@adviser/cement 0.4.6 → 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.
- package/base-basic-sys-abstraction.test.d.ts +2 -0
- package/base-basic-sys-abstraction.test.d.ts.map +1 -0
- package/base-basic-sys-abstraction.test.js +88 -0
- package/base-basic-sys-abstraction.test.js.map +1 -0
- package/{base-sys-abstraction-h0dB3nZ5.d.ts → base-sys-abstraction.d.ts} +23 -22
- package/base-sys-abstraction.d.ts.map +1 -0
- package/base-sys-abstraction.js +193 -0
- package/base-sys-abstraction.js.map +1 -0
- package/bin2text.d.ts +3 -0
- package/bin2text.d.ts.map +1 -0
- package/bin2text.js +43 -0
- package/bin2text.js.map +1 -0
- package/bin2text.test.d.ts +2 -0
- package/bin2text.test.d.ts.map +1 -0
- package/bin2text.test.js +51 -0
- package/bin2text.test.js.map +1 -0
- package/cf/cf-basic-sys-abstraction.d.ts +14 -0
- package/cf/cf-basic-sys-abstraction.d.ts.map +1 -0
- package/cf/cf-basic-sys-abstraction.js +67 -0
- package/cf/cf-basic-sys-abstraction.js.map +1 -0
- package/cf/cf-env-actions.d.ts +16 -0
- package/cf/cf-env-actions.d.ts.map +1 -0
- package/cf/cf-env-actions.js +53 -0
- package/cf/cf-env-actions.js.map +1 -0
- package/cf/index.d.ts +3 -30
- package/cf/index.d.ts.map +1 -0
- package/cf/index.js +2 -11
- package/cf/index.js.map +1 -1
- package/cf-test-main.d.ts +5 -0
- package/cf-test-main.d.ts.map +1 -0
- package/cf-test-main.js +12 -0
- package/cf-test-main.js.map +1 -0
- package/coerce-binary.d.ts +6 -0
- package/coerce-binary.d.ts.map +1 -0
- package/coerce-binary.js +32 -0
- package/coerce-binary.js.map +1 -0
- package/coerce-binary.test.d.ts +2 -0
- package/coerce-binary.test.d.ts.map +1 -0
- package/coerce-binary.test.js +39 -0
- package/coerce-binary.test.js.map +1 -0
- package/crypto.d.ts +76 -0
- package/crypto.d.ts.map +1 -0
- package/crypto.js +22 -0
- package/crypto.js.map +1 -0
- package/crypto.test.d.ts +2 -0
- package/crypto.test.d.ts.map +1 -0
- package/crypto.test.js +21 -0
- package/crypto.test.js.map +1 -0
- package/deno/deno-basic-sys-abstraction.d.ts +14 -0
- package/deno/deno-basic-sys-abstraction.d.ts.map +1 -0
- package/deno/deno-basic-sys-abstraction.js +35 -0
- package/deno/deno-basic-sys-abstraction.js.map +1 -0
- package/deno/deno-env-actions.d.ts +23 -0
- package/deno/deno-env-actions.d.ts.map +1 -0
- package/deno/deno-env-actions.js +40 -0
- package/deno/deno-env-actions.js.map +1 -0
- package/deno/deno-file-service.d.ts +17 -0
- package/deno/deno-file-service.d.ts.map +1 -0
- package/deno/deno-file-service.js +67 -0
- package/deno/deno-file-service.js.map +1 -0
- package/deno/deno-sys-abstraction.d.ts +19 -0
- package/deno/deno-sys-abstraction.d.ts.map +1 -0
- package/deno/deno-sys-abstraction.js +96 -0
- package/deno/deno-sys-abstraction.js.map +1 -0
- package/deno/index.d.ts +3 -37
- package/deno/index.d.ts.map +1 -0
- package/deno/index.js +2 -179
- package/deno/index.js.map +1 -1
- package/file-service.d.ts +17 -0
- package/file-service.d.ts.map +1 -0
- package/file-service.js +2 -0
- package/file-service.js.map +1 -0
- package/future.d.ts +8 -0
- package/future.d.ts.map +1 -0
- package/future.js +25 -0
- package/future.js.map +1 -0
- package/future.test.d.ts +2 -0
- package/future.test.d.ts.map +1 -0
- package/future.test.js +32 -0
- package/future.test.js.map +1 -0
- package/http_header.d.ts +29 -0
- package/http_header.d.ts.map +1 -0
- package/http_header.js +157 -0
- package/http_header.js.map +1 -0
- package/http_header.test.d.ts +2 -0
- package/http_header.test.d.ts.map +1 -0
- package/http_header.test.js +96 -0
- package/http_header.test.js.map +1 -0
- package/index.d.ts +29 -396
- package/index.d.ts.map +1 -0
- package/index.js +28 -609
- package/index.js.map +1 -1
- package/is-promise.d.ts +4 -0
- package/is-promise.d.ts.map +1 -0
- package/is-promise.js +10 -0
- package/is-promise.js.map +1 -0
- package/is-promise.test.d.ts +2 -0
- package/is-promise.test.d.ts.map +1 -0
- package/is-promise.test.js +48 -0
- package/is-promise.test.js.map +1 -0
- package/json-en-decoder.d.ts +12 -0
- package/json-en-decoder.d.ts.map +1 -0
- package/json-en-decoder.js +42 -0
- package/json-en-decoder.js.map +1 -0
- package/json-en-decoder.test.d.ts +2 -0
- package/json-en-decoder.test.d.ts.map +1 -0
- package/json-en-decoder.test.js +18 -0
- package/json-en-decoder.test.js.map +1 -0
- package/log-level-impl.d.ts +17 -0
- package/log-level-impl.d.ts.map +1 -0
- package/log-level-impl.js +75 -0
- package/log-level-impl.js.map +1 -0
- package/log-writer-impl.d.ts +11 -0
- package/log-writer-impl.d.ts.map +1 -0
- package/log-writer-impl.js +52 -0
- package/log-writer-impl.js.map +1 -0
- package/logger-impl.d.ts +75 -0
- package/logger-impl.d.ts.map +1 -0
- package/logger-impl.js +505 -0
- package/logger-impl.js.map +1 -0
- package/logger.d.ts +97 -0
- package/logger.d.ts.map +1 -0
- package/logger.js +150 -0
- package/logger.js.map +1 -0
- package/logger.test.d.ts +2 -0
- package/logger.test.d.ts.map +1 -0
- package/logger.test.js +1577 -0
- package/logger.test.js.map +1 -0
- package/lru-map-set.d.ts +33 -0
- package/lru-map-set.d.ts.map +1 -0
- package/lru-map-set.js +116 -0
- package/lru-map-set.js.map +1 -0
- package/lru-map-set.test.d.ts +2 -0
- package/lru-map-set.test.d.ts.map +1 -0
- package/lru-map-set.test.js +81 -0
- package/lru-map-set.test.js.map +1 -0
- package/node/index.d.ts +4 -45
- package/node/index.d.ts.map +1 -0
- package/node/index.js +3 -222
- package/node/index.js.map +1 -1
- package/node/mock-file-service.d.ts +11 -0
- package/node/mock-file-service.d.ts.map +1 -0
- package/node/mock-file-service.js +31 -0
- package/node/mock-file-service.js.map +1 -0
- package/node/mock-file-service.test.d.ts +2 -0
- package/node/mock-file-service.test.d.ts.map +1 -0
- package/node/mock-file-service.test.js +31 -0
- package/node/mock-file-service.test.js.map +1 -0
- package/node/node-basic-sys-abstraction.d.ts +25 -0
- package/node/node-basic-sys-abstraction.d.ts.map +1 -0
- package/node/node-basic-sys-abstraction.js +45 -0
- package/node/node-basic-sys-abstraction.js.map +1 -0
- package/node/node-env-actions.d.ts +15 -0
- package/node/node-env-actions.d.ts.map +1 -0
- package/node/node-env-actions.js +38 -0
- package/node/node-env-actions.js.map +1 -0
- package/node/node-file-service.d.ts +16 -0
- package/node/node-file-service.d.ts.map +1 -0
- package/node/node-file-service.js +72 -0
- package/node/node-file-service.js.map +1 -0
- package/node/node-sys-abstraction.d.ts +19 -0
- package/node/node-sys-abstraction.d.ts.map +1 -0
- package/node/node-sys-abstraction.js +95 -0
- package/node/node-sys-abstraction.js.map +1 -0
- package/node/node-sys-abstraction.test.d.ts +2 -0
- package/node/node-sys-abstraction.test.d.ts.map +1 -0
- package/node/node-sys-abstraction.test.js +83 -0
- package/node/node-sys-abstraction.test.js.map +1 -0
- package/option.d.ts +26 -0
- package/option.d.ts.map +1 -0
- package/option.js +54 -0
- package/option.js.map +1 -0
- package/package.json +4 -10
- package/path-ops.d.ts +7 -0
- package/path-ops.d.ts.map +1 -0
- package/path-ops.js +35 -0
- package/path-ops.js.map +1 -0
- package/path-ops.test.d.ts +2 -0
- package/path-ops.test.d.ts.map +1 -0
- package/path-ops.test.js +39 -0
- package/path-ops.test.js.map +1 -0
- package/resolve-once.d.ts +59 -0
- package/resolve-once.d.ts.map +1 -0
- package/resolve-once.js +212 -0
- package/resolve-once.js.map +1 -0
- package/resolve-once.test.d.ts +2 -0
- package/resolve-once.test.d.ts.map +1 -0
- package/resolve-once.test.js +392 -0
- package/resolve-once.test.js.map +1 -0
- package/result.d.ts +34 -0
- package/result.d.ts.map +1 -0
- package/result.js +94 -0
- package/result.js.map +1 -0
- package/result.test.d.ts +2 -0
- package/result.test.d.ts.map +1 -0
- package/result.test.js +83 -0
- package/result.test.js.map +1 -0
- package/runtime.d.ts +9 -0
- package/runtime.d.ts.map +1 -0
- package/runtime.js +33 -0
- package/runtime.js.map +1 -0
- package/src/jsr.json +1 -1
- package/src/uri.ts +66 -37
- package/sys-abstraction.d.ts +43 -0
- package/sys-abstraction.d.ts.map +1 -0
- package/sys-abstraction.js +28 -0
- package/sys-abstraction.js.map +1 -0
- package/sys-env.d.ts +46 -0
- package/sys-env.d.ts.map +1 -0
- package/sys-env.js +161 -0
- package/sys-env.js.map +1 -0
- package/sys-env.test.d.ts +2 -0
- package/sys-env.test.d.ts.map +1 -0
- package/sys-env.test.js +170 -0
- package/sys-env.test.js.map +1 -0
- package/test/index.d.ts +3 -4
- package/test/index.d.ts.map +1 -0
- package/test/index.js +2 -13
- package/test/index.js.map +1 -1
- package/test/log-write-stream.d.ts +27 -0
- package/test/log-write-stream.d.ts.map +1 -0
- package/test/log-write-stream.js +78 -0
- package/test/log-write-stream.js.map +1 -0
- package/test/mock-logger.d.ts +14 -0
- package/test/mock-logger.d.ts.map +1 -0
- package/test/mock-logger.js +29 -0
- package/test/mock-logger.js.map +1 -0
- package/test/mock-logger.test.d.ts +2 -0
- package/test/mock-logger.test.d.ts.map +1 -0
- package/test/mock-logger.test.js +63 -0
- package/test/mock-logger.test.js.map +1 -0
- package/test/test-exit-handler.d.ts +2 -0
- package/test/test-exit-handler.d.ts.map +1 -0
- package/test/test-exit-handler.js +61 -0
- package/test/test-exit-handler.js.map +1 -0
- package/time.d.ts +14 -0
- package/time.d.ts.map +1 -0
- package/time.js +13 -0
- package/time.js.map +1 -0
- package/tracer.d.ts +59 -0
- package/tracer.d.ts.map +1 -0
- package/tracer.js +174 -0
- package/tracer.js.map +1 -0
- package/tracer.test.d.ts +2 -0
- package/tracer.test.d.ts.map +1 -0
- package/tracer.test.js +304 -0
- package/tracer.test.js.map +1 -0
- package/ts/smoke/smoke.js +1 -1
- package/ts/smoke/smoke.js.map +1 -1
- package/ts/src/base-sys-abstraction.js +20 -8
- package/ts/src/base-sys-abstraction.js.map +1 -1
- package/ts/src/cf/cf-basic-sys-abstraction.js +3 -3
- package/ts/src/cf/cf-basic-sys-abstraction.js.map +1 -1
- package/ts/src/cf/cf-env-actions.js +3 -1
- package/ts/src/cf/cf-env-actions.js.map +1 -1
- package/ts/src/coerce-binary.js +1 -1
- package/ts/src/coerce-binary.js.map +1 -1
- package/ts/src/deno/deno-basic-sys-abstraction.js +3 -3
- package/ts/src/deno/deno-basic-sys-abstraction.js.map +1 -1
- package/ts/src/deno/deno-env-actions.js +3 -9
- package/ts/src/deno/deno-env-actions.js.map +1 -1
- package/ts/src/deno/deno-file-service.js +2 -0
- package/ts/src/deno/deno-file-service.js.map +1 -1
- package/ts/src/deno/deno-sys-abstraction.js +21 -21
- package/ts/src/deno/deno-sys-abstraction.js.map +1 -1
- package/ts/src/future.js +13 -26
- package/ts/src/future.js.map +1 -1
- package/ts/src/http_header.js +2 -3
- package/ts/src/http_header.js.map +1 -1
- package/ts/src/json-en-decoder.js +3 -2
- package/ts/src/json-en-decoder.js.map +1 -1
- package/ts/src/log-level-impl.js +4 -6
- package/ts/src/log-level-impl.js.map +1 -1
- package/ts/src/log-writer-impl.js +9 -5
- package/ts/src/log-writer-impl.js.map +1 -1
- package/ts/src/logger-impl.js +15 -5
- package/ts/src/logger-impl.js.map +1 -1
- package/ts/src/logger.js +3 -3
- package/ts/src/logger.js.map +1 -1
- package/ts/src/logger.test.js +7 -19
- package/ts/src/logger.test.js.map +1 -1
- package/ts/src/lru-map-set.js +3 -1
- package/ts/src/lru-map-set.js.map +1 -1
- package/ts/src/node/mock-file-service.js +1 -4
- package/ts/src/node/mock-file-service.js.map +1 -1
- package/ts/src/node/node-basic-sys-abstraction.js +4 -3
- package/ts/src/node/node-basic-sys-abstraction.js.map +1 -1
- package/ts/src/node/node-env-actions.js +3 -9
- package/ts/src/node/node-env-actions.js.map +1 -1
- package/ts/src/node/node-file-service.js +1 -0
- package/ts/src/node/node-file-service.js.map +1 -1
- package/ts/src/node/node-sys-abstraction.js +21 -21
- package/ts/src/node/node-sys-abstraction.js.map +1 -1
- package/ts/src/option.js +1 -0
- package/ts/src/option.js.map +1 -1
- package/ts/src/path-ops.js +21 -30
- package/ts/src/path-ops.js.map +1 -1
- package/ts/src/resolve-once.js +17 -13
- package/ts/src/resolve-once.js.map +1 -1
- package/ts/src/result.js +2 -0
- package/ts/src/result.js.map +1 -1
- package/ts/src/sys-abstraction.js +1 -1
- package/ts/src/sys-abstraction.js.map +1 -1
- package/ts/src/sys-env.js +2 -1
- package/ts/src/sys-env.js.map +1 -1
- package/ts/src/sys-env.test.js +6 -19
- package/ts/src/sys-env.test.js.map +1 -1
- package/ts/src/test/log-write-stream.js +10 -6
- package/ts/src/test/log-write-stream.js.map +1 -1
- package/ts/src/test/mock-logger.js +6 -6
- package/ts/src/test/mock-logger.js.map +1 -1
- package/ts/src/test/test-exit-handler.js +1 -2
- package/ts/src/test/test-exit-handler.js.map +1 -1
- package/ts/src/tracer.js +10 -3
- package/ts/src/tracer.js.map +1 -1
- package/ts/src/tracer.test.js +5 -9
- package/ts/src/tracer.test.js.map +1 -1
- package/ts/src/txt-en-decoder.js +2 -4
- package/ts/src/txt-en-decoder.js.map +1 -1
- package/ts/src/types.js +2 -6
- package/ts/src/types.js.map +1 -1
- package/ts/src/uri.d.ts +5 -0
- package/ts/src/uri.d.ts.map +1 -1
- package/ts/src/uri.js +57 -34
- package/ts/src/uri.js.map +1 -1
- package/ts/src/uri.test.js +47 -0
- package/ts/src/uri.test.js.map +1 -1
- package/ts/src/utils/console-write-stream.js +8 -5
- package/ts/src/utils/console-write-stream.js.map +1 -1
- package/ts/src/utils/fanout-write-stream.js +4 -1
- package/ts/src/utils/fanout-write-stream.js.map +1 -1
- package/ts/src/utils/rebuffer.test.js +1 -1
- package/ts/src/utils/rebuffer.test.js.map +1 -1
- package/ts/src/utils/relative-path.js +1 -0
- package/ts/src/utils/relative-path.js.map +1 -1
- package/ts/src/utils/stream-map.test.js +1 -1
- package/ts/src/utils/stream-map.test.js.map +1 -1
- package/ts/src/web/web-basic-sys-abstraction.js +3 -3
- package/ts/src/web/web-basic-sys-abstraction.js.map +1 -1
- package/ts/src/web/web-env-actions.js +2 -1
- package/ts/src/web/web-env-actions.js.map +1 -1
- package/txt-en-decoder.d.ts +11 -0
- package/txt-en-decoder.d.ts.map +1 -0
- package/txt-en-decoder.js +37 -0
- package/txt-en-decoder.js.map +1 -0
- package/txt-en-decoder.test.d.ts +2 -0
- package/txt-en-decoder.test.d.ts.map +1 -0
- package/txt-en-decoder.test.js +48 -0
- package/txt-en-decoder.test.js.map +1 -0
- package/types.d.ts +16 -0
- package/types.d.ts.map +1 -0
- package/types.js +11 -0
- package/types.js.map +1 -0
- package/uri.d.ts +137 -0
- package/uri.d.ts.map +1 -0
- package/uri.js +567 -0
- package/uri.js.map +1 -0
- package/uri.test.d.ts +2 -0
- package/uri.test.d.ts.map +1 -0
- package/uri.test.js +633 -0
- package/uri.test.js.map +1 -0
- package/utils/coerce-uint8.d.ts +8 -0
- package/utils/coerce-uint8.d.ts.map +1 -0
- package/utils/coerce-uint8.js +34 -0
- package/utils/coerce-uint8.js.map +1 -0
- package/utils/console-write-stream.d.ts +21 -0
- package/utils/console-write-stream.d.ts.map +1 -0
- package/utils/console-write-stream.js +66 -0
- package/utils/console-write-stream.js.map +1 -0
- package/utils/fanout-write-stream.d.ts +12 -0
- package/utils/fanout-write-stream.d.ts.map +1 -0
- package/utils/fanout-write-stream.js +27 -0
- package/utils/fanout-write-stream.js.map +1 -0
- package/utils/get-params-result.d.ts +8 -0
- package/utils/get-params-result.d.ts.map +1 -0
- package/utils/get-params-result.js +45 -0
- package/utils/get-params-result.js.map +1 -0
- package/utils/index.d.ts +12 -3
- package/utils/index.d.ts.map +1 -0
- package/utils/index.js +11 -50
- package/utils/index.js.map +1 -1
- package/utils/rebuffer.d.ts +3 -0
- package/utils/rebuffer.d.ts.map +1 -0
- package/utils/rebuffer.js +66 -0
- package/utils/rebuffer.js.map +1 -0
- package/utils/rebuffer.test.d.ts +2 -0
- package/utils/rebuffer.test.d.ts.map +1 -0
- package/utils/rebuffer.test.js +77 -0
- package/utils/rebuffer.test.js.map +1 -0
- package/utils/relative-path.d.ts +18 -0
- package/utils/relative-path.d.ts.map +1 -0
- package/utils/relative-path.js +148 -0
- package/utils/relative-path.js.map +1 -0
- package/utils/relative-path.test.d.ts +2 -0
- package/utils/relative-path.test.d.ts.map +1 -0
- package/utils/relative-path.test.js +187 -0
- package/utils/relative-path.test.js.map +1 -0
- package/utils/sorted-objec.test.d.ts +2 -0
- package/utils/sorted-objec.test.d.ts.map +1 -0
- package/utils/sorted-objec.test.js +20 -0
- package/utils/sorted-objec.test.js.map +1 -0
- package/utils/sorted-object.d.ts +4 -0
- package/utils/sorted-object.d.ts.map +1 -0
- package/utils/sorted-object.js +16 -0
- package/utils/sorted-object.js.map +1 -0
- package/utils/stream-map.d.ts +9 -0
- package/utils/stream-map.d.ts.map +1 -0
- package/utils/stream-map.js +63 -0
- package/utils/stream-map.js.map +1 -0
- package/utils/stream-map.test.d.ts +2 -0
- package/utils/stream-map.test.d.ts.map +1 -0
- package/utils/stream-map.test.js +87 -0
- package/utils/stream-map.test.js.map +1 -0
- package/utils/stream-test-helper.d.ts +17 -0
- package/utils/stream-test-helper.d.ts.map +1 -0
- package/utils/stream-test-helper.js +45 -0
- package/utils/stream-test-helper.js.map +1 -0
- package/utils/stream2string.d.ts +3 -0
- package/utils/stream2string.d.ts.map +1 -0
- package/utils/stream2string.js +48 -0
- package/utils/stream2string.js.map +1 -0
- package/utils/stream2string.test.d.ts +2 -0
- package/utils/stream2string.test.d.ts.map +1 -0
- package/utils/stream2string.test.js +29 -0
- package/utils/stream2string.test.js.map +1 -0
- package/utils/string2stream.d.ts +4 -0
- package/utils/string2stream.d.ts.map +1 -0
- package/utils/string2stream.js +13 -0
- package/utils/string2stream.js.map +1 -0
- package/utils/string2stream.test.d.ts +2 -0
- package/utils/string2stream.test.d.ts.map +1 -0
- package/utils/string2stream.test.js +6 -0
- package/utils/string2stream.test.js.map +1 -0
- package/utils/stripper.d.ts +3 -0
- package/utils/stripper.d.ts.map +1 -0
- package/utils/stripper.js +59 -0
- package/utils/stripper.js.map +1 -0
- package/utils/stripper.test.d.ts +2 -0
- package/utils/stripper.test.d.ts.map +1 -0
- package/utils/stripper.test.js +128 -0
- package/utils/stripper.test.js.map +1 -0
- package/utils/uint8array-equal.d.ts +2 -0
- package/utils/uint8array-equal.d.ts.map +1 -0
- package/utils/uint8array-equal.js +12 -0
- package/utils/uint8array-equal.js.map +1 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +4 -0
- package/version.js.map +1 -0
- package/web/index.d.ts +2 -7
- package/web/index.d.ts.map +1 -0
- package/web/index.js +1 -7
- package/web/index.js.map +1 -1
- package/web/web-basic-sys-abstraction.d.ts +4 -0
- package/web/web-basic-sys-abstraction.d.ts.map +1 -0
- package/web/web-basic-sys-abstraction.js +45 -0
- package/web/web-basic-sys-abstraction.js.map +1 -0
- package/web/web-env-actions.d.ts +14 -0
- package/web/web-env-actions.d.ts.map +1 -0
- package/web/web-env-actions.js +36 -0
- package/web/web-env-actions.js.map +1 -0
- package/base-sys-abstraction-DgTynXGV.d.cts +0 -95
- package/cf/index.cjs +0 -1110
- package/cf/index.cjs.map +0 -1
- package/cf/index.d.cts +0 -30
- package/chunk-FOALXQST.js +0 -89
- package/chunk-FOALXQST.js.map +0 -1
- package/chunk-FURW5CDL.js +0 -792
- package/chunk-FURW5CDL.js.map +0 -1
- package/chunk-NJMNJYN2.js +0 -270
- package/chunk-NJMNJYN2.js.map +0 -1
- package/chunk-NTOGMD33.js +0 -684
- package/chunk-NTOGMD33.js.map +0 -1
- package/chunk-O3CWMM7E.js +0 -1678
- package/chunk-O3CWMM7E.js.map +0 -1
- package/deno/index.cjs +0 -1280
- package/deno/index.cjs.map +0 -1
- package/deno/index.d.cts +0 -37
- package/get-params-result-4xHM5s4_.d.cts +0 -71
- package/get-params-result-4xHM5s4_.d.ts +0 -71
- package/index-CMLb7JSe.d.ts +0 -97
- package/index-DL2hPDP5.d.cts +0 -296
- package/index-DTF3tq6t.d.ts +0 -296
- package/index-LQOsS7gM.d.cts +0 -97
- package/index.cjs +0 -4006
- package/index.cjs.map +0 -1
- package/index.d.cts +0 -396
- package/metafile-cjs.json +0 -1
- package/metafile-esm.json +0 -1
- package/node/index.cjs +0 -1335
- package/node/index.cjs.map +0 -1
- package/node/index.d.cts +0 -45
- package/stripper-BpBUUZ9p.d.cts +0 -4
- package/stripper-BpBUUZ9p.d.ts +0 -4
- package/sys-abstraction-CeAxxg9H.d.ts +0 -117
- package/sys-abstraction-DDAwGTnk.d.cts +0 -117
- package/test/index.cjs +0 -2991
- package/test/index.cjs.map +0 -1
- package/test/index.d.cts +0 -4
- package/utils/index.cjs +0 -778
- package/utils/index.cjs.map +0 -1
- package/utils/index.d.cts +0 -3
- package/web/index.cjs +0 -1153
- package/web/index.cjs.map +0 -1
- package/web/index.d.cts +0 -7
package/test/index.cjs
DELETED
@@ -1,2991 +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
|
-
|
37
|
-
// src/test/index.ts
|
38
|
-
var test_exports = {};
|
39
|
-
__export(test_exports, {
|
40
|
-
LogCollector: () => LogCollector,
|
41
|
-
LogWriteStream: () => LogWriteStream,
|
42
|
-
MockLogger: () => MockLogger
|
43
|
-
});
|
44
|
-
module.exports = __toCommonJS(test_exports);
|
45
|
-
|
46
|
-
// src/utils/fanout-write-stream.ts
|
47
|
-
var FanoutWriteStream = class {
|
48
|
-
constructor(writers) {
|
49
|
-
this.desiredSize = null;
|
50
|
-
this._writers = writers;
|
51
|
-
this.ready = Promise.all(this._writers.map((w) => w.ready)).then(() => void 0);
|
52
|
-
this.closed = Promise.all(this._writers.map((w) => w.closed)).then(() => void 0);
|
53
|
-
}
|
54
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
55
|
-
abort(reason) {
|
56
|
-
return Promise.all(this._writers.map((w) => w.abort(reason))).then(() => {
|
57
|
-
});
|
58
|
-
}
|
59
|
-
close() {
|
60
|
-
return Promise.all(this._writers.map((w) => w.close())).then(() => {
|
61
|
-
});
|
62
|
-
}
|
63
|
-
releaseLock() {
|
64
|
-
this._writers.map((w) => w.releaseLock());
|
65
|
-
}
|
66
|
-
write(chunk) {
|
67
|
-
return Promise.all(this._writers.map((w) => w.write(chunk))).then(() => {
|
68
|
-
});
|
69
|
-
}
|
70
|
-
};
|
71
|
-
|
72
|
-
// src/future.ts
|
73
|
-
var _promise, _resolveFn, _rejectFn;
|
74
|
-
var Future = class {
|
75
|
-
constructor() {
|
76
|
-
__privateAdd(this, _promise);
|
77
|
-
__privateAdd(this, _resolveFn, () => {
|
78
|
-
throw new Error("This Promise is not working as expected.");
|
79
|
-
});
|
80
|
-
__privateAdd(this, _rejectFn, () => {
|
81
|
-
throw new Error("This Promise is not working as expected.");
|
82
|
-
});
|
83
|
-
__privateSet(this, _promise, new Promise((resolve, reject) => {
|
84
|
-
__privateSet(this, _resolveFn, resolve);
|
85
|
-
__privateSet(this, _rejectFn, reject);
|
86
|
-
}));
|
87
|
-
}
|
88
|
-
async asPromise() {
|
89
|
-
return __privateGet(this, _promise);
|
90
|
-
}
|
91
|
-
resolve(value) {
|
92
|
-
__privateGet(this, _resolveFn).call(this, value);
|
93
|
-
}
|
94
|
-
reject(reason) {
|
95
|
-
__privateGet(this, _rejectFn).call(this, reason);
|
96
|
-
}
|
97
|
-
};
|
98
|
-
_promise = new WeakMap();
|
99
|
-
_resolveFn = new WeakMap();
|
100
|
-
_rejectFn = new WeakMap();
|
101
|
-
|
102
|
-
// src/lru-map-set.ts
|
103
|
-
var LRUMap = class {
|
104
|
-
constructor(c = {}) {
|
105
|
-
this._map = /* @__PURE__ */ new Map();
|
106
|
-
this.param = {
|
107
|
-
maxEntries: c.maxEntries || 100,
|
108
|
-
maxAge: c.maxAge || 0
|
109
|
-
};
|
110
|
-
}
|
111
|
-
touch(key) {
|
112
|
-
if (!this._map.has(key)) {
|
113
|
-
throw new Error(`key not found in cache: ${key}`);
|
114
|
-
}
|
115
|
-
const value = this._map.get(key);
|
116
|
-
this._map.delete(key);
|
117
|
-
this._map.set(key, value);
|
118
|
-
return value;
|
119
|
-
}
|
120
|
-
setParam(param2 = {}) {
|
121
|
-
if (typeof param2.maxEntries === "number") {
|
122
|
-
this.param.maxEntries = param2.maxEntries;
|
123
|
-
if (param2.maxEntries > 0 && this._map.size > param2.maxEntries) {
|
124
|
-
const toDelete = [];
|
125
|
-
let cacheSize = this._map.size;
|
126
|
-
for (const key of this._map.keys()) {
|
127
|
-
if (cacheSize > param2.maxEntries) {
|
128
|
-
toDelete.push(key);
|
129
|
-
cacheSize--;
|
130
|
-
} else {
|
131
|
-
break;
|
132
|
-
}
|
133
|
-
}
|
134
|
-
for (const key of toDelete) {
|
135
|
-
this._map.delete(key);
|
136
|
-
}
|
137
|
-
}
|
138
|
-
}
|
139
|
-
}
|
140
|
-
has(key) {
|
141
|
-
return this._map.has(key);
|
142
|
-
}
|
143
|
-
get size() {
|
144
|
-
return this._map.size;
|
145
|
-
}
|
146
|
-
async getSet(key, createFN) {
|
147
|
-
const val = this.get(key);
|
148
|
-
if (val) {
|
149
|
-
return val;
|
150
|
-
} else {
|
151
|
-
const val2 = await createFN(key);
|
152
|
-
this.set(key, val2);
|
153
|
-
return val2;
|
154
|
-
}
|
155
|
-
}
|
156
|
-
get(key) {
|
157
|
-
if (this._map.has(key)) {
|
158
|
-
return this.touch(key);
|
159
|
-
}
|
160
|
-
return this._map.get(key);
|
161
|
-
}
|
162
|
-
set(key, value) {
|
163
|
-
this._map.delete(key);
|
164
|
-
if (this.param.maxEntries > 0 && this._map.size >= this.param.maxEntries) {
|
165
|
-
this._map.delete(this._map.keys().next().value);
|
166
|
-
this._map.set(key, value);
|
167
|
-
} else {
|
168
|
-
this._map.set(key, value);
|
169
|
-
}
|
170
|
-
}
|
171
|
-
delete(key) {
|
172
|
-
this._map.delete(key);
|
173
|
-
}
|
174
|
-
clear() {
|
175
|
-
this._map.clear();
|
176
|
-
}
|
177
|
-
forEach(callbackfn) {
|
178
|
-
this._map.forEach(callbackfn);
|
179
|
-
}
|
180
|
-
entries() {
|
181
|
-
return this._map.entries();
|
182
|
-
}
|
183
|
-
// *entries(): IterableIterator<[T, K]> {
|
184
|
-
// for (const x of this._cache.entries()) {
|
185
|
-
// yield x;
|
186
|
-
// }
|
187
|
-
// }
|
188
|
-
// getLeastRecent(): K {
|
189
|
-
// return Array.from(this.cache)[0];
|
190
|
-
// }
|
191
|
-
// getMostRecent(): K {
|
192
|
-
// return Array.from(this.cache)[this.cache.size - 1];
|
193
|
-
// }
|
194
|
-
};
|
195
|
-
|
196
|
-
// src/is-promise.ts
|
197
|
-
function isPromise(a) {
|
198
|
-
const mayBe = a;
|
199
|
-
return mayBe instanceof Promise || !!(mayBe && mayBe !== null && typeof mayBe.then === "function" && typeof mayBe.catch === "function" && typeof mayBe.finally === "function");
|
200
|
-
}
|
201
|
-
|
202
|
-
// src/result.ts
|
203
|
-
var Result = class _Result {
|
204
|
-
static Ok(t) {
|
205
|
-
return new ResultOK(t);
|
206
|
-
}
|
207
|
-
static Err(t) {
|
208
|
-
if (typeof t === "string") {
|
209
|
-
return new ResultError(new Error(t));
|
210
|
-
}
|
211
|
-
if (_Result.Is(t)) {
|
212
|
-
if (t.is_ok()) {
|
213
|
-
return new ResultError(new Error("Result Error is Ok"));
|
214
|
-
}
|
215
|
-
return t;
|
216
|
-
}
|
217
|
-
return new ResultError(t);
|
218
|
-
}
|
219
|
-
static Is(t) {
|
220
|
-
if (!t) {
|
221
|
-
return false;
|
222
|
-
}
|
223
|
-
if (t instanceof _Result) {
|
224
|
-
return true;
|
225
|
-
}
|
226
|
-
const rt = t;
|
227
|
-
if ([typeof rt.is_ok, typeof rt.is_err, typeof rt.unwrap, typeof rt.unwrap_err].every((x) => x === "function")) {
|
228
|
-
return true;
|
229
|
-
}
|
230
|
-
return false;
|
231
|
-
}
|
232
|
-
isOk() {
|
233
|
-
return this.is_ok();
|
234
|
-
}
|
235
|
-
isErr() {
|
236
|
-
return this.is_err();
|
237
|
-
}
|
238
|
-
Ok() {
|
239
|
-
return this.unwrap();
|
240
|
-
}
|
241
|
-
Err() {
|
242
|
-
return this.unwrap_err();
|
243
|
-
}
|
244
|
-
};
|
245
|
-
var ResultOK = class extends Result {
|
246
|
-
constructor(t) {
|
247
|
-
super();
|
248
|
-
this._t = t;
|
249
|
-
}
|
250
|
-
is_ok() {
|
251
|
-
return true;
|
252
|
-
}
|
253
|
-
is_err() {
|
254
|
-
return false;
|
255
|
-
}
|
256
|
-
unwrap_err() {
|
257
|
-
throw new Error("Result is Ok");
|
258
|
-
}
|
259
|
-
unwrap() {
|
260
|
-
return this._t;
|
261
|
-
}
|
262
|
-
};
|
263
|
-
var ResultError = class extends Result {
|
264
|
-
constructor(t) {
|
265
|
-
super();
|
266
|
-
this._error = t;
|
267
|
-
}
|
268
|
-
is_ok() {
|
269
|
-
return false;
|
270
|
-
}
|
271
|
-
is_err() {
|
272
|
-
return true;
|
273
|
-
}
|
274
|
-
unwrap() {
|
275
|
-
throw new Error(`Result is Err: ${this._error}`);
|
276
|
-
}
|
277
|
-
unwrap_err() {
|
278
|
-
return this._error;
|
279
|
-
}
|
280
|
-
};
|
281
|
-
function exception2Result(fn) {
|
282
|
-
try {
|
283
|
-
const res = fn();
|
284
|
-
if (isPromise(res)) {
|
285
|
-
return res.then((value) => Result.Ok(value)).catch((e) => Result.Err(e));
|
286
|
-
}
|
287
|
-
return Result.Ok(res);
|
288
|
-
} catch (e) {
|
289
|
-
return Result.Err(e);
|
290
|
-
}
|
291
|
-
}
|
292
|
-
|
293
|
-
// src/resolve-once.ts
|
294
|
-
var ResolveOnce = class {
|
295
|
-
constructor(ctx) {
|
296
|
-
this._onceDone = false;
|
297
|
-
this._onceFutures = [];
|
298
|
-
this._onceOk = false;
|
299
|
-
this._isPromise = false;
|
300
|
-
this.ctx = ctx;
|
301
|
-
}
|
302
|
-
get ready() {
|
303
|
-
return this._onceDone;
|
304
|
-
}
|
305
|
-
reset() {
|
306
|
-
this._onceDone = false;
|
307
|
-
this._onceOk = false;
|
308
|
-
this._onceValue = void 0;
|
309
|
-
this._onceError = void 0;
|
310
|
-
if (this._inProgress) {
|
311
|
-
const idx = this._onceFutures.findIndex((f) => f === this._inProgress);
|
312
|
-
if (idx >= 0) {
|
313
|
-
this._onceFutures.push(...this._onceFutures.splice(2).slice(1));
|
314
|
-
}
|
315
|
-
} else {
|
316
|
-
this._onceFutures.length = 0;
|
317
|
-
}
|
318
|
-
}
|
319
|
-
// T extends Option<infer U> ? U : T
|
320
|
-
once(fn) {
|
321
|
-
if (this._onceDone) {
|
322
|
-
if (this._onceError) {
|
323
|
-
if (this._isPromise) {
|
324
|
-
return Promise.reject(this._onceError);
|
325
|
-
} else {
|
326
|
-
throw this._onceError;
|
327
|
-
}
|
328
|
-
}
|
329
|
-
if (this._onceOk) {
|
330
|
-
if (this._isPromise) {
|
331
|
-
return Promise.resolve(this._onceValue);
|
332
|
-
} else {
|
333
|
-
return this._onceValue;
|
334
|
-
}
|
335
|
-
}
|
336
|
-
throw new Error("ResolveOnce.once impossible");
|
337
|
-
}
|
338
|
-
const future = new Future();
|
339
|
-
this._onceFutures.push(future);
|
340
|
-
if (this._onceFutures.length === 1) {
|
341
|
-
const okFn = (value) => {
|
342
|
-
this._onceValue = value;
|
343
|
-
this._onceOk = true;
|
344
|
-
this._onceDone = true;
|
345
|
-
if (this._isPromise) {
|
346
|
-
this._onceFutures.forEach((f) => f.resolve(this._onceValue));
|
347
|
-
}
|
348
|
-
this._onceFutures.length = 0;
|
349
|
-
};
|
350
|
-
const catchFn = (e) => {
|
351
|
-
this._onceError = e;
|
352
|
-
this._onceOk = false;
|
353
|
-
this._onceValue = void 0;
|
354
|
-
this._onceDone = true;
|
355
|
-
if (this._isPromise) {
|
356
|
-
this._onceFutures.forEach((f) => f.reject(this._onceError));
|
357
|
-
}
|
358
|
-
this._onceFutures.length = 0;
|
359
|
-
};
|
360
|
-
this._inProgress = future;
|
361
|
-
try {
|
362
|
-
const ret = fn(this.ctx);
|
363
|
-
if (typeof ret.then === "function") {
|
364
|
-
this._isPromise = true;
|
365
|
-
ret.then(okFn).catch(catchFn).finally(() => {
|
366
|
-
this._inProgress = void 0;
|
367
|
-
});
|
368
|
-
} else {
|
369
|
-
okFn(ret);
|
370
|
-
}
|
371
|
-
} catch (e) {
|
372
|
-
catchFn(e);
|
373
|
-
}
|
374
|
-
if (!this._isPromise) {
|
375
|
-
this._inProgress = void 0;
|
376
|
-
}
|
377
|
-
}
|
378
|
-
if (this._isPromise) {
|
379
|
-
return future.asPromise();
|
380
|
-
} else {
|
381
|
-
return this.once(fn);
|
382
|
-
}
|
383
|
-
}
|
384
|
-
};
|
385
|
-
var Keyed = class {
|
386
|
-
constructor(factory, params) {
|
387
|
-
var _a;
|
388
|
-
this.factory = factory;
|
389
|
-
this._map = new LRUMap((_a = params == null ? void 0 : params.lru) != null ? _a : { maxEntries: -1 });
|
390
|
-
}
|
391
|
-
setParam(params) {
|
392
|
-
this._map.setParam(params.lru);
|
393
|
-
}
|
394
|
-
async asyncGet(key) {
|
395
|
-
return this.get(await key());
|
396
|
-
}
|
397
|
-
get(key) {
|
398
|
-
if (typeof key === "function") {
|
399
|
-
key = key();
|
400
|
-
}
|
401
|
-
let keyed = this._map.get(key);
|
402
|
-
if (!keyed) {
|
403
|
-
keyed = this.factory(key);
|
404
|
-
this._map.set(key, keyed);
|
405
|
-
}
|
406
|
-
return keyed;
|
407
|
-
}
|
408
|
-
unget(key) {
|
409
|
-
const keyed = this._map.get(key);
|
410
|
-
keyed == null ? void 0 : keyed.reset();
|
411
|
-
this._map.delete(key);
|
412
|
-
}
|
413
|
-
reset() {
|
414
|
-
this._map.forEach((keyed) => keyed.reset());
|
415
|
-
this._map.clear();
|
416
|
-
}
|
417
|
-
};
|
418
|
-
var KeyedResolvOnce = class extends Keyed {
|
419
|
-
constructor(kp = {}) {
|
420
|
-
super((key) => new ResolveOnce(key), kp);
|
421
|
-
}
|
422
|
-
/**
|
423
|
-
*
|
424
|
-
* @returns The values of the resolved keys
|
425
|
-
*/
|
426
|
-
values() {
|
427
|
-
return Array.from(this._map.entries()).filter(([_, v]) => v._onceDone).map(([k, v]) => {
|
428
|
-
if (v._onceDone) {
|
429
|
-
if (v._onceError) {
|
430
|
-
return {
|
431
|
-
key: k,
|
432
|
-
value: Result.Err(v._onceError)
|
433
|
-
};
|
434
|
-
}
|
435
|
-
return {
|
436
|
-
key: k,
|
437
|
-
value: Result.Ok(v._onceValue)
|
438
|
-
};
|
439
|
-
}
|
440
|
-
throw new Error("KeyedResolvOnce.values impossible");
|
441
|
-
});
|
442
|
-
}
|
443
|
-
};
|
444
|
-
|
445
|
-
// src/utils/coerce-uint8.ts
|
446
|
-
var globalBuffer = globalThis;
|
447
|
-
function coerceIntoUint8(raw) {
|
448
|
-
if (raw instanceof ArrayBuffer) {
|
449
|
-
return Result.Ok(new Uint8Array(raw));
|
450
|
-
}
|
451
|
-
if (ArrayBuffer.isView(raw)) {
|
452
|
-
return Result.Ok(new Uint8Array(raw.buffer, raw.byteOffset, raw.byteLength));
|
453
|
-
}
|
454
|
-
if (raw instanceof Blob) {
|
455
|
-
return Result.Err("Blob not supported");
|
456
|
-
}
|
457
|
-
if (globalBuffer.Buffer && globalBuffer.Buffer.isBuffer(raw)) {
|
458
|
-
return Result.Ok(new Uint8Array(raw.buffer, raw.byteOffset, raw.byteLength));
|
459
|
-
}
|
460
|
-
if (raw instanceof Uint8Array) {
|
461
|
-
return Result.Ok(raw);
|
462
|
-
}
|
463
|
-
if (Result.Is(raw)) {
|
464
|
-
if (raw.isErr()) {
|
465
|
-
return Result.Err(raw);
|
466
|
-
}
|
467
|
-
return coerceIntoUint8(raw.unwrap());
|
468
|
-
}
|
469
|
-
return Result.Err("Not a Uint8Array");
|
470
|
-
}
|
471
|
-
|
472
|
-
// src/txt-en-decoder.ts
|
473
|
-
var TxtOps = class {
|
474
|
-
constructor() {
|
475
|
-
this.encoder = new TextEncoder();
|
476
|
-
this.decoder = new TextDecoder();
|
477
|
-
}
|
478
|
-
encode(str) {
|
479
|
-
return this.encoder.encode(str);
|
480
|
-
}
|
481
|
-
decode(data) {
|
482
|
-
if (Result.Is(data)) {
|
483
|
-
if (data.isErr()) {
|
484
|
-
throw data.Err();
|
485
|
-
}
|
486
|
-
const unwrapped = data.unwrap();
|
487
|
-
if (typeof unwrapped === "string") {
|
488
|
-
return this.decode(unwrapped);
|
489
|
-
}
|
490
|
-
}
|
491
|
-
if (typeof data === "string") {
|
492
|
-
return data;
|
493
|
-
}
|
494
|
-
return this.decoder.decode(coerceIntoUint8(data).Ok());
|
495
|
-
}
|
496
|
-
async asyncDecode(data) {
|
497
|
-
let resolved = await data;
|
498
|
-
if (resolved instanceof Blob) {
|
499
|
-
resolved = await resolved.arrayBuffer();
|
500
|
-
}
|
501
|
-
return this.decode(resolved);
|
502
|
-
}
|
503
|
-
};
|
504
|
-
var txtEnDecoder = new ResolveOnce();
|
505
|
-
function TxtEnDecoderSingleton() {
|
506
|
-
return txtEnDecoder.once(() => new TxtOps());
|
507
|
-
}
|
508
|
-
|
509
|
-
// src/test/log-write-stream.ts
|
510
|
-
var LogWriteStream = class {
|
511
|
-
constructor(bufferArr) {
|
512
|
-
this._resolveClosed = new Future();
|
513
|
-
this.closed = this._resolveClosed.asPromise();
|
514
|
-
this.desiredSize = null;
|
515
|
-
this.ready = Promise.resolve(void 0);
|
516
|
-
this._bufferArr = bufferArr;
|
517
|
-
}
|
518
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
519
|
-
abort(reason) {
|
520
|
-
throw new Error("Method not implemented.");
|
521
|
-
}
|
522
|
-
async close() {
|
523
|
-
await this.closed;
|
524
|
-
return Promise.resolve(void 0);
|
525
|
-
}
|
526
|
-
releaseLock() {
|
527
|
-
}
|
528
|
-
async write(chunk) {
|
529
|
-
if (chunk) {
|
530
|
-
this._bufferArr.push(chunk);
|
531
|
-
}
|
532
|
-
return Promise.resolve(void 0);
|
533
|
-
}
|
534
|
-
};
|
535
|
-
var LogCollector = class {
|
536
|
-
constructor(pass, txtEnDe) {
|
537
|
-
this.locked = false;
|
538
|
-
this._bufferArr = [];
|
539
|
-
this._pass = pass;
|
540
|
-
this._txtEnDe = txtEnDe || TxtEnDecoderSingleton();
|
541
|
-
}
|
542
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
543
|
-
abort(reason) {
|
544
|
-
throw new Error("Method not implemented.");
|
545
|
-
}
|
546
|
-
async close() {
|
547
|
-
if (this._writer) {
|
548
|
-
const ret = await this._writer.close();
|
549
|
-
this._writer = void 0;
|
550
|
-
return ret;
|
551
|
-
}
|
552
|
-
return Promise.resolve(void 0);
|
553
|
-
}
|
554
|
-
getWriter() {
|
555
|
-
if (!this._writer) {
|
556
|
-
const dests = [new LogWriteStream(this._bufferArr)];
|
557
|
-
if (this._pass) {
|
558
|
-
dests.push(this._pass);
|
559
|
-
}
|
560
|
-
this._writer = new FanoutWriteStream(dests);
|
561
|
-
}
|
562
|
-
return this._writer;
|
563
|
-
}
|
564
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
565
|
-
Logs(notJsonLine = false) {
|
566
|
-
if (!this._writer) {
|
567
|
-
return [];
|
568
|
-
}
|
569
|
-
const jsonNlStr = this._txtEnDe.decode(
|
570
|
-
new Uint8Array(
|
571
|
-
function* (res) {
|
572
|
-
for (const x of res) {
|
573
|
-
yield* x;
|
574
|
-
}
|
575
|
-
}(this._bufferArr)
|
576
|
-
)
|
577
|
-
);
|
578
|
-
if (!notJsonLine) {
|
579
|
-
const splitStr = jsonNlStr.split("\n");
|
580
|
-
const filterStr = splitStr.filter((a) => a.length);
|
581
|
-
const mapStr = filterStr.map((a) => JSON.parse(a));
|
582
|
-
return mapStr;
|
583
|
-
}
|
584
|
-
return jsonNlStr.split("\n").filter((a) => a.length);
|
585
|
-
}
|
586
|
-
};
|
587
|
-
|
588
|
-
// src/bin2text.ts
|
589
|
-
function bin2text(hex, lineFn, size = 0) {
|
590
|
-
const arr = new Uint8Array(hex.buffer, hex.byteOffset, hex.byteLength);
|
591
|
-
let cutted = " ";
|
592
|
-
if (size == 0) {
|
593
|
-
size = arr.length;
|
594
|
-
}
|
595
|
-
size = Math.min(size, arr.length);
|
596
|
-
const cols = 16;
|
597
|
-
for (let line = 0; line < size; line += cols) {
|
598
|
-
if (line + cols <= size || arr.length == size) {
|
599
|
-
} else {
|
600
|
-
line = arr.length - arr.length % cols;
|
601
|
-
size = arr.length;
|
602
|
-
cutted = ">>";
|
603
|
-
}
|
604
|
-
const l = [line.toString(16).padStart(4, "0"), cutted];
|
605
|
-
for (let col = 0; col < cols; col++) {
|
606
|
-
if (line + col < size) {
|
607
|
-
l.push(arr[line + col].toString(16).padStart(2, "0"));
|
608
|
-
} else {
|
609
|
-
l.push(" ");
|
610
|
-
}
|
611
|
-
l.push(" ");
|
612
|
-
}
|
613
|
-
for (let col = 0; col < cols; col++) {
|
614
|
-
if (line + col < size) {
|
615
|
-
const ch = arr[line + col];
|
616
|
-
l.push(ch >= 32 && ch < 127 ? String.fromCharCode(ch) : ".");
|
617
|
-
}
|
618
|
-
}
|
619
|
-
lineFn(l.join(""));
|
620
|
-
}
|
621
|
-
}
|
622
|
-
function bin2string(hex, size = 0) {
|
623
|
-
const collector = [];
|
624
|
-
bin2text(
|
625
|
-
hex,
|
626
|
-
(line) => {
|
627
|
-
collector.push(line);
|
628
|
-
},
|
629
|
-
size
|
630
|
-
);
|
631
|
-
return collector.join("\n");
|
632
|
-
}
|
633
|
-
|
634
|
-
// src/logger.ts
|
635
|
-
var Level = {
|
636
|
-
WARN: "warn",
|
637
|
-
DEBUG: "debug",
|
638
|
-
INFO: "info",
|
639
|
-
ERROR: "error"
|
640
|
-
};
|
641
|
-
var LogValue = class {
|
642
|
-
constructor(fn) {
|
643
|
-
this.fn = fn;
|
644
|
-
}
|
645
|
-
value() {
|
646
|
-
try {
|
647
|
-
return this.fn();
|
648
|
-
} catch (e) {
|
649
|
-
return `LogValue:${e.message}`;
|
650
|
-
}
|
651
|
-
}
|
652
|
-
toJSON() {
|
653
|
-
return this.value();
|
654
|
-
}
|
655
|
-
};
|
656
|
-
function logValue(val, ctx) {
|
657
|
-
return logValueInternal(val, {
|
658
|
-
...ctx,
|
659
|
-
state: ctx.state || /* @__PURE__ */ new Set([Math.random()])
|
660
|
-
});
|
661
|
-
}
|
662
|
-
function logValueInternal(val, ctx) {
|
663
|
-
var _a, _b;
|
664
|
-
ctx = {
|
665
|
-
...ctx,
|
666
|
-
state: ctx.state || /* @__PURE__ */ new Set([Math.random()])
|
667
|
-
};
|
668
|
-
switch (typeof val) {
|
669
|
-
case "function":
|
670
|
-
return new LogValue(val);
|
671
|
-
case "string": {
|
672
|
-
try {
|
673
|
-
const ret = JSON.parse(val);
|
674
|
-
if (typeof ret === "object" && ret !== null) {
|
675
|
-
return logValueInternal(ret, ctx);
|
676
|
-
}
|
677
|
-
} catch (e) {
|
678
|
-
try {
|
679
|
-
const url = new URL(val);
|
680
|
-
return new LogValue(() => url.toString());
|
681
|
-
} catch (e2) {
|
682
|
-
}
|
683
|
-
}
|
684
|
-
if (val.match(/[\n\r]/)) {
|
685
|
-
const lines = val.split(/[\n\r]+/).map((v) => v.trim());
|
686
|
-
return new LogValue(() => lines);
|
687
|
-
}
|
688
|
-
return new LogValue(() => val.toString());
|
689
|
-
}
|
690
|
-
case "number":
|
691
|
-
return new LogValue(() => val);
|
692
|
-
case "boolean":
|
693
|
-
return new LogValue(() => val);
|
694
|
-
case "object": {
|
695
|
-
if (val === null) {
|
696
|
-
return new LogValue(() => "null");
|
697
|
-
}
|
698
|
-
if (ArrayBuffer.isView(val)) {
|
699
|
-
try {
|
700
|
-
const decoder = new TextDecoder();
|
701
|
-
const asStr = decoder.decode(val);
|
702
|
-
const obj = JSON.parse(asStr);
|
703
|
-
return logValueInternal(obj, ctx);
|
704
|
-
} catch (e) {
|
705
|
-
return logValueInternal(bin2string(val, 512), ctx);
|
706
|
-
}
|
707
|
-
}
|
708
|
-
if (Array.isArray(val)) {
|
709
|
-
return new LogValue(
|
710
|
-
() => val.map((v) => logValue(v, { ...ctx, state: void 0 }).value())
|
711
|
-
);
|
712
|
-
}
|
713
|
-
if (val instanceof Headers) {
|
714
|
-
return new LogValue(() => Object.fromEntries(val.entries()));
|
715
|
-
}
|
716
|
-
if (val instanceof ReadableStream) {
|
717
|
-
return new LogValue(() => ">Stream<");
|
718
|
-
}
|
719
|
-
if (isPromise(val)) {
|
720
|
-
return new LogValue(() => ">Promise<");
|
721
|
-
}
|
722
|
-
if ((_a = ctx.state) == null ? void 0 : _a.has(val)) {
|
723
|
-
return new LogValue(() => "...");
|
724
|
-
}
|
725
|
-
(_b = ctx.state) == null ? void 0 : _b.add(val);
|
726
|
-
if (typeof val.toJSON === "function") {
|
727
|
-
return new LogValue(() => val.toJSON());
|
728
|
-
}
|
729
|
-
const res = {};
|
730
|
-
const typedVal = val;
|
731
|
-
for (const key in typedVal) {
|
732
|
-
if (ctx.ignoreAttr.IsSome() && ctx.ignoreAttr.unwrap().test(key)) {
|
733
|
-
continue;
|
734
|
-
}
|
735
|
-
const element = typedVal[key];
|
736
|
-
if (element instanceof LogValue) {
|
737
|
-
res[key] = element;
|
738
|
-
} else {
|
739
|
-
if (typeof element !== "function") {
|
740
|
-
res[key] = logValueInternal(element, ctx);
|
741
|
-
}
|
742
|
-
}
|
743
|
-
}
|
744
|
-
return new LogValue(() => res);
|
745
|
-
}
|
746
|
-
default:
|
747
|
-
if (!val) {
|
748
|
-
return new LogValue(() => "--Falsy--");
|
749
|
-
}
|
750
|
-
throw new Error(`Invalid type:${typeof val}`);
|
751
|
-
}
|
752
|
-
}
|
753
|
-
|
754
|
-
// src/option.ts
|
755
|
-
var Option = class _Option {
|
756
|
-
static Some(t) {
|
757
|
-
return new Some(t);
|
758
|
-
}
|
759
|
-
static None() {
|
760
|
-
return new None();
|
761
|
-
}
|
762
|
-
static Is(t) {
|
763
|
-
return t instanceof _Option;
|
764
|
-
}
|
765
|
-
static From(t) {
|
766
|
-
if (!t) {
|
767
|
-
return new None();
|
768
|
-
}
|
769
|
-
return new Some(t);
|
770
|
-
}
|
771
|
-
IsNone() {
|
772
|
-
return this.is_none();
|
773
|
-
}
|
774
|
-
IsSome() {
|
775
|
-
return this.is_some();
|
776
|
-
}
|
777
|
-
Unwrap() {
|
778
|
-
return this.unwrap();
|
779
|
-
}
|
780
|
-
};
|
781
|
-
var Some = class extends Option {
|
782
|
-
constructor(_t) {
|
783
|
-
super();
|
784
|
-
this._t = _t;
|
785
|
-
}
|
786
|
-
is_none() {
|
787
|
-
return false;
|
788
|
-
}
|
789
|
-
is_some() {
|
790
|
-
return true;
|
791
|
-
}
|
792
|
-
unwrap() {
|
793
|
-
return this._t;
|
794
|
-
}
|
795
|
-
};
|
796
|
-
var None = class extends Option {
|
797
|
-
is_none() {
|
798
|
-
return true;
|
799
|
-
}
|
800
|
-
is_some() {
|
801
|
-
return false;
|
802
|
-
}
|
803
|
-
unwrap() {
|
804
|
-
throw new Error("None.unwrap");
|
805
|
-
}
|
806
|
-
};
|
807
|
-
|
808
|
-
// src/log-level-impl.ts
|
809
|
-
var LevelHandlerImpl = class {
|
810
|
-
constructor() {
|
811
|
-
this._globalLevels = /* @__PURE__ */ new Set([Level.INFO, Level.ERROR, Level.WARN]);
|
812
|
-
this._modules = /* @__PURE__ */ new Map();
|
813
|
-
this.ignoreAttr = Option.Some(/^_/);
|
814
|
-
this.isStackExposed = false;
|
815
|
-
}
|
816
|
-
enableLevel(level, ...modules) {
|
817
|
-
if (modules.length == 0) {
|
818
|
-
this._globalLevels.add(level);
|
819
|
-
return;
|
820
|
-
}
|
821
|
-
this.forModules(
|
822
|
-
level,
|
823
|
-
(p) => {
|
824
|
-
this._modules.set(p, /* @__PURE__ */ new Set([...this._globalLevels, level]));
|
825
|
-
},
|
826
|
-
...modules
|
827
|
-
);
|
828
|
-
}
|
829
|
-
disableLevel(level, ...modules) {
|
830
|
-
if (modules.length == 0) {
|
831
|
-
this._globalLevels.delete(level);
|
832
|
-
return;
|
833
|
-
}
|
834
|
-
this.forModules(
|
835
|
-
level,
|
836
|
-
(p) => {
|
837
|
-
this._modules.delete(p);
|
838
|
-
},
|
839
|
-
...modules
|
840
|
-
);
|
841
|
-
}
|
842
|
-
setExposeStack(enable) {
|
843
|
-
this.isStackExposed = !!enable;
|
844
|
-
}
|
845
|
-
setIgnoreAttr(re) {
|
846
|
-
this.ignoreAttr = Option.From(re);
|
847
|
-
}
|
848
|
-
forModules(level, fnAction, ...modules) {
|
849
|
-
for (const m of modules.flat()) {
|
850
|
-
if (typeof m !== "string") {
|
851
|
-
continue;
|
852
|
-
}
|
853
|
-
const parts = m.split(",").map((s) => s.trim()).filter((s) => s.length);
|
854
|
-
for (const p of parts) {
|
855
|
-
fnAction(p);
|
856
|
-
}
|
857
|
-
}
|
858
|
-
}
|
859
|
-
setDebug(...modules) {
|
860
|
-
this.forModules(
|
861
|
-
Level.DEBUG,
|
862
|
-
(p) => {
|
863
|
-
this._modules.set(p, /* @__PURE__ */ new Set([...this._globalLevels, Level.DEBUG]));
|
864
|
-
},
|
865
|
-
...modules
|
866
|
-
);
|
867
|
-
}
|
868
|
-
isEnabled(ilevel, module2) {
|
869
|
-
const level = ilevel;
|
870
|
-
if (typeof module2 === "string") {
|
871
|
-
const levels = this._modules.get(module2);
|
872
|
-
if (levels && levels.has(level)) {
|
873
|
-
return true;
|
874
|
-
}
|
875
|
-
}
|
876
|
-
const wlevel = this._modules.get("*");
|
877
|
-
if (wlevel && typeof level === "string") {
|
878
|
-
if (wlevel.has(level)) {
|
879
|
-
return true;
|
880
|
-
}
|
881
|
-
}
|
882
|
-
if (typeof level !== "string") {
|
883
|
-
return true;
|
884
|
-
}
|
885
|
-
return this._globalLevels.has(level);
|
886
|
-
}
|
887
|
-
};
|
888
|
-
var levelSingleton = new LevelHandlerImpl();
|
889
|
-
function LevelHandlerSingleton() {
|
890
|
-
return levelSingleton;
|
891
|
-
}
|
892
|
-
|
893
|
-
// src/logger-impl.ts
|
894
|
-
var import_yaml = __toESM(require("yaml"), 1);
|
895
|
-
|
896
|
-
// src/types.ts
|
897
|
-
var _Required = class {
|
898
|
-
constructor() {
|
899
|
-
this.type = "REQUIRED";
|
900
|
-
}
|
901
|
-
};
|
902
|
-
var _Optional = class {
|
903
|
-
constructor() {
|
904
|
-
this.type = "OPTIONAL";
|
905
|
-
}
|
906
|
-
};
|
907
|
-
var param = {
|
908
|
-
REQUIRED: new _Required(),
|
909
|
-
OPTIONAL: new _Optional()
|
910
|
-
};
|
911
|
-
|
912
|
-
// src/utils/get-params-result.ts
|
913
|
-
function getParamsResult(keys, getParam) {
|
914
|
-
const keyDef = keys.flat().reduce(
|
915
|
-
(acc, i) => {
|
916
|
-
if (typeof i === "string") {
|
917
|
-
acc.push({ key: i, def: void 0, isOptional: false });
|
918
|
-
} else if (typeof i === "object") {
|
919
|
-
acc.push(
|
920
|
-
...Object.keys(i).map((k) => ({
|
921
|
-
key: k,
|
922
|
-
def: typeof i[k] === "string" ? i[k] : void 0,
|
923
|
-
isOptional: i[k] === param.OPTIONAL
|
924
|
-
}))
|
925
|
-
);
|
926
|
-
}
|
927
|
-
return acc;
|
928
|
-
},
|
929
|
-
[]
|
930
|
-
);
|
931
|
-
const msgFn = keys.find((k) => typeof k === "function") || ((...keys2) => {
|
932
|
-
const msg = keys2.join(",");
|
933
|
-
return `missing parameters: ${msg}`;
|
934
|
-
});
|
935
|
-
const errors = [];
|
936
|
-
const result = {};
|
937
|
-
for (const kd of keyDef) {
|
938
|
-
const val = getParam.getParam(kd.key);
|
939
|
-
if (val === void 0) {
|
940
|
-
if (typeof kd.def === "string") {
|
941
|
-
result[kd.key] = kd.def;
|
942
|
-
} else {
|
943
|
-
if (!kd.isOptional) {
|
944
|
-
errors.push(kd.key);
|
945
|
-
}
|
946
|
-
}
|
947
|
-
} else {
|
948
|
-
result[kd.key] = val;
|
949
|
-
}
|
950
|
-
}
|
951
|
-
if (errors.length) {
|
952
|
-
return Result.Err(msgFn(...errors));
|
953
|
-
}
|
954
|
-
return Result.Ok(result);
|
955
|
-
}
|
956
|
-
|
957
|
-
// src/utils/relative-path.ts
|
958
|
-
var PartType = {
|
959
|
-
Slash: 1,
|
960
|
-
Root: 3,
|
961
|
-
Up: 4,
|
962
|
-
Noop: 8
|
963
|
-
// RootUp = 0x8 /* ../ */,
|
964
|
-
};
|
965
|
-
var Path = class {
|
966
|
-
constructor(parts = []) {
|
967
|
-
this.parts = parts;
|
968
|
-
}
|
969
|
-
toString() {
|
970
|
-
return this.parts.map((part) => {
|
971
|
-
if (typeof part === "string") {
|
972
|
-
return part;
|
973
|
-
} else {
|
974
|
-
switch (part) {
|
975
|
-
case PartType.Slash:
|
976
|
-
case PartType.Root:
|
977
|
-
return "/";
|
978
|
-
case PartType.Up:
|
979
|
-
return "..";
|
980
|
-
default:
|
981
|
-
return part;
|
982
|
-
}
|
983
|
-
}
|
984
|
-
}).join("");
|
985
|
-
}
|
986
|
-
add(part) {
|
987
|
-
if (this.parts.includes(PartType.Root) && part === PartType.Root) {
|
988
|
-
throw new Error("Cannot add absolute part to absolute path");
|
989
|
-
}
|
990
|
-
const last = this.parts[this.parts.length - 1];
|
991
|
-
if (last & PartType.Slash && part === PartType.Slash) {
|
992
|
-
return;
|
993
|
-
}
|
994
|
-
switch (part) {
|
995
|
-
case ".":
|
996
|
-
this.parts.push(PartType.Noop);
|
997
|
-
return;
|
998
|
-
case "..":
|
999
|
-
part = PartType.Up;
|
1000
|
-
}
|
1001
|
-
if (last === PartType.Noop && part === PartType.Slash) {
|
1002
|
-
if (last === PartType.Noop) {
|
1003
|
-
this.parts.pop();
|
1004
|
-
}
|
1005
|
-
return;
|
1006
|
-
}
|
1007
|
-
this.parts.push(part);
|
1008
|
-
}
|
1009
|
-
};
|
1010
|
-
function splitPath(path) {
|
1011
|
-
const p = new Path();
|
1012
|
-
if (path === "") {
|
1013
|
-
return p;
|
1014
|
-
}
|
1015
|
-
for (let count = 0; path.length; count++) {
|
1016
|
-
if (path.match(/^\/+/)) {
|
1017
|
-
if (count === 0) {
|
1018
|
-
p.add(PartType.Root);
|
1019
|
-
} else {
|
1020
|
-
p.add(PartType.Slash);
|
1021
|
-
}
|
1022
|
-
path = path.replace(/^\/+/, "");
|
1023
|
-
} else {
|
1024
|
-
const part = path.replace(/\/.*$/, "");
|
1025
|
-
p.add(part);
|
1026
|
-
path = path.replace(/^[^/]+/, "");
|
1027
|
-
}
|
1028
|
-
}
|
1029
|
-
return p;
|
1030
|
-
}
|
1031
|
-
function pathJoin(...paths) {
|
1032
|
-
let prev = "";
|
1033
|
-
const res = [];
|
1034
|
-
for (let i = 0; i < paths.length; i++) {
|
1035
|
-
const path = paths[i];
|
1036
|
-
if (path === "") {
|
1037
|
-
continue;
|
1038
|
-
}
|
1039
|
-
if (!(prev.endsWith("/") || path.startsWith("/"))) {
|
1040
|
-
if (prev !== "") {
|
1041
|
-
res.push("/");
|
1042
|
-
}
|
1043
|
-
res.push(path);
|
1044
|
-
} else {
|
1045
|
-
res.push(path);
|
1046
|
-
}
|
1047
|
-
prev = path;
|
1048
|
-
}
|
1049
|
-
return res.join("");
|
1050
|
-
}
|
1051
|
-
function relativePath(path, relative) {
|
1052
|
-
const relativeParts = splitPath(relative);
|
1053
|
-
let result;
|
1054
|
-
if (relativeParts.parts[0] === PartType.Root) {
|
1055
|
-
result = relative;
|
1056
|
-
} else {
|
1057
|
-
result = pathJoin(path, relative);
|
1058
|
-
}
|
1059
|
-
const unoptPath = splitPath(result);
|
1060
|
-
const out = [];
|
1061
|
-
let topUp = false;
|
1062
|
-
for (const part of unoptPath.parts) {
|
1063
|
-
switch (part) {
|
1064
|
-
case PartType.Root:
|
1065
|
-
out.push(PartType.Root);
|
1066
|
-
break;
|
1067
|
-
case PartType.Up:
|
1068
|
-
if (out.length && !topUp) {
|
1069
|
-
const last = out.length - 1;
|
1070
|
-
if (typeof out[last] === "string" && out[last - 1] == PartType.Root) {
|
1071
|
-
out.pop();
|
1072
|
-
} else {
|
1073
|
-
out.pop();
|
1074
|
-
out.pop();
|
1075
|
-
}
|
1076
|
-
if (out.length === 0) {
|
1077
|
-
topUp = !topUp ? true : topUp;
|
1078
|
-
out.push(PartType.Up);
|
1079
|
-
}
|
1080
|
-
} else {
|
1081
|
-
out.push(PartType.Up);
|
1082
|
-
}
|
1083
|
-
break;
|
1084
|
-
case PartType.Slash:
|
1085
|
-
if (!(out[out.length - 1] & PartType.Slash)) {
|
1086
|
-
out.push(PartType.Slash);
|
1087
|
-
}
|
1088
|
-
break;
|
1089
|
-
default:
|
1090
|
-
out.push(part);
|
1091
|
-
break;
|
1092
|
-
}
|
1093
|
-
}
|
1094
|
-
return new Path(out).toString();
|
1095
|
-
}
|
1096
|
-
|
1097
|
-
// src/utils/stripper.ts
|
1098
|
-
function stripper(strip, obj) {
|
1099
|
-
const strips = Array.isArray(strip) ? strip : [strip];
|
1100
|
-
const restrips = strips.map((s) => {
|
1101
|
-
if (typeof s === "string") {
|
1102
|
-
const escaped = s.replace(/[-\\[\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\^\\$\\|]/g, "\\$&");
|
1103
|
-
return new RegExp(`^${escaped}$`);
|
1104
|
-
}
|
1105
|
-
return s;
|
1106
|
-
});
|
1107
|
-
return localStripper(void 0, restrips, obj);
|
1108
|
-
}
|
1109
|
-
function localStripper(path, restrips, obj) {
|
1110
|
-
if (typeof obj !== "object" || obj === null) {
|
1111
|
-
return obj;
|
1112
|
-
}
|
1113
|
-
if (Array.isArray(obj)) {
|
1114
|
-
return obj.map((i) => localStripper(path, restrips, i));
|
1115
|
-
}
|
1116
|
-
const ret = { ...obj };
|
1117
|
-
const matcher = (key, nextPath) => {
|
1118
|
-
for (const re of restrips) {
|
1119
|
-
if (re.test(key) || re.test(nextPath)) {
|
1120
|
-
return true;
|
1121
|
-
}
|
1122
|
-
}
|
1123
|
-
return false;
|
1124
|
-
};
|
1125
|
-
for (const key in ret) {
|
1126
|
-
if (Object.prototype.hasOwnProperty.call(ret, key)) {
|
1127
|
-
let nextPath;
|
1128
|
-
if (path) {
|
1129
|
-
nextPath = [path, key].join(".");
|
1130
|
-
} else {
|
1131
|
-
nextPath = key;
|
1132
|
-
}
|
1133
|
-
if (matcher(key, nextPath)) {
|
1134
|
-
delete ret[key];
|
1135
|
-
continue;
|
1136
|
-
}
|
1137
|
-
if (typeof ret[key] === "object") {
|
1138
|
-
if (Array.isArray(ret[key])) {
|
1139
|
-
ret[key] = ret[key].reduce((acc, v, i) => {
|
1140
|
-
const toDelete = matcher(key, `${nextPath}[${i}]`);
|
1141
|
-
if (!toDelete) {
|
1142
|
-
acc.push(localStripper(`${nextPath}[${i}]`, restrips, v));
|
1143
|
-
}
|
1144
|
-
return acc;
|
1145
|
-
}, []);
|
1146
|
-
} else {
|
1147
|
-
ret[key] = localStripper(nextPath, restrips, ret[key]);
|
1148
|
-
}
|
1149
|
-
}
|
1150
|
-
}
|
1151
|
-
}
|
1152
|
-
return ret;
|
1153
|
-
}
|
1154
|
-
|
1155
|
-
// src/uri.ts
|
1156
|
-
function match(iref, ioth) {
|
1157
|
-
const mr = {
|
1158
|
-
score: 0,
|
1159
|
-
protocol: false,
|
1160
|
-
hostname: false,
|
1161
|
-
port: false,
|
1162
|
-
pathname: false,
|
1163
|
-
pathParts: [],
|
1164
|
-
params: {}
|
1165
|
-
};
|
1166
|
-
const ref = URI.from(iref);
|
1167
|
-
const oth = URI.from(ioth);
|
1168
|
-
if (ref.protocol === oth.protocol) {
|
1169
|
-
mr.score += 1;
|
1170
|
-
mr.protocol = true;
|
1171
|
-
}
|
1172
|
-
try {
|
1173
|
-
const refH = ref.hostname;
|
1174
|
-
const refP = ref.port;
|
1175
|
-
if (refH === oth.hostname) {
|
1176
|
-
mr.score += 1;
|
1177
|
-
mr.hostname = true;
|
1178
|
-
}
|
1179
|
-
if (refP.length && refP === oth.port) {
|
1180
|
-
mr.score += 1;
|
1181
|
-
mr.port = true;
|
1182
|
-
}
|
1183
|
-
} catch (e) {
|
1184
|
-
}
|
1185
|
-
if (ref.pathname.length && ref.pathname !== "/") {
|
1186
|
-
const pref = ref.pathname.split("/").filter((p) => p.length);
|
1187
|
-
const poth = oth.pathname.split("/").filter((p) => p.length);
|
1188
|
-
for (let i = 0; i < pref.length && i < poth.length; i++) {
|
1189
|
-
if (poth[i] === pref[i]) {
|
1190
|
-
mr.score += 1;
|
1191
|
-
mr.pathname = true;
|
1192
|
-
mr.pathParts.push(pref[i]);
|
1193
|
-
}
|
1194
|
-
}
|
1195
|
-
}
|
1196
|
-
for (const [key, value] of ref.getParams) {
|
1197
|
-
if (oth.getParam(key) === value) {
|
1198
|
-
mr.score += 1;
|
1199
|
-
mr.params[key] = value;
|
1200
|
-
}
|
1201
|
-
}
|
1202
|
-
return mr;
|
1203
|
-
}
|
1204
|
-
function coerceKey(key, def) {
|
1205
|
-
if (typeof key === "object") {
|
1206
|
-
const keys = Object.keys(key);
|
1207
|
-
if (keys.length !== 1) {
|
1208
|
-
throw new Error(`Invalid key: ${JSON.stringify(key)}`);
|
1209
|
-
}
|
1210
|
-
return { key: keys[0], def: key[keys[0]] };
|
1211
|
-
}
|
1212
|
-
return { key, def };
|
1213
|
-
}
|
1214
|
-
function resolveHash(hash) {
|
1215
|
-
const searchParams = new URLSearchParams(hash.replace(/^#/, ""));
|
1216
|
-
return {
|
1217
|
-
getParam: (k) => {
|
1218
|
-
const ret = searchParams.get(k);
|
1219
|
-
return ret === null ? void 0 : ret;
|
1220
|
-
}
|
1221
|
-
};
|
1222
|
-
}
|
1223
|
-
function falsy2undef(value) {
|
1224
|
-
return value === void 0 || value === null ? void 0 : value;
|
1225
|
-
}
|
1226
|
-
function ensureURLWithDefaultProto(url, defaultProtocol) {
|
1227
|
-
if (!url) {
|
1228
|
-
return new MutableURL(`${defaultProtocol}//`);
|
1229
|
-
}
|
1230
|
-
if (typeof url === "string") {
|
1231
|
-
try {
|
1232
|
-
return new MutableURL(url);
|
1233
|
-
} catch (e) {
|
1234
|
-
return new MutableURL(`${defaultProtocol}//${url}`);
|
1235
|
-
}
|
1236
|
-
} else {
|
1237
|
-
return new MutableURL(url.toString());
|
1238
|
-
}
|
1239
|
-
}
|
1240
|
-
function isURL(value) {
|
1241
|
-
return value instanceof URL || !!value && typeof value.searchParams === "object" && typeof value.searchParams.sort === "function" && typeof value.hash === "string";
|
1242
|
-
}
|
1243
|
-
var customInspectSymbol = Symbol.for("nodejs.util.inspect.custom");
|
1244
|
-
var MutableURL = class _MutableURL extends URL {
|
1245
|
-
// override readonly hash: string;
|
1246
|
-
constructor(urlStr) {
|
1247
|
-
super("defect://does.not.exist");
|
1248
|
-
const partedURL = urlStr.split(":");
|
1249
|
-
this._hasHostpart = hasHostPartProtocols.has(partedURL[0]);
|
1250
|
-
let hostPartUrl = ["http", ...partedURL.slice(1)].join(":");
|
1251
|
-
if (!this._hasHostpart) {
|
1252
|
-
const pathname = hostPartUrl.replace(/http:\/\/[/]*/, "").replace(/[#?].*$/, "");
|
1253
|
-
hostPartUrl = hostPartUrl.replace(/http:\/\//, `http://localhost/${pathname}`);
|
1254
|
-
}
|
1255
|
-
try {
|
1256
|
-
this._sysURL = new URL(hostPartUrl);
|
1257
|
-
} catch (ie) {
|
1258
|
-
const e = ie;
|
1259
|
-
e.message = `${e.message} for URL: ${urlStr}`;
|
1260
|
-
throw e;
|
1261
|
-
}
|
1262
|
-
this._protocol = `${partedURL[0]}:`;
|
1263
|
-
if (this._hasHostpart) {
|
1264
|
-
this._pathname = this._sysURL.pathname;
|
1265
|
-
} else {
|
1266
|
-
this._pathname = urlStr.replace(new RegExp(`^${this._protocol}//`), "").replace(/[#?].*$/, "");
|
1267
|
-
}
|
1268
|
-
}
|
1269
|
-
[customInspectSymbol]() {
|
1270
|
-
return this.toString();
|
1271
|
-
}
|
1272
|
-
clone() {
|
1273
|
-
return new _MutableURL(this.toString());
|
1274
|
-
}
|
1275
|
-
get host() {
|
1276
|
-
if (!this._hasHostpart) {
|
1277
|
-
throw new Error(
|
1278
|
-
`you can use hostname only if protocol is ${this.toString()} ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`
|
1279
|
-
);
|
1280
|
-
}
|
1281
|
-
return this._sysURL.host;
|
1282
|
-
}
|
1283
|
-
get port() {
|
1284
|
-
if (!this._hasHostpart) {
|
1285
|
-
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);
|
1286
|
-
}
|
1287
|
-
return this._sysURL.port;
|
1288
|
-
}
|
1289
|
-
set port(p) {
|
1290
|
-
if (!this._hasHostpart) {
|
1291
|
-
throw new Error(`you can use port only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);
|
1292
|
-
}
|
1293
|
-
this._sysURL.port = p;
|
1294
|
-
}
|
1295
|
-
get hostname() {
|
1296
|
-
if (!this._hasHostpart) {
|
1297
|
-
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);
|
1298
|
-
}
|
1299
|
-
return this._sysURL.hostname;
|
1300
|
-
}
|
1301
|
-
set hostname(h) {
|
1302
|
-
if (!this._hasHostpart) {
|
1303
|
-
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);
|
1304
|
-
}
|
1305
|
-
this._sysURL.hostname = h;
|
1306
|
-
}
|
1307
|
-
set pathname(p) {
|
1308
|
-
this._pathname = p;
|
1309
|
-
}
|
1310
|
-
get pathname() {
|
1311
|
-
return this._pathname;
|
1312
|
-
}
|
1313
|
-
get protocol() {
|
1314
|
-
return this._protocol;
|
1315
|
-
}
|
1316
|
-
set protocol(p) {
|
1317
|
-
if (!p.endsWith(":")) {
|
1318
|
-
p = `${p}:`;
|
1319
|
-
}
|
1320
|
-
this._protocol = p;
|
1321
|
-
}
|
1322
|
-
get hash() {
|
1323
|
-
return this._sysURL.hash;
|
1324
|
-
}
|
1325
|
-
set hash(h) {
|
1326
|
-
this._sysURL.hash = h;
|
1327
|
-
}
|
1328
|
-
get searchParams() {
|
1329
|
-
return this._sysURL.searchParams;
|
1330
|
-
}
|
1331
|
-
get search() {
|
1332
|
-
let search = "";
|
1333
|
-
if (this._sysURL.searchParams.size) {
|
1334
|
-
for (const [key, value] of Array.from(this._sysURL.searchParams.entries()).sort((a, b) => a[0].localeCompare(b[0]))) {
|
1335
|
-
search += `${!search.length ? "?" : "&"}${key}=${encodeURIComponent(value)}`;
|
1336
|
-
}
|
1337
|
-
}
|
1338
|
-
return search;
|
1339
|
-
}
|
1340
|
-
toString() {
|
1341
|
-
const search = this.search;
|
1342
|
-
let hostpart = "";
|
1343
|
-
if (this._hasHostpart) {
|
1344
|
-
hostpart = this._sysURL.hostname;
|
1345
|
-
if (this._sysURL.port) {
|
1346
|
-
hostpart += `:${this._sysURL.port}`;
|
1347
|
-
}
|
1348
|
-
if (!this._pathname.startsWith("/")) {
|
1349
|
-
hostpart += "/";
|
1350
|
-
}
|
1351
|
-
}
|
1352
|
-
return `${this._protocol}//${hostpart}${this._pathname}${search}${this.hash}`;
|
1353
|
-
}
|
1354
|
-
};
|
1355
|
-
function from(fac, strURLUri, defaultProtocol) {
|
1356
|
-
switch (typeof falsy2undef(strURLUri)) {
|
1357
|
-
case "undefined":
|
1358
|
-
return fac(new MutableURL(`${defaultProtocol}///`));
|
1359
|
-
case "string":
|
1360
|
-
return fac(ensureURLWithDefaultProto(strURLUri, defaultProtocol));
|
1361
|
-
case "object":
|
1362
|
-
if (BuildURI.is(strURLUri)) {
|
1363
|
-
return fac(new MutableURL(strURLUri._url.toString()));
|
1364
|
-
} else if (URI.is(strURLUri)) {
|
1365
|
-
return fac(new MutableURL(strURLUri._url.toString()));
|
1366
|
-
} else if (isURL(strURLUri)) {
|
1367
|
-
return fac(new MutableURL(strURLUri.toString()));
|
1368
|
-
}
|
1369
|
-
throw new Error(`unknown object type: ${strURLUri}`);
|
1370
|
-
default:
|
1371
|
-
throw new Error(`Invalid argument: ${typeof strURLUri}`);
|
1372
|
-
}
|
1373
|
-
}
|
1374
|
-
function getParamResult(key, val, msgFn = (key2) => {
|
1375
|
-
return `missing parameter: ${key2}`;
|
1376
|
-
}) {
|
1377
|
-
if (val === void 0) {
|
1378
|
-
return Result.Err(msgFn(key));
|
1379
|
-
}
|
1380
|
-
return Result.Ok(val);
|
1381
|
-
}
|
1382
|
-
var BuildURI = class _BuildURI {
|
1383
|
-
// pathname needs this
|
1384
|
-
constructor(url) {
|
1385
|
-
this._url = url;
|
1386
|
-
}
|
1387
|
-
static is(value) {
|
1388
|
-
return value instanceof _BuildURI || !!value && typeof value.delParam === "function" && typeof value.setParam === "function";
|
1389
|
-
}
|
1390
|
-
static from(strURLUri, defaultProtocol = "file:") {
|
1391
|
-
return from((url) => new _BuildURI(url), strURLUri, defaultProtocol);
|
1392
|
-
}
|
1393
|
-
match(other) {
|
1394
|
-
return match(this.URI(), URI.from(other));
|
1395
|
-
}
|
1396
|
-
port(p) {
|
1397
|
-
this._url.port = p;
|
1398
|
-
return this;
|
1399
|
-
}
|
1400
|
-
hostname(h) {
|
1401
|
-
this._url.hostname = h;
|
1402
|
-
return this;
|
1403
|
-
}
|
1404
|
-
protocol(p) {
|
1405
|
-
if (!p.endsWith(":")) {
|
1406
|
-
p = `${p}:`;
|
1407
|
-
}
|
1408
|
-
this._url.protocol = p;
|
1409
|
-
return this;
|
1410
|
-
}
|
1411
|
-
pathname(p) {
|
1412
|
-
this._url.pathname = p;
|
1413
|
-
return this;
|
1414
|
-
}
|
1415
|
-
hash(h) {
|
1416
|
-
this._url.hash = h;
|
1417
|
-
return this;
|
1418
|
-
}
|
1419
|
-
// could pass a relative path or a full URL
|
1420
|
-
// if relative path, it will be appended to the current path
|
1421
|
-
resolve(p) {
|
1422
|
-
if (!p) {
|
1423
|
-
return this;
|
1424
|
-
}
|
1425
|
-
if (typeof p === "string") {
|
1426
|
-
if (!p.match(/^[a-zA-Z0-9]+:/)) {
|
1427
|
-
if (p.startsWith("/")) {
|
1428
|
-
this.pathname(p);
|
1429
|
-
return this;
|
1430
|
-
}
|
1431
|
-
return this.appendRelative(p);
|
1432
|
-
}
|
1433
|
-
}
|
1434
|
-
this._url = new MutableURL(p.toString());
|
1435
|
-
return this;
|
1436
|
-
}
|
1437
|
-
appendRelative(p) {
|
1438
|
-
const appendUrl = URI.from(p);
|
1439
|
-
const pathname = "./" + appendUrl.pathname;
|
1440
|
-
const basePath = this._url.pathname;
|
1441
|
-
this.pathname(relativePath(basePath, pathname));
|
1442
|
-
for (const [key, value] of appendUrl.getParams) {
|
1443
|
-
this.setParam(key, value);
|
1444
|
-
}
|
1445
|
-
return this;
|
1446
|
-
}
|
1447
|
-
cleanParams(...remove) {
|
1448
|
-
const keys = new Set(remove.flat());
|
1449
|
-
for (const key of Array.from(this._url.searchParams.keys())) {
|
1450
|
-
if (keys.size === 0 || keys.has(key)) {
|
1451
|
-
this._url.searchParams.delete(key);
|
1452
|
-
}
|
1453
|
-
}
|
1454
|
-
return this;
|
1455
|
-
}
|
1456
|
-
hashParams(val, mode = "reset") {
|
1457
|
-
let preset;
|
1458
|
-
switch (mode) {
|
1459
|
-
case "reset":
|
1460
|
-
this._url.hash = "";
|
1461
|
-
preset = {};
|
1462
|
-
break;
|
1463
|
-
case "merge":
|
1464
|
-
default:
|
1465
|
-
preset = Object.fromEntries(new URLSearchParams(this._url.hash.replace(/^#/, "")).entries());
|
1466
|
-
break;
|
1467
|
-
}
|
1468
|
-
const out = new URLSearchParams("");
|
1469
|
-
for (const [key, value] of Object.entries({ ...preset, ...val }).sort((a, b) => a[0].localeCompare(b[0]))) {
|
1470
|
-
switch (typeof value) {
|
1471
|
-
case "string":
|
1472
|
-
out.set(key, value);
|
1473
|
-
break;
|
1474
|
-
case "number":
|
1475
|
-
out.set(key, value.toString());
|
1476
|
-
break;
|
1477
|
-
case "boolean":
|
1478
|
-
out.set(key, value ? "true" : "false");
|
1479
|
-
break;
|
1480
|
-
default:
|
1481
|
-
if (value instanceof Date) {
|
1482
|
-
out.set(key, value.toISOString());
|
1483
|
-
} else {
|
1484
|
-
console.error(`unsupported type: ${typeof value} ignore key: ${key}`);
|
1485
|
-
}
|
1486
|
-
break;
|
1487
|
-
}
|
1488
|
-
}
|
1489
|
-
this._url.hash = out.toString();
|
1490
|
-
return this;
|
1491
|
-
}
|
1492
|
-
delParam(key) {
|
1493
|
-
this._url.searchParams.delete(key);
|
1494
|
-
return this;
|
1495
|
-
}
|
1496
|
-
defParam(key, str) {
|
1497
|
-
if (!this._url.searchParams.has(key)) {
|
1498
|
-
this._url.searchParams.set(key, str);
|
1499
|
-
}
|
1500
|
-
return this;
|
1501
|
-
}
|
1502
|
-
setParam(key, str) {
|
1503
|
-
this._url.searchParams.set(key, str);
|
1504
|
-
return this;
|
1505
|
-
}
|
1506
|
-
hasParam(key) {
|
1507
|
-
return this._url.searchParams.has(key);
|
1508
|
-
}
|
1509
|
-
get getParams() {
|
1510
|
-
return this._url.searchParams.entries();
|
1511
|
-
}
|
1512
|
-
getParam(key, def) {
|
1513
|
-
const { key: k, def: d } = coerceKey(key, def);
|
1514
|
-
let val = this._url.searchParams.get(k);
|
1515
|
-
if (!falsy2undef(val) && d) {
|
1516
|
-
val = d;
|
1517
|
-
}
|
1518
|
-
return falsy2undef(val);
|
1519
|
-
}
|
1520
|
-
getParamResult(key, msgFn) {
|
1521
|
-
return getParamResult(key, this.getParam(key), msgFn);
|
1522
|
-
}
|
1523
|
-
getParamsResult(...keys) {
|
1524
|
-
return getParamsResult(keys, this);
|
1525
|
-
}
|
1526
|
-
getHashParams(...keys) {
|
1527
|
-
return getParamsResult(keys, resolveHash(this._url.hash));
|
1528
|
-
}
|
1529
|
-
toString() {
|
1530
|
-
this._url.searchParams.sort();
|
1531
|
-
return this._url.toString();
|
1532
|
-
}
|
1533
|
-
toJSON() {
|
1534
|
-
return this.toString();
|
1535
|
-
}
|
1536
|
-
asURL() {
|
1537
|
-
return this.URI().asURL();
|
1538
|
-
}
|
1539
|
-
asObj(...strips) {
|
1540
|
-
return this.URI().asObj(...strips);
|
1541
|
-
}
|
1542
|
-
clone() {
|
1543
|
-
return _BuildURI.from(this.toString());
|
1544
|
-
}
|
1545
|
-
URI() {
|
1546
|
-
return URI.from(this._url);
|
1547
|
-
}
|
1548
|
-
};
|
1549
|
-
var hasHostPartProtocols = /* @__PURE__ */ new Set(["http", "https", "ws", "wss"]);
|
1550
|
-
var URI = class _URI {
|
1551
|
-
static protocolHasHostpart(protocol) {
|
1552
|
-
protocol = protocol.replace(/:$/, "");
|
1553
|
-
hasHostPartProtocols.add(protocol);
|
1554
|
-
return () => {
|
1555
|
-
hasHostPartProtocols.delete(protocol);
|
1556
|
-
};
|
1557
|
-
}
|
1558
|
-
match(other) {
|
1559
|
-
return match(this, other);
|
1560
|
-
}
|
1561
|
-
// if no protocol is provided, default to file:
|
1562
|
-
static merge(into, from2, defaultProtocol = "file:") {
|
1563
|
-
const intoUrl = BuildURI.from(into, defaultProtocol);
|
1564
|
-
const fromUrl = _URI.from(from2, defaultProtocol);
|
1565
|
-
intoUrl.protocol(fromUrl.protocol);
|
1566
|
-
const fPath = fromUrl.pathname;
|
1567
|
-
if (!(fPath.length === 0 || fPath === "/" || fPath === "./")) {
|
1568
|
-
intoUrl.pathname(fromUrl.pathname);
|
1569
|
-
}
|
1570
|
-
for (const [key, value] of fromUrl.getParams) {
|
1571
|
-
intoUrl.setParam(key, value);
|
1572
|
-
}
|
1573
|
-
return intoUrl.URI();
|
1574
|
-
}
|
1575
|
-
static is(value) {
|
1576
|
-
return value instanceof _URI || !!value && typeof value.asURL === "function" && typeof value.getParam === "function" && typeof value.hasParam === "function";
|
1577
|
-
}
|
1578
|
-
// if no protocol is provided, default to file:
|
1579
|
-
static from(strURLUri, defaultProtocol = "file:") {
|
1580
|
-
return from((url) => new _URI(url), strURLUri, defaultProtocol);
|
1581
|
-
}
|
1582
|
-
static fromResult(strURLUri, defaultProtocol = "file:") {
|
1583
|
-
return exception2Result(() => from((url) => new _URI(url), strURLUri, defaultProtocol));
|
1584
|
-
}
|
1585
|
-
constructor(url) {
|
1586
|
-
this._url = url.clone();
|
1587
|
-
}
|
1588
|
-
build() {
|
1589
|
-
return BuildURI.from(this._url);
|
1590
|
-
}
|
1591
|
-
get hostname() {
|
1592
|
-
return this._url.hostname;
|
1593
|
-
}
|
1594
|
-
get onlyHostAndSchema() {
|
1595
|
-
return this.build().pathname("").cleanParams().hash("").toString();
|
1596
|
-
}
|
1597
|
-
get withoutHostAndSchema() {
|
1598
|
-
return this._url.pathname + this._url.search + this._url.hash;
|
1599
|
-
}
|
1600
|
-
// get password(): string {
|
1601
|
-
// return this._url.password;
|
1602
|
-
// }
|
1603
|
-
get port() {
|
1604
|
-
return this._url.port;
|
1605
|
-
}
|
1606
|
-
get host() {
|
1607
|
-
return this._url.host;
|
1608
|
-
}
|
1609
|
-
// get username(): string {
|
1610
|
-
// return this._url.username;
|
1611
|
-
// }
|
1612
|
-
// get search(): string {
|
1613
|
-
// return this._url.search;
|
1614
|
-
// }
|
1615
|
-
get protocol() {
|
1616
|
-
return this._url.protocol;
|
1617
|
-
}
|
1618
|
-
get pathname() {
|
1619
|
-
return this._url.pathname;
|
1620
|
-
}
|
1621
|
-
get hash() {
|
1622
|
-
return this._url.hash;
|
1623
|
-
}
|
1624
|
-
// get host(): string {
|
1625
|
-
// return this._url.host;
|
1626
|
-
// }
|
1627
|
-
get getParams() {
|
1628
|
-
return this._url.searchParams.entries();
|
1629
|
-
}
|
1630
|
-
hasParam(key) {
|
1631
|
-
return this._url.searchParams.has(key);
|
1632
|
-
}
|
1633
|
-
getParam(key, def) {
|
1634
|
-
const { key: k, def: d } = coerceKey(key, def);
|
1635
|
-
let val = this._url.searchParams.get(k);
|
1636
|
-
if (!falsy2undef(val) && d) {
|
1637
|
-
val = d;
|
1638
|
-
}
|
1639
|
-
return falsy2undef(val);
|
1640
|
-
}
|
1641
|
-
getParamResult(key, msgFn) {
|
1642
|
-
return getParamResult(key, this.getParam(key), msgFn);
|
1643
|
-
}
|
1644
|
-
getParamsResult(...keys) {
|
1645
|
-
return getParamsResult(keys, this);
|
1646
|
-
}
|
1647
|
-
getHashParams(...keys) {
|
1648
|
-
return getParamsResult(keys, resolveHash(this._url.hash));
|
1649
|
-
}
|
1650
|
-
clone() {
|
1651
|
-
return new _URI(this._url);
|
1652
|
-
}
|
1653
|
-
asURL() {
|
1654
|
-
return this._url.clone();
|
1655
|
-
}
|
1656
|
-
toString() {
|
1657
|
-
return this._url.toString();
|
1658
|
-
}
|
1659
|
-
toJSON() {
|
1660
|
-
return this.toString();
|
1661
|
-
}
|
1662
|
-
asObj(...strips) {
|
1663
|
-
const pathURI = {
|
1664
|
-
style: "path",
|
1665
|
-
protocol: this.protocol,
|
1666
|
-
pathname: this.pathname,
|
1667
|
-
searchParams: Object.fromEntries(this.getParams)
|
1668
|
-
};
|
1669
|
-
if (hasHostPartProtocols.has(this.protocol.replace(/:$/, ""))) {
|
1670
|
-
return stripper(strips, {
|
1671
|
-
...pathURI,
|
1672
|
-
style: "host",
|
1673
|
-
hostname: this.hostname,
|
1674
|
-
port: this.port
|
1675
|
-
});
|
1676
|
-
}
|
1677
|
-
return stripper(strips, pathURI);
|
1678
|
-
}
|
1679
|
-
};
|
1680
|
-
|
1681
|
-
// src/runtime.ts
|
1682
|
-
function isSet(value, ref = globalThis) {
|
1683
|
-
const [head, ...tail] = value.split(".");
|
1684
|
-
if (["object", "function"].includes(typeof ref) && ref && ["object", "function"].includes(typeof ref[head]) && ref[head]) {
|
1685
|
-
if (tail.length <= 1) {
|
1686
|
-
return true;
|
1687
|
-
}
|
1688
|
-
return isSet(tail.join("."), ref[head]);
|
1689
|
-
}
|
1690
|
-
return false;
|
1691
|
-
}
|
1692
|
-
function runtimeFn() {
|
1693
|
-
const gt = globalThis;
|
1694
|
-
let isReactNative = (
|
1695
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
1696
|
-
isSet("navigator.product") && typeof gt["navigator"] === "object" && gt["navigator"]["product"] === "ReactNative"
|
1697
|
-
);
|
1698
|
-
let isNodeIsh = false;
|
1699
|
-
if (!isSet("Deno")) {
|
1700
|
-
isNodeIsh = isSet("process.versions.node") && !isReactNative;
|
1701
|
-
}
|
1702
|
-
let isDeno = isSet("Deno");
|
1703
|
-
const isCFWorker = isSet("caches.default") && isSet("WebSocketPair");
|
1704
|
-
if (isCFWorker) {
|
1705
|
-
isDeno = false;
|
1706
|
-
isNodeIsh = false;
|
1707
|
-
isReactNative = false;
|
1708
|
-
}
|
1709
|
-
return {
|
1710
|
-
isNodeIsh,
|
1711
|
-
isBrowser: !(isNodeIsh || isDeno || isCFWorker || isReactNative),
|
1712
|
-
isDeno,
|
1713
|
-
isReactNative,
|
1714
|
-
isCFWorker
|
1715
|
-
};
|
1716
|
-
}
|
1717
|
-
|
1718
|
-
// src/sys-abstraction.ts
|
1719
|
-
var TimeMode = {
|
1720
|
-
REAL: "real",
|
1721
|
-
CONST: "const",
|
1722
|
-
STEP: "step"
|
1723
|
-
};
|
1724
|
-
var RandomMode = {
|
1725
|
-
CONST: "const",
|
1726
|
-
STEP: "step",
|
1727
|
-
RANDOM: "random"
|
1728
|
-
};
|
1729
|
-
var IDMode = {
|
1730
|
-
UUID: "uuid",
|
1731
|
-
CONST: "const",
|
1732
|
-
STEP: "step"
|
1733
|
-
};
|
1734
|
-
|
1735
|
-
// src/time.ts
|
1736
|
-
var Time = class {
|
1737
|
-
TimeSince(start) {
|
1738
|
-
const now = this.Now();
|
1739
|
-
return now.getTime() - start.getTime();
|
1740
|
-
}
|
1741
|
-
};
|
1742
|
-
var TimeUnits = {
|
1743
|
-
Microsecond: 1,
|
1744
|
-
Second: 1e3 * 1,
|
1745
|
-
//Microsecond,
|
1746
|
-
Minute: 60 * 1e3 * 1,
|
1747
|
-
//Second,
|
1748
|
-
Hour: 60 * 60 * 1e3 * 1
|
1749
|
-
// Minute,
|
1750
|
-
};
|
1751
|
-
|
1752
|
-
// src/deno/deno-env-actions.ts
|
1753
|
-
var once = new ResolveOnce();
|
1754
|
-
var _deno;
|
1755
|
-
var _DenoEnvActions = class _DenoEnvActions {
|
1756
|
-
constructor(opts) {
|
1757
|
-
__privateAdd(this, _deno, globalThis);
|
1758
|
-
this.opts = opts;
|
1759
|
-
}
|
1760
|
-
static new(opts) {
|
1761
|
-
return once.once(() => new _DenoEnvActions(opts));
|
1762
|
-
}
|
1763
|
-
get _env() {
|
1764
|
-
return __privateGet(this, _deno).Deno.env;
|
1765
|
-
}
|
1766
|
-
register(env) {
|
1767
|
-
for (const key of env.keys()) {
|
1768
|
-
this._env.set(key, env.get(key) || "");
|
1769
|
-
}
|
1770
|
-
return env;
|
1771
|
-
}
|
1772
|
-
active() {
|
1773
|
-
return runtimeFn().isDeno;
|
1774
|
-
}
|
1775
|
-
keys() {
|
1776
|
-
return Object.keys(this._env.toObject());
|
1777
|
-
}
|
1778
|
-
get(key) {
|
1779
|
-
return this._env.get(key);
|
1780
|
-
}
|
1781
|
-
set(key, value) {
|
1782
|
-
if (value) {
|
1783
|
-
this._env.set(key, value);
|
1784
|
-
}
|
1785
|
-
}
|
1786
|
-
delete(key) {
|
1787
|
-
this._env.delete(key);
|
1788
|
-
}
|
1789
|
-
};
|
1790
|
-
_deno = new WeakMap();
|
1791
|
-
var DenoEnvActions = _DenoEnvActions;
|
1792
|
-
|
1793
|
-
// src/node/node-env-actions.ts
|
1794
|
-
var once2 = new ResolveOnce();
|
1795
|
-
var _node;
|
1796
|
-
var _NodeEnvActions = class _NodeEnvActions {
|
1797
|
-
constructor(opts) {
|
1798
|
-
__privateAdd(this, _node, globalThis);
|
1799
|
-
this._env = this.active() ? __privateGet(this, _node).process.env : {};
|
1800
|
-
this.opts = opts;
|
1801
|
-
}
|
1802
|
-
static new(opts) {
|
1803
|
-
return once2.once(() => new _NodeEnvActions(opts));
|
1804
|
-
}
|
1805
|
-
register(env) {
|
1806
|
-
for (const key of env.keys()) {
|
1807
|
-
this._env[key] = env.get(key) || "";
|
1808
|
-
}
|
1809
|
-
return env;
|
1810
|
-
}
|
1811
|
-
active() {
|
1812
|
-
return runtimeFn().isNodeIsh;
|
1813
|
-
}
|
1814
|
-
keys() {
|
1815
|
-
return Object.keys(this._env);
|
1816
|
-
}
|
1817
|
-
get(key) {
|
1818
|
-
return this._env[key];
|
1819
|
-
}
|
1820
|
-
set(key, value) {
|
1821
|
-
if (value) {
|
1822
|
-
this._env[key] = value;
|
1823
|
-
}
|
1824
|
-
}
|
1825
|
-
delete(key) {
|
1826
|
-
delete this._env[key];
|
1827
|
-
}
|
1828
|
-
};
|
1829
|
-
_node = new WeakMap();
|
1830
|
-
var NodeEnvActions = _NodeEnvActions;
|
1831
|
-
|
1832
|
-
// src/web/web-env-actions.ts
|
1833
|
-
var once3 = new ResolveOnce();
|
1834
|
-
var BrowserEnvActions = class _BrowserEnvActions {
|
1835
|
-
constructor(opts) {
|
1836
|
-
this.env = /* @__PURE__ */ new Map();
|
1837
|
-
this.opts = opts;
|
1838
|
-
}
|
1839
|
-
static new(opts) {
|
1840
|
-
return once3.once(() => new _BrowserEnvActions(opts));
|
1841
|
-
}
|
1842
|
-
get(key) {
|
1843
|
-
return this.env.get(key);
|
1844
|
-
}
|
1845
|
-
set(key, value) {
|
1846
|
-
if (value) {
|
1847
|
-
this.env.set(key, value);
|
1848
|
-
}
|
1849
|
-
}
|
1850
|
-
delete(key) {
|
1851
|
-
this.env.delete(key);
|
1852
|
-
}
|
1853
|
-
keys() {
|
1854
|
-
return Array.from(this.env.keys());
|
1855
|
-
}
|
1856
|
-
active() {
|
1857
|
-
return true;
|
1858
|
-
}
|
1859
|
-
register(env) {
|
1860
|
-
const sym = Symbol.for(this.opts.symbol || "CP_ENV");
|
1861
|
-
const browser = globalThis;
|
1862
|
-
browser[sym] = env;
|
1863
|
-
return env;
|
1864
|
-
}
|
1865
|
-
};
|
1866
|
-
|
1867
|
-
// src/cf/cf-env-actions.ts
|
1868
|
-
var once4 = new ResolveOnce();
|
1869
|
-
var CFEnvActions = class _CFEnvActions {
|
1870
|
-
constructor(env) {
|
1871
|
-
this.injectOnRegister = {};
|
1872
|
-
this.cfEnv = new Map(Object.entries(env.presetEnv || {}));
|
1873
|
-
}
|
1874
|
-
static new(opts) {
|
1875
|
-
return once4.once(() => new _CFEnvActions(opts));
|
1876
|
-
}
|
1877
|
-
static inject(o) {
|
1878
|
-
const env = _CFEnvActions.new({});
|
1879
|
-
for (const key in o) {
|
1880
|
-
const value = o[key];
|
1881
|
-
if (typeof value === "string") {
|
1882
|
-
if (env.env) {
|
1883
|
-
env.env.set(key, value);
|
1884
|
-
} else {
|
1885
|
-
env.injectOnRegister[key] = value;
|
1886
|
-
}
|
1887
|
-
}
|
1888
|
-
}
|
1889
|
-
}
|
1890
|
-
active() {
|
1891
|
-
return runtimeFn().isCFWorker;
|
1892
|
-
}
|
1893
|
-
register(env) {
|
1894
|
-
this.env = env;
|
1895
|
-
for (const key in this.injectOnRegister) {
|
1896
|
-
env.set(key, this.injectOnRegister[key]);
|
1897
|
-
}
|
1898
|
-
return env;
|
1899
|
-
}
|
1900
|
-
get(key) {
|
1901
|
-
return this.cfEnv.get(key);
|
1902
|
-
}
|
1903
|
-
set(key, value) {
|
1904
|
-
if (value) {
|
1905
|
-
this.cfEnv.set(key, value);
|
1906
|
-
}
|
1907
|
-
}
|
1908
|
-
delete(key) {
|
1909
|
-
this.cfEnv.delete(key);
|
1910
|
-
}
|
1911
|
-
keys() {
|
1912
|
-
return Array.from(this.cfEnv.keys());
|
1913
|
-
}
|
1914
|
-
};
|
1915
|
-
|
1916
|
-
// src/sys-env.ts
|
1917
|
-
var envActions = [
|
1918
|
-
{ id: "cf", fn: (opts) => CFEnvActions.new(opts) },
|
1919
|
-
{ id: "node", fn: (opts) => NodeEnvActions.new(opts) },
|
1920
|
-
{ id: "deno", fn: (opts) => DenoEnvActions.new(opts) },
|
1921
|
-
{ id: "browser", fn: (opts) => BrowserEnvActions.new(opts) }
|
1922
|
-
];
|
1923
|
-
var _envFactories = new KeyedResolvOnce();
|
1924
|
-
function envFactory(opts = {}) {
|
1925
|
-
const found = envActions.find((fi) => fi.fn(opts).active());
|
1926
|
-
if (!found) {
|
1927
|
-
throw new Error("SysContainer:envFactory: no env available");
|
1928
|
-
}
|
1929
|
-
return _envFactories.get(found.id).once(() => {
|
1930
|
-
const action = found.fn(opts);
|
1931
|
-
const ret = new EnvImpl(action, opts);
|
1932
|
-
action.register(ret);
|
1933
|
-
return ret;
|
1934
|
-
});
|
1935
|
-
}
|
1936
|
-
function isIterable(obj) {
|
1937
|
-
if (obj == null) {
|
1938
|
-
return false;
|
1939
|
-
}
|
1940
|
-
return typeof obj[Symbol.iterator] === "function";
|
1941
|
-
}
|
1942
|
-
var EnvImpl = class {
|
1943
|
-
constructor(map, opts = {}) {
|
1944
|
-
this._onSet = [];
|
1945
|
-
this._map = map;
|
1946
|
-
this._updatePresets(opts.presetEnv);
|
1947
|
-
}
|
1948
|
-
gets(...kparams) {
|
1949
|
-
return getParamsResult(kparams, {
|
1950
|
-
getParam: (k) => this.get(k)
|
1951
|
-
});
|
1952
|
-
}
|
1953
|
-
sets(...keys) {
|
1954
|
-
keys.forEach((key) => {
|
1955
|
-
if (Array.isArray(key)) {
|
1956
|
-
if (key.length === 2) {
|
1957
|
-
const [k, v] = key;
|
1958
|
-
if (typeof k === "string" && typeof v === "string") {
|
1959
|
-
this.set(k, v);
|
1960
|
-
return;
|
1961
|
-
}
|
1962
|
-
}
|
1963
|
-
for (const item of key) {
|
1964
|
-
if (Array.isArray(item)) {
|
1965
|
-
if (item.length === 2) {
|
1966
|
-
const [k, v] = item;
|
1967
|
-
if (typeof k === "string" && typeof v === "string") {
|
1968
|
-
this.set(k, v);
|
1969
|
-
}
|
1970
|
-
}
|
1971
|
-
}
|
1972
|
-
}
|
1973
|
-
} else {
|
1974
|
-
if (isIterable(key)) {
|
1975
|
-
for (const [k, v] of key) {
|
1976
|
-
if (typeof k === "string" && typeof v === "string") {
|
1977
|
-
this.set(k, v);
|
1978
|
-
}
|
1979
|
-
}
|
1980
|
-
} else {
|
1981
|
-
const rKey = key;
|
1982
|
-
for (const k in rKey) {
|
1983
|
-
const v = rKey[k];
|
1984
|
-
if (typeof k === "string" && typeof v === "string") {
|
1985
|
-
this.set(k, v);
|
1986
|
-
}
|
1987
|
-
}
|
1988
|
-
}
|
1989
|
-
}
|
1990
|
-
});
|
1991
|
-
}
|
1992
|
-
_updatePresets(presetEnv) {
|
1993
|
-
if (!presetEnv) {
|
1994
|
-
return;
|
1995
|
-
}
|
1996
|
-
for (const [key, value] of presetEnv) {
|
1997
|
-
this._map.set(key, value);
|
1998
|
-
}
|
1999
|
-
}
|
2000
|
-
_applyOnSet(onSet, key, value) {
|
2001
|
-
onSet.forEach((item) => {
|
2002
|
-
let keys = [];
|
2003
|
-
if (key) {
|
2004
|
-
keys = [key];
|
2005
|
-
} else {
|
2006
|
-
keys = this._map.keys();
|
2007
|
-
}
|
2008
|
-
keys.filter((k) => {
|
2009
|
-
if (item.filter.size === 0) {
|
2010
|
-
return true;
|
2011
|
-
}
|
2012
|
-
if (item.filter.has(k)) {
|
2013
|
-
return true;
|
2014
|
-
}
|
2015
|
-
return false;
|
2016
|
-
}).forEach((k) => {
|
2017
|
-
let v;
|
2018
|
-
if (!key && !value) {
|
2019
|
-
v = this._map.get(k);
|
2020
|
-
} else if (key && !value) {
|
2021
|
-
v = void 0;
|
2022
|
-
} else {
|
2023
|
-
v = value;
|
2024
|
-
}
|
2025
|
-
item.fn(k, v);
|
2026
|
-
});
|
2027
|
-
});
|
2028
|
-
}
|
2029
|
-
keys() {
|
2030
|
-
return this._map.keys();
|
2031
|
-
}
|
2032
|
-
// filter is not set all sets passed
|
2033
|
-
onSet(fn, ...filter) {
|
2034
|
-
const item = { filter: new Set(filter), fn };
|
2035
|
-
this._onSet.push(item);
|
2036
|
-
this._applyOnSet([item]);
|
2037
|
-
}
|
2038
|
-
get(key) {
|
2039
|
-
return this._map.get(key);
|
2040
|
-
}
|
2041
|
-
set(key, value) {
|
2042
|
-
if (!value) {
|
2043
|
-
return;
|
2044
|
-
}
|
2045
|
-
this._map.set(key, value);
|
2046
|
-
this._applyOnSet(this._onSet, key, value);
|
2047
|
-
}
|
2048
|
-
delete(key) {
|
2049
|
-
this._map.delete(key);
|
2050
|
-
this._applyOnSet(this._onSet, key);
|
2051
|
-
}
|
2052
|
-
};
|
2053
|
-
|
2054
|
-
// src/utils/console-write-stream.ts
|
2055
|
-
var ConsoleWriterStreamDefaultWriter = class {
|
2056
|
-
constructor(stream) {
|
2057
|
-
this.stream = stream;
|
2058
|
-
this.desiredSize = null;
|
2059
|
-
this.decoder = new TextDecoder();
|
2060
|
-
this._stream = stream;
|
2061
|
-
this.ready = Promise.resolve(void 0);
|
2062
|
-
this.closed = Promise.resolve(void 0);
|
2063
|
-
}
|
2064
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
2065
|
-
abort(reason) {
|
2066
|
-
throw new Error("Method not implemented.");
|
2067
|
-
}
|
2068
|
-
async close() {
|
2069
|
-
}
|
2070
|
-
releaseLock() {
|
2071
|
-
this._stream.locked = false;
|
2072
|
-
this.ready = Promise.resolve(void 0);
|
2073
|
-
this.closed = Promise.resolve(void 0);
|
2074
|
-
}
|
2075
|
-
write(chunk) {
|
2076
|
-
let strObj = this.decoder.decode(chunk).trimEnd();
|
2077
|
-
let output = "log";
|
2078
|
-
try {
|
2079
|
-
strObj = JSON.parse(strObj);
|
2080
|
-
output = strObj.level;
|
2081
|
-
} catch (e) {
|
2082
|
-
}
|
2083
|
-
switch (output) {
|
2084
|
-
case "error":
|
2085
|
-
console.error(strObj);
|
2086
|
-
break;
|
2087
|
-
case "warn":
|
2088
|
-
console.warn(strObj);
|
2089
|
-
break;
|
2090
|
-
default:
|
2091
|
-
console.log(strObj);
|
2092
|
-
}
|
2093
|
-
return Promise.resolve();
|
2094
|
-
}
|
2095
|
-
};
|
2096
|
-
var ConsoleWriterStream = class {
|
2097
|
-
constructor() {
|
2098
|
-
this.locked = false;
|
2099
|
-
}
|
2100
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
2101
|
-
abort(reason) {
|
2102
|
-
throw new Error("Method not implemented.");
|
2103
|
-
}
|
2104
|
-
close() {
|
2105
|
-
return Promise.resolve();
|
2106
|
-
}
|
2107
|
-
getWriter() {
|
2108
|
-
if (this.locked) {
|
2109
|
-
throw new Error("Stream is locked");
|
2110
|
-
}
|
2111
|
-
this.locked = true;
|
2112
|
-
if (!this._writer) {
|
2113
|
-
this._writer = new ConsoleWriterStreamDefaultWriter(this);
|
2114
|
-
}
|
2115
|
-
return this._writer;
|
2116
|
-
}
|
2117
|
-
};
|
2118
|
-
|
2119
|
-
// src/web/web-basic-sys-abstraction.ts
|
2120
|
-
var WebSystemService = class {
|
2121
|
-
constructor(ende) {
|
2122
|
-
this._txtEnDe = ende;
|
2123
|
-
}
|
2124
|
-
Env() {
|
2125
|
-
return envFactory();
|
2126
|
-
}
|
2127
|
-
Args() {
|
2128
|
-
throw new Error("Args-Method not implemented.");
|
2129
|
-
}
|
2130
|
-
Stdout() {
|
2131
|
-
return new ConsoleWriterStream();
|
2132
|
-
}
|
2133
|
-
Stderr() {
|
2134
|
-
const decoder = this._txtEnDe;
|
2135
|
-
return new WritableStream({
|
2136
|
-
write(chunk) {
|
2137
|
-
return new Promise((resolve) => {
|
2138
|
-
const decoded = decoder.decode(chunk);
|
2139
|
-
console.error(decoded.trimEnd());
|
2140
|
-
resolve();
|
2141
|
-
});
|
2142
|
-
}
|
2143
|
-
});
|
2144
|
-
}
|
2145
|
-
};
|
2146
|
-
var baseSysAbstraction = new ResolveOnce();
|
2147
|
-
function WebBasicSysAbstraction(param2) {
|
2148
|
-
var _a;
|
2149
|
-
const my = baseSysAbstraction.once(() => {
|
2150
|
-
return new BaseBasicSysAbstraction({
|
2151
|
-
TxtEnDecoder: (param2 == null ? void 0 : param2.TxtEnDecoder) || TxtEnDecoderSingleton()
|
2152
|
-
});
|
2153
|
-
});
|
2154
|
-
return new WrapperBasicSysAbstraction(my, {
|
2155
|
-
basicRuntimeService: new WebSystemService((_a = param2 == null ? void 0 : param2.TxtEnDecoder) != null ? _a : my._txtEnDe),
|
2156
|
-
...param2
|
2157
|
-
});
|
2158
|
-
}
|
2159
|
-
|
2160
|
-
// src/cf/cf-basic-sys-abstraction.ts
|
2161
|
-
var CFRuntimeService = class {
|
2162
|
-
constructor(ende) {
|
2163
|
-
this._txtEnDe = ende;
|
2164
|
-
}
|
2165
|
-
Env() {
|
2166
|
-
return envFactory();
|
2167
|
-
}
|
2168
|
-
Args() {
|
2169
|
-
throw new Error("Args-Method not implemented.");
|
2170
|
-
}
|
2171
|
-
Stdout() {
|
2172
|
-
return CFWriteableStream((chunk) => {
|
2173
|
-
const decoded = this._txtEnDe.decode(chunk);
|
2174
|
-
console.log(decoded.trimEnd());
|
2175
|
-
return Promise.resolve();
|
2176
|
-
});
|
2177
|
-
}
|
2178
|
-
Stderr() {
|
2179
|
-
return CFWriteableStream((chunk) => {
|
2180
|
-
const decoded = this._txtEnDe.decode(chunk);
|
2181
|
-
console.error(decoded.trimEnd());
|
2182
|
-
return Promise.resolve();
|
2183
|
-
});
|
2184
|
-
}
|
2185
|
-
};
|
2186
|
-
function consumeReadableStream(reader, writeFn) {
|
2187
|
-
reader.read().then(({ done, value }) => {
|
2188
|
-
if (done) {
|
2189
|
-
return;
|
2190
|
-
}
|
2191
|
-
writeFn(value).then(() => {
|
2192
|
-
consumeReadableStream(reader, writeFn);
|
2193
|
-
}).catch((e) => {
|
2194
|
-
console.error("consumeReadableStream:writeFn", e);
|
2195
|
-
});
|
2196
|
-
}).catch((e) => {
|
2197
|
-
console.error("consumeReadableStream:read", e);
|
2198
|
-
});
|
2199
|
-
}
|
2200
|
-
function CFWriteableStream(writeFn) {
|
2201
|
-
const ts = new TransformStream();
|
2202
|
-
consumeReadableStream(ts.readable.getReader(), writeFn);
|
2203
|
-
return ts.writable;
|
2204
|
-
}
|
2205
|
-
var baseSysAbstraction2 = new ResolveOnce();
|
2206
|
-
function CFBasicSysAbstraction(param2) {
|
2207
|
-
var _a;
|
2208
|
-
const my = baseSysAbstraction2.once(() => {
|
2209
|
-
return new BaseBasicSysAbstraction({
|
2210
|
-
TxtEnDecoder: (param2 == null ? void 0 : param2.TxtEnDecoder) || TxtEnDecoderSingleton()
|
2211
|
-
});
|
2212
|
-
});
|
2213
|
-
return new WrapperBasicSysAbstraction(my, {
|
2214
|
-
basicRuntimeService: new CFRuntimeService((_a = param2 == null ? void 0 : param2.TxtEnDecoder) != null ? _a : my._txtEnDe),
|
2215
|
-
...param2
|
2216
|
-
});
|
2217
|
-
}
|
2218
|
-
|
2219
|
-
// src/deno/deno-basic-sys-abstraction.ts
|
2220
|
-
var DenoRuntimeService = class {
|
2221
|
-
constructor(ende) {
|
2222
|
-
this._txtEnDe = ende;
|
2223
|
-
}
|
2224
|
-
Env() {
|
2225
|
-
return envFactory();
|
2226
|
-
}
|
2227
|
-
Args() {
|
2228
|
-
return globalThis.Deno.args;
|
2229
|
-
}
|
2230
|
-
Stdout() {
|
2231
|
-
return globalThis.Deno.stdout.writable;
|
2232
|
-
}
|
2233
|
-
Stderr() {
|
2234
|
-
return globalThis.Deno.stderr.writable;
|
2235
|
-
}
|
2236
|
-
};
|
2237
|
-
var baseSysAbstraction3 = new ResolveOnce();
|
2238
|
-
function DenoBasicSysAbstraction(param2) {
|
2239
|
-
var _a;
|
2240
|
-
const my = baseSysAbstraction3.once(() => {
|
2241
|
-
return new BaseBasicSysAbstraction({
|
2242
|
-
TxtEnDecoder: (param2 == null ? void 0 : param2.TxtEnDecoder) || TxtEnDecoderSingleton()
|
2243
|
-
});
|
2244
|
-
});
|
2245
|
-
return new WrapperBasicSysAbstraction(my, {
|
2246
|
-
basicRuntimeService: new DenoRuntimeService((_a = param2 == null ? void 0 : param2.TxtEnDecoder) != null ? _a : my._txtEnDe),
|
2247
|
-
...param2
|
2248
|
-
});
|
2249
|
-
}
|
2250
|
-
|
2251
|
-
// src/node/node-basic-sys-abstraction.ts
|
2252
|
-
var NodeRuntimeService = class {
|
2253
|
-
constructor(ende) {
|
2254
|
-
this._txtEnDe = ende;
|
2255
|
-
this._gthis = globalThis;
|
2256
|
-
}
|
2257
|
-
Env() {
|
2258
|
-
return envFactory();
|
2259
|
-
}
|
2260
|
-
Args() {
|
2261
|
-
return this._gthis.process.argv;
|
2262
|
-
}
|
2263
|
-
Stdout() {
|
2264
|
-
return new WritableStream({
|
2265
|
-
write: (chunk) => {
|
2266
|
-
this._gthis.process.stdout.write(chunk);
|
2267
|
-
}
|
2268
|
-
});
|
2269
|
-
}
|
2270
|
-
Stderr() {
|
2271
|
-
return new WritableStream({
|
2272
|
-
write: (chunk) => {
|
2273
|
-
this._gthis.process.stderr.write(chunk);
|
2274
|
-
}
|
2275
|
-
});
|
2276
|
-
}
|
2277
|
-
};
|
2278
|
-
var baseSysAbstraction4 = new ResolveOnce();
|
2279
|
-
function NodeBasicSysAbstraction(param2) {
|
2280
|
-
var _a;
|
2281
|
-
const my = baseSysAbstraction4.once(() => {
|
2282
|
-
return new BaseBasicSysAbstraction({
|
2283
|
-
TxtEnDecoder: (param2 == null ? void 0 : param2.TxtEnDecoder) || TxtEnDecoderSingleton()
|
2284
|
-
});
|
2285
|
-
});
|
2286
|
-
return new WrapperBasicSysAbstraction(my, {
|
2287
|
-
basicRuntimeService: new NodeRuntimeService((_a = param2 == null ? void 0 : param2.TxtEnDecoder) != null ? _a : my._txtEnDe),
|
2288
|
-
...param2
|
2289
|
-
});
|
2290
|
-
}
|
2291
|
-
|
2292
|
-
// src/base-sys-abstraction.ts
|
2293
|
-
var SysTime = class extends Time {
|
2294
|
-
Now() {
|
2295
|
-
return /* @__PURE__ */ new Date();
|
2296
|
-
}
|
2297
|
-
Sleep(duration) {
|
2298
|
-
return new Promise((resolve) => {
|
2299
|
-
setTimeout(() => {
|
2300
|
-
resolve();
|
2301
|
-
}, duration);
|
2302
|
-
});
|
2303
|
-
}
|
2304
|
-
};
|
2305
|
-
var ConstTime = class extends Time {
|
2306
|
-
Now() {
|
2307
|
-
return new Date(2021, 1, 1, 0, 0, 0, 0);
|
2308
|
-
}
|
2309
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2310
|
-
Sleep(duration) {
|
2311
|
-
return Promise.resolve();
|
2312
|
-
}
|
2313
|
-
};
|
2314
|
-
var StepTime = class extends Time {
|
2315
|
-
constructor() {
|
2316
|
-
super();
|
2317
|
-
this._step = new ConstTime().Now();
|
2318
|
-
this._start = this._step;
|
2319
|
-
}
|
2320
|
-
Now(steps = 1) {
|
2321
|
-
for (let i = 0; steps > 0 && i < steps; i++) {
|
2322
|
-
this._step = new Date(this._step.getTime() + 1e3);
|
2323
|
-
}
|
2324
|
-
if (steps < 1) {
|
2325
|
-
this._step = new Date(this._start.getTime() + steps * -1e3);
|
2326
|
-
}
|
2327
|
-
return this._step;
|
2328
|
-
}
|
2329
|
-
Sleep(duration) {
|
2330
|
-
this._step = new Date(this._step.getTime() + duration);
|
2331
|
-
return Promise.resolve();
|
2332
|
-
}
|
2333
|
-
};
|
2334
|
-
function TimeFactory(timeMode) {
|
2335
|
-
switch (timeMode) {
|
2336
|
-
case TimeMode.REAL:
|
2337
|
-
return new SysTime();
|
2338
|
-
case TimeMode.CONST:
|
2339
|
-
return new ConstTime();
|
2340
|
-
case TimeMode.STEP:
|
2341
|
-
return new StepTime();
|
2342
|
-
}
|
2343
|
-
return new SysTime();
|
2344
|
-
}
|
2345
|
-
var RandomService = class {
|
2346
|
-
constructor(mode) {
|
2347
|
-
this._step = 0;
|
2348
|
-
this._mode = mode;
|
2349
|
-
}
|
2350
|
-
Random0ToValue(value) {
|
2351
|
-
switch (this._mode) {
|
2352
|
-
case RandomMode.CONST:
|
2353
|
-
return 0.5 * value;
|
2354
|
-
case RandomMode.STEP:
|
2355
|
-
this._step += 1e-4;
|
2356
|
-
return this._step * value;
|
2357
|
-
case RandomMode.RANDOM:
|
2358
|
-
return Math.random() * value;
|
2359
|
-
default:
|
2360
|
-
throw new Error("Unknown RandomMode");
|
2361
|
-
}
|
2362
|
-
}
|
2363
|
-
};
|
2364
|
-
var IdService = class {
|
2365
|
-
constructor(mode) {
|
2366
|
-
this._step = 0;
|
2367
|
-
if (!mode) {
|
2368
|
-
mode = IDMode.UUID;
|
2369
|
-
}
|
2370
|
-
this._mode = mode;
|
2371
|
-
}
|
2372
|
-
NextId() {
|
2373
|
-
switch (this._mode) {
|
2374
|
-
case IDMode.UUID:
|
2375
|
-
return crypto.randomUUID();
|
2376
|
-
case IDMode.CONST:
|
2377
|
-
return "VeryUniqueID";
|
2378
|
-
case IDMode.STEP:
|
2379
|
-
return `STEPId-${this._step++}`;
|
2380
|
-
default:
|
2381
|
-
throw new Error("Unknown IDMode");
|
2382
|
-
}
|
2383
|
-
}
|
2384
|
-
};
|
2385
|
-
var BaseBasicSysAbstraction = class {
|
2386
|
-
constructor(params) {
|
2387
|
-
this._time = new SysTime();
|
2388
|
-
// system independent services
|
2389
|
-
this._idService = new IdService();
|
2390
|
-
this._randomService = new RandomService(RandomMode.RANDOM);
|
2391
|
-
this._txtEnDe = params.TxtEnDecoder;
|
2392
|
-
}
|
2393
|
-
};
|
2394
|
-
function BasicSysAbstractionFactory(params) {
|
2395
|
-
const fn = runtimeFn();
|
2396
|
-
switch (true) {
|
2397
|
-
case fn.isBrowser:
|
2398
|
-
return WebBasicSysAbstraction(params);
|
2399
|
-
case fn.isDeno:
|
2400
|
-
return DenoBasicSysAbstraction(params);
|
2401
|
-
case fn.isCFWorker:
|
2402
|
-
return CFBasicSysAbstraction(params);
|
2403
|
-
case fn.isNodeIsh:
|
2404
|
-
return NodeBasicSysAbstraction(params);
|
2405
|
-
default:
|
2406
|
-
throw new Error("Unknown runtime");
|
2407
|
-
}
|
2408
|
-
}
|
2409
|
-
var WrapperBasicSysAbstraction = class {
|
2410
|
-
constructor(base, params) {
|
2411
|
-
this._time = base._time;
|
2412
|
-
this._basicRuntimeService = params.basicRuntimeService;
|
2413
|
-
this._idService = base._idService;
|
2414
|
-
this._randomService = base._randomService;
|
2415
|
-
if (params.TimeMode) {
|
2416
|
-
this._time = TimeFactory(params.TimeMode);
|
2417
|
-
}
|
2418
|
-
if (params.IdMode) {
|
2419
|
-
this._idService = new IdService(params.IdMode);
|
2420
|
-
}
|
2421
|
-
if (params.RandomMode) {
|
2422
|
-
this._randomService = new RandomService(params.RandomMode);
|
2423
|
-
}
|
2424
|
-
}
|
2425
|
-
Time() {
|
2426
|
-
return this._time;
|
2427
|
-
}
|
2428
|
-
NextId() {
|
2429
|
-
return this._idService.NextId();
|
2430
|
-
}
|
2431
|
-
Random0ToValue(value) {
|
2432
|
-
return this._randomService.Random0ToValue(value);
|
2433
|
-
}
|
2434
|
-
Stdout() {
|
2435
|
-
return this._basicRuntimeService.Stdout();
|
2436
|
-
}
|
2437
|
-
Stderr() {
|
2438
|
-
return this._basicRuntimeService.Stderr();
|
2439
|
-
}
|
2440
|
-
Env() {
|
2441
|
-
return this._basicRuntimeService.Env();
|
2442
|
-
}
|
2443
|
-
Args() {
|
2444
|
-
return this._basicRuntimeService.Args();
|
2445
|
-
}
|
2446
|
-
// System(): SystemService {
|
2447
|
-
// return this._systemService;
|
2448
|
-
// }
|
2449
|
-
// FileSystem(): FileService {
|
2450
|
-
// return this._fileSystem;
|
2451
|
-
// }
|
2452
|
-
};
|
2453
|
-
|
2454
|
-
// src/log-writer-impl.ts
|
2455
|
-
var LogWriterStream = class {
|
2456
|
-
constructor(out) {
|
2457
|
-
this._toFlush = [];
|
2458
|
-
this._flushIsRunning = false;
|
2459
|
-
this._flushDoneFns = [];
|
2460
|
-
this._out = out;
|
2461
|
-
this._id = Math.random();
|
2462
|
-
}
|
2463
|
-
write(encoded) {
|
2464
|
-
const my = async () => {
|
2465
|
-
try {
|
2466
|
-
const writer = this._out.getWriter();
|
2467
|
-
await writer.ready;
|
2468
|
-
await writer.write(encoded);
|
2469
|
-
writer.releaseLock();
|
2470
|
-
} catch (err) {
|
2471
|
-
console.error("Chunk error:", err);
|
2472
|
-
}
|
2473
|
-
};
|
2474
|
-
this._toFlush.push(my);
|
2475
|
-
this._flush();
|
2476
|
-
}
|
2477
|
-
_flush(toFlush = void 0, done) {
|
2478
|
-
if (done) {
|
2479
|
-
this._flushDoneFns.push(done);
|
2480
|
-
}
|
2481
|
-
if (this._toFlush.length == 0) {
|
2482
|
-
this._flushIsRunning = false;
|
2483
|
-
this._flushDoneFns.forEach((fn) => fn());
|
2484
|
-
this._flushDoneFns = [];
|
2485
|
-
return;
|
2486
|
-
}
|
2487
|
-
if (!toFlush && this._toFlush.length == 1 && !this._flushIsRunning) {
|
2488
|
-
this._flushIsRunning = true;
|
2489
|
-
} else if (!toFlush) {
|
2490
|
-
return;
|
2491
|
-
}
|
2492
|
-
const my = this._toFlush.shift();
|
2493
|
-
my == null ? void 0 : my().catch((e) => {
|
2494
|
-
console.error("Flush error:", e);
|
2495
|
-
}).finally(() => {
|
2496
|
-
this._flush(this._toFlush);
|
2497
|
-
});
|
2498
|
-
}
|
2499
|
-
};
|
2500
|
-
|
2501
|
-
// src/logger-impl.ts
|
2502
|
-
function getLen(value, lvs) {
|
2503
|
-
if (Array.isArray(value)) {
|
2504
|
-
return logValue(() => value.length, lvs);
|
2505
|
-
} else if (typeof value === "string") {
|
2506
|
-
return logValue(() => value.length, lvs);
|
2507
|
-
} else if (typeof value === "object" && value !== null) {
|
2508
|
-
if (typeof value.size === "number") {
|
2509
|
-
return logValue(() => value.size, lvs);
|
2510
|
-
} else if (typeof value.length === "number") {
|
2511
|
-
return logValue(() => value.length, lvs);
|
2512
|
-
}
|
2513
|
-
return logValue(() => Object.keys(value).length, lvs);
|
2514
|
-
}
|
2515
|
-
return logValue(() => -1, lvs);
|
2516
|
-
}
|
2517
|
-
function toLogValue(lop) {
|
2518
|
-
if (lop && typeof lop.then === "function") {
|
2519
|
-
throw new Error("async logValue Not implemented");
|
2520
|
-
}
|
2521
|
-
return lop;
|
2522
|
-
}
|
2523
|
-
var JSONFormatter = class {
|
2524
|
-
constructor(txtEnde, space) {
|
2525
|
-
this._txtEnDe = txtEnde;
|
2526
|
-
this._space = space;
|
2527
|
-
}
|
2528
|
-
format(attr) {
|
2529
|
-
let ret;
|
2530
|
-
try {
|
2531
|
-
ret = JSON.stringify(attr, null, this._space);
|
2532
|
-
} catch (e) {
|
2533
|
-
ret = JSON.stringify({ internal: { message: e.message, stack: e.stack } });
|
2534
|
-
}
|
2535
|
-
return this._txtEnDe.encode(ret + "\n");
|
2536
|
-
}
|
2537
|
-
};
|
2538
|
-
function toLogValueCtx(lvh) {
|
2539
|
-
return {
|
2540
|
-
ignoreAttr: lvh.ignoreAttr
|
2541
|
-
};
|
2542
|
-
}
|
2543
|
-
var LoggerImpl = class _LoggerImpl {
|
2544
|
-
// readonly _id: string = "logger-" + Math.random().toString(36)
|
2545
|
-
constructor(params) {
|
2546
|
-
this._attributes = {};
|
2547
|
-
if (!params) {
|
2548
|
-
params = {};
|
2549
|
-
}
|
2550
|
-
if (!params.sys) {
|
2551
|
-
this._sys = BasicSysAbstractionFactory();
|
2552
|
-
} else {
|
2553
|
-
this._sys = params.sys;
|
2554
|
-
}
|
2555
|
-
if (!params.txtEnDe) {
|
2556
|
-
this._txtEnDe = TxtEnDecoderSingleton();
|
2557
|
-
} else {
|
2558
|
-
this._txtEnDe = params.txtEnDe;
|
2559
|
-
}
|
2560
|
-
if (!params.formatter) {
|
2561
|
-
this._formatter = new JSONFormatter(this._txtEnDe);
|
2562
|
-
} else {
|
2563
|
-
this._formatter = params.formatter;
|
2564
|
-
}
|
2565
|
-
if (params.logWriter) {
|
2566
|
-
this._logWriter = params.logWriter;
|
2567
|
-
} else {
|
2568
|
-
if (!params.out) {
|
2569
|
-
this._logWriter = new LogWriterStream(this._sys.Stdout());
|
2570
|
-
} else {
|
2571
|
-
this._logWriter = new LogWriterStream(params.out);
|
2572
|
-
}
|
2573
|
-
}
|
2574
|
-
if (!params.withAttributes) {
|
2575
|
-
this._withAttributes = {};
|
2576
|
-
} else {
|
2577
|
-
this._withAttributes = { ...params.withAttributes };
|
2578
|
-
}
|
2579
|
-
this._attributes = { ...this._withAttributes };
|
2580
|
-
if (params.levelHandler) {
|
2581
|
-
this.levelHandler = params.levelHandler;
|
2582
|
-
} else {
|
2583
|
-
this.levelHandler = LevelHandlerSingleton();
|
2584
|
-
}
|
2585
|
-
}
|
2586
|
-
TxtEnDe() {
|
2587
|
-
return this._txtEnDe;
|
2588
|
-
}
|
2589
|
-
Attributes() {
|
2590
|
-
return JSON.parse(JSON.stringify(this._attributes, null));
|
2591
|
-
}
|
2592
|
-
SetExposeStack(enable) {
|
2593
|
-
this.levelHandler.setExposeStack(enable);
|
2594
|
-
return this;
|
2595
|
-
}
|
2596
|
-
EnableLevel(level, ...modules) {
|
2597
|
-
this.levelHandler.enableLevel(level, ...modules);
|
2598
|
-
return this;
|
2599
|
-
}
|
2600
|
-
DisableLevel(level, ...modules) {
|
2601
|
-
this.levelHandler.disableLevel(level, ...modules);
|
2602
|
-
return this;
|
2603
|
-
}
|
2604
|
-
Module(key) {
|
2605
|
-
this._attributes["module"] = logValue(key, toLogValueCtx(this.levelHandler));
|
2606
|
-
this._withAttributes["module"] = logValue(key, toLogValueCtx(this.levelHandler));
|
2607
|
-
return this;
|
2608
|
-
}
|
2609
|
-
// if the string is "*" it will enable for all modules
|
2610
|
-
SetDebug(...modules) {
|
2611
|
-
this.levelHandler.setDebug(...modules);
|
2612
|
-
return this;
|
2613
|
-
}
|
2614
|
-
SetIgnoreAttribute(re) {
|
2615
|
-
this.levelHandler.setIgnoreAttr(re);
|
2616
|
-
return this;
|
2617
|
-
}
|
2618
|
-
SetFormatter(formatter) {
|
2619
|
-
this._formatter = formatter;
|
2620
|
-
return this;
|
2621
|
-
}
|
2622
|
-
Timestamp() {
|
2623
|
-
this._attributes["ts"] = logValue(() => this._sys.Time().Now().toISOString(), toLogValueCtx(this.levelHandler));
|
2624
|
-
return this;
|
2625
|
-
}
|
2626
|
-
Warn() {
|
2627
|
-
this._attributes["level"] = logValue(Level.WARN, toLogValueCtx(this.levelHandler));
|
2628
|
-
return this;
|
2629
|
-
}
|
2630
|
-
Log() {
|
2631
|
-
return this;
|
2632
|
-
}
|
2633
|
-
Debug() {
|
2634
|
-
this._attributes["level"] = logValue(Level.DEBUG, toLogValueCtx(this.levelHandler));
|
2635
|
-
return this;
|
2636
|
-
}
|
2637
|
-
Error() {
|
2638
|
-
this._attributes["level"] = logValue(Level.ERROR, toLogValueCtx(this.levelHandler));
|
2639
|
-
return this;
|
2640
|
-
}
|
2641
|
-
Info() {
|
2642
|
-
this._attributes["level"] = logValue(Level.INFO, toLogValueCtx(this.levelHandler));
|
2643
|
-
return this;
|
2644
|
-
}
|
2645
|
-
Err(err) {
|
2646
|
-
var _a;
|
2647
|
-
let key = "error";
|
2648
|
-
if (Result.Is(err)) {
|
2649
|
-
if (err.isOk()) {
|
2650
|
-
key = "noerror";
|
2651
|
-
err = err.Ok();
|
2652
|
-
} else {
|
2653
|
-
err = err.Err();
|
2654
|
-
}
|
2655
|
-
}
|
2656
|
-
if (err instanceof Error) {
|
2657
|
-
if (err.cause) {
|
2658
|
-
this.coerceKey(key, {
|
2659
|
-
message: err.message,
|
2660
|
-
cause: err.cause
|
2661
|
-
});
|
2662
|
-
} else {
|
2663
|
-
this._attributes[key] = logValue(err.message, toLogValueCtx(this.levelHandler));
|
2664
|
-
}
|
2665
|
-
if (this.levelHandler.isStackExposed) {
|
2666
|
-
this._attributes["stack"] = logValue(
|
2667
|
-
(_a = err.stack) == null ? void 0 : _a.split(/[\r\n]+/).map((s) => s.trim()),
|
2668
|
-
toLogValueCtx(this.levelHandler)
|
2669
|
-
);
|
2670
|
-
}
|
2671
|
-
} else {
|
2672
|
-
this.Any(key, err);
|
2673
|
-
}
|
2674
|
-
return this;
|
2675
|
-
}
|
2676
|
-
WithLevel(l) {
|
2677
|
-
this._attributes["level"] = logValue(l, toLogValueCtx(this.levelHandler));
|
2678
|
-
return this;
|
2679
|
-
}
|
2680
|
-
Ref(key, action) {
|
2681
|
-
if (typeof action === "function") {
|
2682
|
-
this._attributes[key] = logValue(action, toLogValueCtx(this.levelHandler));
|
2683
|
-
} else if (typeof action.toString === "function") {
|
2684
|
-
this._attributes[key] = logValue(() => action.toString(), toLogValueCtx(this.levelHandler));
|
2685
|
-
} else {
|
2686
|
-
this._attributes[key] = logValue("INVALID REF", toLogValueCtx(this.levelHandler));
|
2687
|
-
}
|
2688
|
-
return this;
|
2689
|
-
}
|
2690
|
-
Bool(key, value) {
|
2691
|
-
this.coerceKey(key, !!value);
|
2692
|
-
return this;
|
2693
|
-
}
|
2694
|
-
Http(...mix) {
|
2695
|
-
const key = mix.find((x) => typeof x === "string");
|
2696
|
-
mix = mix.filter((x) => typeof x !== "string");
|
2697
|
-
const resErrors = mix.filter((x) => Result.Is(x) && x.isErr());
|
2698
|
-
if (resErrors.length) {
|
2699
|
-
this.Err(resErrors.map((x) => x.Err().message).join("\n"));
|
2700
|
-
return this;
|
2701
|
-
}
|
2702
|
-
const req = mix.map((reqOrResult) => Result.Is(reqOrResult) ? reqOrResult.Ok() : reqOrResult).find((req2) => typeof req2.status !== "number");
|
2703
|
-
const res = mix.map((resOrResult) => Result.Is(resOrResult) ? resOrResult.Ok() : resOrResult).find((res2) => typeof res2.status === "number");
|
2704
|
-
let reqAndOrres;
|
2705
|
-
if (res && req) {
|
2706
|
-
reqAndOrres = { res, req };
|
2707
|
-
} else if (!res && !req) {
|
2708
|
-
reqAndOrres = void 0;
|
2709
|
-
} else if (res) {
|
2710
|
-
reqAndOrres = res;
|
2711
|
-
} else if (req) {
|
2712
|
-
reqAndOrres = req;
|
2713
|
-
}
|
2714
|
-
if (reqAndOrres) {
|
2715
|
-
this.Any(key || "Http", reqAndOrres);
|
2716
|
-
}
|
2717
|
-
return this;
|
2718
|
-
}
|
2719
|
-
Pair(x) {
|
2720
|
-
for (const key of Object.keys(x)) {
|
2721
|
-
const value = x[key];
|
2722
|
-
if (value instanceof LogValue) {
|
2723
|
-
this._attributes[key] = value;
|
2724
|
-
continue;
|
2725
|
-
}
|
2726
|
-
if (Result.Is(value)) {
|
2727
|
-
this.Result(key, value);
|
2728
|
-
continue;
|
2729
|
-
}
|
2730
|
-
this.Any(key, value);
|
2731
|
-
}
|
2732
|
-
return this;
|
2733
|
-
}
|
2734
|
-
Result(key, res) {
|
2735
|
-
if (res.isOk()) {
|
2736
|
-
this._attributes[key] = logValue(res.Ok(), toLogValueCtx(this.levelHandler));
|
2737
|
-
} else {
|
2738
|
-
this.Err(res.Err());
|
2739
|
-
}
|
2740
|
-
return this;
|
2741
|
-
}
|
2742
|
-
Len(value, key = "len") {
|
2743
|
-
this._attributes[key] = getLen(value, toLogValueCtx(this.levelHandler));
|
2744
|
-
return this;
|
2745
|
-
}
|
2746
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2747
|
-
Hash(value, key = "hash") {
|
2748
|
-
throw new Error("Not implemented");
|
2749
|
-
}
|
2750
|
-
Url(url, key = "url") {
|
2751
|
-
this.Ref(key, () => URI.from(url).toString());
|
2752
|
-
return this;
|
2753
|
-
}
|
2754
|
-
coerceKey(key, value) {
|
2755
|
-
if (typeof key === "string") {
|
2756
|
-
this._attributes[key] = logValue(value, toLogValueCtx(this.levelHandler));
|
2757
|
-
} else {
|
2758
|
-
this.Pair(key);
|
2759
|
-
}
|
2760
|
-
}
|
2761
|
-
Str(key, value) {
|
2762
|
-
this.coerceKey(key, value);
|
2763
|
-
return this;
|
2764
|
-
}
|
2765
|
-
Any(key, value) {
|
2766
|
-
this.coerceKey(key, value);
|
2767
|
-
return this;
|
2768
|
-
}
|
2769
|
-
Dur(key, nsec) {
|
2770
|
-
this._attributes[key] = logValue(`${nsec}ms`, toLogValueCtx(this.levelHandler));
|
2771
|
-
return this;
|
2772
|
-
}
|
2773
|
-
Uint64(key, value) {
|
2774
|
-
this.coerceKey(key, value);
|
2775
|
-
return this;
|
2776
|
-
}
|
2777
|
-
Int(key, value) {
|
2778
|
-
return this.Uint64(key, value);
|
2779
|
-
}
|
2780
|
-
async Flush() {
|
2781
|
-
return new Promise((resolve) => {
|
2782
|
-
this._logWriter._flush(void 0, resolve);
|
2783
|
-
});
|
2784
|
-
}
|
2785
|
-
With() {
|
2786
|
-
return new WithLoggerBuilder(
|
2787
|
-
new _LoggerImpl({
|
2788
|
-
logWriter: this._logWriter,
|
2789
|
-
sys: this._sys,
|
2790
|
-
levelHandler: this.levelHandler,
|
2791
|
-
formatter: this._formatter,
|
2792
|
-
withAttributes: {
|
2793
|
-
module: this._attributes["module"],
|
2794
|
-
...this._withAttributes
|
2795
|
-
}
|
2796
|
-
})
|
2797
|
-
);
|
2798
|
-
}
|
2799
|
-
_resetAttributes(fn) {
|
2800
|
-
const ret = fn();
|
2801
|
-
Object.keys(this._attributes).forEach((key) => {
|
2802
|
-
delete this._attributes[key];
|
2803
|
-
});
|
2804
|
-
Object.assign(this._attributes, this._withAttributes);
|
2805
|
-
return ret;
|
2806
|
-
}
|
2807
|
-
Msg(...args) {
|
2808
|
-
const fnError = this._resetAttributes(() => {
|
2809
|
-
var _a, _b;
|
2810
|
-
const doWrite = this.levelHandler.isEnabled(
|
2811
|
-
(_a = toLogValue(this._attributes["level"])) == null ? void 0 : _a.value(),
|
2812
|
-
(_b = toLogValue(this._attributes["module"])) == null ? void 0 : _b.value()
|
2813
|
-
);
|
2814
|
-
this._attributes["msg"] = logValue(args.join(" "), toLogValueCtx(this.levelHandler));
|
2815
|
-
const msg = this._attributes["msg"].value();
|
2816
|
-
if (typeof msg === "string" && !msg.trim().length) {
|
2817
|
-
delete this._attributes["msg"];
|
2818
|
-
}
|
2819
|
-
let fnRet = () => this._formatter.format({ ...this._attributes });
|
2820
|
-
if (doWrite) {
|
2821
|
-
const encoded = fnRet();
|
2822
|
-
this._logWriter.write(encoded);
|
2823
|
-
fnRet = () => encoded;
|
2824
|
-
}
|
2825
|
-
return fnRet;
|
2826
|
-
});
|
2827
|
-
const asError = () => new Error(this._txtEnDe.decode(fnError()));
|
2828
|
-
return {
|
2829
|
-
ResultError: () => Result.Err(asError()),
|
2830
|
-
AsError: asError
|
2831
|
-
};
|
2832
|
-
}
|
2833
|
-
};
|
2834
|
-
var WithLoggerBuilder = class {
|
2835
|
-
constructor(li) {
|
2836
|
-
this._li = li;
|
2837
|
-
this.levelHandler = li.levelHandler;
|
2838
|
-
}
|
2839
|
-
TxtEnDe() {
|
2840
|
-
return this._li.TxtEnDe();
|
2841
|
-
}
|
2842
|
-
Logger() {
|
2843
|
-
Object.assign(this._li._withAttributes, this._li._attributes);
|
2844
|
-
return this._li;
|
2845
|
-
}
|
2846
|
-
Attributes() {
|
2847
|
-
return { ...this._li._attributes };
|
2848
|
-
}
|
2849
|
-
SetExposeStack(enable) {
|
2850
|
-
this._li.levelHandler.setExposeStack(enable);
|
2851
|
-
return this;
|
2852
|
-
}
|
2853
|
-
SetIgnoreAttribute(re) {
|
2854
|
-
this._li.levelHandler.setIgnoreAttr(re);
|
2855
|
-
return this;
|
2856
|
-
}
|
2857
|
-
SetFormatter(fmt) {
|
2858
|
-
this._li.SetFormatter(fmt);
|
2859
|
-
return this;
|
2860
|
-
}
|
2861
|
-
EnableLevel(level, ...modules) {
|
2862
|
-
this._li.levelHandler.enableLevel(level, ...modules);
|
2863
|
-
return this;
|
2864
|
-
}
|
2865
|
-
DisableLevel(level, ...modules) {
|
2866
|
-
this._li.levelHandler.enableLevel(level, ...modules);
|
2867
|
-
return this;
|
2868
|
-
}
|
2869
|
-
Module(key) {
|
2870
|
-
this._li.Module(key);
|
2871
|
-
return this;
|
2872
|
-
}
|
2873
|
-
SetDebug(...modules) {
|
2874
|
-
this._li.SetDebug(...modules);
|
2875
|
-
return this;
|
2876
|
-
}
|
2877
|
-
Http(...mix) {
|
2878
|
-
this._li.Http(...mix);
|
2879
|
-
return this;
|
2880
|
-
}
|
2881
|
-
Pair(x) {
|
2882
|
-
this._li.Pair(x);
|
2883
|
-
return this;
|
2884
|
-
}
|
2885
|
-
Str(key, value) {
|
2886
|
-
this._li.Str(key, value);
|
2887
|
-
return this;
|
2888
|
-
}
|
2889
|
-
Len(value, key) {
|
2890
|
-
this._li.Len(value, key);
|
2891
|
-
return this;
|
2892
|
-
}
|
2893
|
-
Hash(value, key) {
|
2894
|
-
this._li.Hash(value, key);
|
2895
|
-
return this;
|
2896
|
-
}
|
2897
|
-
Ref(key, action) {
|
2898
|
-
this._li.Ref(key, action);
|
2899
|
-
return this;
|
2900
|
-
}
|
2901
|
-
Bool(key, value) {
|
2902
|
-
this._li.Bool(key, value);
|
2903
|
-
return this;
|
2904
|
-
}
|
2905
|
-
Result(key, res) {
|
2906
|
-
this._li.Result(key, res);
|
2907
|
-
return this;
|
2908
|
-
}
|
2909
|
-
Url(url, key) {
|
2910
|
-
this._li.Url(url, key);
|
2911
|
-
return this;
|
2912
|
-
}
|
2913
|
-
Int(key, value) {
|
2914
|
-
this._li.Int(key, value);
|
2915
|
-
return this;
|
2916
|
-
}
|
2917
|
-
Log() {
|
2918
|
-
this._li.Log();
|
2919
|
-
return this;
|
2920
|
-
}
|
2921
|
-
WithLevel(level) {
|
2922
|
-
this._li.WithLevel(level);
|
2923
|
-
return this;
|
2924
|
-
}
|
2925
|
-
Error() {
|
2926
|
-
this._li.Error();
|
2927
|
-
return this;
|
2928
|
-
}
|
2929
|
-
Warn() {
|
2930
|
-
this._li.Error();
|
2931
|
-
return this;
|
2932
|
-
}
|
2933
|
-
Debug() {
|
2934
|
-
this._li.Debug();
|
2935
|
-
return this;
|
2936
|
-
}
|
2937
|
-
Err(err) {
|
2938
|
-
this._li.Err(err);
|
2939
|
-
return this;
|
2940
|
-
}
|
2941
|
-
Info() {
|
2942
|
-
this._li.Info();
|
2943
|
-
return this;
|
2944
|
-
}
|
2945
|
-
Timestamp() {
|
2946
|
-
this._li.Timestamp();
|
2947
|
-
return this;
|
2948
|
-
}
|
2949
|
-
Any(key, value) {
|
2950
|
-
this._li.Any(key, value);
|
2951
|
-
return this;
|
2952
|
-
}
|
2953
|
-
Dur(key, nsec) {
|
2954
|
-
this._li.Dur(key, nsec);
|
2955
|
-
return this;
|
2956
|
-
}
|
2957
|
-
Uint64(key, value) {
|
2958
|
-
this._li.Uint64(key, value);
|
2959
|
-
return this;
|
2960
|
-
}
|
2961
|
-
};
|
2962
|
-
|
2963
|
-
// src/test/mock-logger.ts
|
2964
|
-
function MockLogger(params) {
|
2965
|
-
const lc = new LogCollector(params == null ? void 0 : params.pass);
|
2966
|
-
let modNames = ["MockLogger"];
|
2967
|
-
if (typeof (params == null ? void 0 : params.moduleName) === "string") {
|
2968
|
-
modNames = [params == null ? void 0 : params.moduleName];
|
2969
|
-
} else if (Array.isArray(params == null ? void 0 : params.moduleName)) {
|
2970
|
-
modNames = [...params.moduleName, ...modNames];
|
2971
|
-
}
|
2972
|
-
const logger = new LoggerImpl({
|
2973
|
-
out: lc,
|
2974
|
-
sys: params == null ? void 0 : params.sys,
|
2975
|
-
levelHandler: new LevelHandlerImpl()
|
2976
|
-
}).With().Module(modNames[0]).Logger();
|
2977
|
-
if (!(params == null ? void 0 : params.disableDebug)) {
|
2978
|
-
logger.SetDebug(...modNames);
|
2979
|
-
}
|
2980
|
-
return {
|
2981
|
-
logCollector: lc,
|
2982
|
-
logger
|
2983
|
-
};
|
2984
|
-
}
|
2985
|
-
// Annotate the CommonJS export names for ESM import in node:
|
2986
|
-
0 && (module.exports = {
|
2987
|
-
LogCollector,
|
2988
|
-
LogWriteStream,
|
2989
|
-
MockLogger
|
2990
|
-
});
|
2991
|
-
//# sourceMappingURL=index.cjs.map
|