@adviser/cement 0.0.0-jsr-t1
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +201 -0
- package/README.md +39 -0
- package/base-sys-abstraction-BkEiLHl0.d.ts +193 -0
- package/base-sys-abstraction-Qj7pkY1N.d.cts +193 -0
- package/chunk-7KFVMTOS.js +311 -0
- package/chunk-7KFVMTOS.js.map +1 -0
- package/chunk-GES3MUGV.js +92 -0
- package/chunk-GES3MUGV.js.map +1 -0
- package/chunk-Q65HLCNL.js +601 -0
- package/chunk-Q65HLCNL.js.map +1 -0
- package/chunk-WMMUXBDX.js +87 -0
- package/chunk-WMMUXBDX.js.map +1 -0
- package/index-Q3phXzYr.d.cts +75 -0
- package/index-tIGZMHTc.d.ts +75 -0
- package/index.cjs +2593 -0
- package/index.cjs.map +1 -0
- package/index.d.cts +532 -0
- package/index.d.ts +532 -0
- package/index.js +1533 -0
- package/index.js.map +1 -0
- package/node/index.cjs +924 -0
- package/node/index.cjs.map +1 -0
- package/node/index.d.cts +65 -0
- package/node/index.d.ts +65 -0
- package/node/index.js +398 -0
- package/node/index.js.map +1 -0
- package/package.json +81 -0
- package/src/base-sys-abstraction.test.ts +95 -0
- package/src/base-sys-abstraction.ts +242 -0
- package/src/bin2text.test.ts +59 -0
- package/src/bin2text.ts +47 -0
- package/src/crypto.test.ts +15 -0
- package/src/crypto.ts +125 -0
- package/src/file-service.ts +24 -0
- package/src/future.test.ts +32 -0
- package/src/future.ts +27 -0
- package/src/index.ts +22 -0
- package/src/jsr.json +20 -0
- package/src/log-level-impl.ts +87 -0
- package/src/log-writer-impl.ts +58 -0
- package/src/logger-impl.ts +498 -0
- package/src/logger.test.ts +1132 -0
- package/src/logger.ts +208 -0
- package/src/node/deno-file-service.ts +92 -0
- package/src/node/deno-sys-abstraction.ts +133 -0
- package/src/node/index.ts +4 -0
- package/src/node/mock-file-service.ts +45 -0
- package/src/node/node-file-service.ts +91 -0
- package/src/node/node-sys-abstraction.ts +121 -0
- package/src/option.ts +60 -0
- package/src/resolve-once.test.ts +321 -0
- package/src/resolve-once.ts +179 -0
- package/src/result.test.ts +102 -0
- package/src/result.ts +165 -0
- package/src/runtime.ts +36 -0
- package/src/sys-abstraction.ts +53 -0
- package/src/sys-env.test.ts +53 -0
- package/src/sys-env.ts +216 -0
- package/src/test/log-write-stream.ts +95 -0
- package/src/test/mock-logger.ts +40 -0
- package/src/time.ts +20 -0
- package/src/tracer.test.ts +314 -0
- package/src/tracer.ts +222 -0
- package/src/txt-en-decoder.ts +21 -0
- package/src/uri.test.ts +155 -0
- package/src/uri.ts +421 -0
- package/src/utils/console-write-stream.ts +72 -0
- package/src/utils/fanout-write-stream.ts +32 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/rebuffer.ts +75 -0
- package/src/utils/stream-map.ts +67 -0
- package/src/utils/stream2string.ts +47 -0
- package/src/utils/string2stream.ts +14 -0
- package/src/version.ts +3 -0
- package/src/web/index.ts +1 -0
- package/src/web/web-sys-abstraction.ts +80 -0
- package/ts/LICENSE +201 -0
- package/ts/README.md +39 -0
- package/ts/base-sys-abstraction.d.ts +84 -0
- package/ts/base-sys-abstraction.d.ts.map +1 -0
- package/ts/base-sys-abstraction.js +178 -0
- package/ts/base-sys-abstraction.js.map +1 -0
- package/ts/base-sys-abstraction.test.d.ts +2 -0
- package/ts/base-sys-abstraction.test.d.ts.map +1 -0
- package/ts/base-sys-abstraction.test.js +82 -0
- package/ts/base-sys-abstraction.test.js.map +1 -0
- package/ts/bin2text.d.ts +3 -0
- package/ts/bin2text.d.ts.map +1 -0
- package/ts/bin2text.js +43 -0
- package/ts/bin2text.js.map +1 -0
- package/ts/bin2text.test.d.ts +2 -0
- package/ts/bin2text.test.d.ts.map +1 -0
- package/ts/bin2text.test.js +51 -0
- package/ts/bin2text.test.js.map +1 -0
- package/ts/crypto.d.ts +76 -0
- package/ts/crypto.d.ts.map +1 -0
- package/ts/crypto.js +22 -0
- package/ts/crypto.js.map +1 -0
- package/ts/crypto.test.d.ts +2 -0
- package/ts/crypto.test.d.ts.map +1 -0
- package/ts/crypto.test.js +14 -0
- package/ts/crypto.test.js.map +1 -0
- package/ts/file-service.d.ts +17 -0
- package/ts/file-service.d.ts.map +1 -0
- package/ts/file-service.js +2 -0
- package/ts/file-service.js.map +1 -0
- package/ts/future.d.ts +8 -0
- package/ts/future.d.ts.map +1 -0
- package/ts/future.js +38 -0
- package/ts/future.js.map +1 -0
- package/ts/future.test.d.ts +2 -0
- package/ts/future.test.d.ts.map +1 -0
- package/ts/future.test.js +28 -0
- package/ts/future.test.js.map +1 -0
- package/ts/index.d.ts +23 -0
- package/ts/index.d.ts.map +1 -0
- package/ts/index.js +23 -0
- package/ts/index.js.map +1 -0
- package/ts/log-level-impl.d.ts +14 -0
- package/ts/log-level-impl.d.ts.map +1 -0
- package/ts/log-level-impl.js +72 -0
- package/ts/log-level-impl.js.map +1 -0
- package/ts/log-writer-impl.d.ts +10 -0
- package/ts/log-writer-impl.d.ts.map +1 -0
- package/ts/log-writer-impl.js +45 -0
- package/ts/log-writer-impl.js.map +1 -0
- package/ts/logger-impl.d.ts +71 -0
- package/ts/logger-impl.d.ts.map +1 -0
- package/ts/logger-impl.js +412 -0
- package/ts/logger-impl.js.map +1 -0
- package/ts/logger.d.ts +84 -0
- package/ts/logger.d.ts.map +1 -0
- package/ts/logger.js +114 -0
- package/ts/logger.js.map +1 -0
- package/ts/logger.test.d.ts +2 -0
- package/ts/logger.test.d.ts.map +1 -0
- package/ts/logger.test.js +1023 -0
- package/ts/logger.test.js.map +1 -0
- package/ts/node/deno-file-service.d.ts +17 -0
- package/ts/node/deno-file-service.d.ts.map +1 -0
- package/ts/node/deno-file-service.js +65 -0
- package/ts/node/deno-file-service.js.map +1 -0
- package/ts/node/deno-sys-abstraction.d.ts +22 -0
- package/ts/node/deno-sys-abstraction.d.ts.map +1 -0
- package/ts/node/deno-sys-abstraction.js +101 -0
- package/ts/node/deno-sys-abstraction.js.map +1 -0
- package/ts/node/index.d.ts +5 -0
- package/ts/node/index.d.ts.map +1 -0
- package/ts/node/index.js +5 -0
- package/ts/node/index.js.map +1 -0
- package/ts/node/mock-file-service.d.ts +11 -0
- package/ts/node/mock-file-service.d.ts.map +1 -0
- package/ts/node/mock-file-service.js +34 -0
- package/ts/node/mock-file-service.js.map +1 -0
- package/ts/node/mock-file-service.test.d.ts +2 -0
- package/ts/node/mock-file-service.test.d.ts.map +1 -0
- package/ts/node/mock-file-service.test.js +31 -0
- package/ts/node/mock-file-service.test.js.map +1 -0
- package/ts/node/node-file-service.d.ts +16 -0
- package/ts/node/node-file-service.d.ts.map +1 -0
- package/ts/node/node-file-service.js +71 -0
- package/ts/node/node-file-service.js.map +1 -0
- package/ts/node/node-sys-abstraction.d.ts +22 -0
- package/ts/node/node-sys-abstraction.d.ts.map +1 -0
- package/ts/node/node-sys-abstraction.js +99 -0
- package/ts/node/node-sys-abstraction.js.map +1 -0
- package/ts/node/node-sys-abstraction.test.d.ts +2 -0
- package/ts/node/node-sys-abstraction.test.d.ts.map +1 -0
- package/ts/node/node-sys-abstraction.test.js +87 -0
- package/ts/node/node-sys-abstraction.test.js.map +1 -0
- package/ts/option.d.ts +25 -0
- package/ts/option.d.ts.map +1 -0
- package/ts/option.js +47 -0
- package/ts/option.js.map +1 -0
- package/ts/resolve-once.d.ts +46 -0
- package/ts/resolve-once.d.ts.map +1 -0
- package/ts/resolve-once.js +152 -0
- package/ts/resolve-once.js.map +1 -0
- package/ts/resolve-once.test.d.ts +2 -0
- package/ts/resolve-once.test.d.ts.map +1 -0
- package/ts/resolve-once.test.js +283 -0
- package/ts/resolve-once.test.js.map +1 -0
- package/ts/result.d.ts +34 -0
- package/ts/result.d.ts.map +1 -0
- package/ts/result.js +85 -0
- package/ts/result.js.map +1 -0
- package/ts/result.test.d.ts +2 -0
- package/ts/result.test.d.ts.map +1 -0
- package/ts/result.test.js +79 -0
- package/ts/result.test.js.map +1 -0
- package/ts/runtime.d.ts +8 -0
- package/ts/runtime.d.ts.map +1 -0
- package/ts/runtime.js +26 -0
- package/ts/runtime.js.map +1 -0
- package/ts/sys-abstraction.d.ts +36 -0
- package/ts/sys-abstraction.d.ts.map +1 -0
- package/ts/sys-abstraction.js +31 -0
- package/ts/sys-abstraction.js.map +1 -0
- package/ts/sys-env.d.ts +48 -0
- package/ts/sys-env.d.ts.map +1 -0
- package/ts/sys-env.js +176 -0
- package/ts/sys-env.js.map +1 -0
- package/ts/sys-env.test.d.ts +2 -0
- package/ts/sys-env.test.d.ts.map +1 -0
- package/ts/sys-env.test.js +51 -0
- package/ts/sys-env.test.js.map +1 -0
- package/ts/test/log-write-stream.d.ts +27 -0
- package/ts/test/log-write-stream.d.ts.map +1 -0
- package/ts/test/log-write-stream.js +74 -0
- package/ts/test/log-write-stream.js.map +1 -0
- package/ts/test/mock-logger.d.ts +14 -0
- package/ts/test/mock-logger.d.ts.map +1 -0
- package/ts/test/mock-logger.js +29 -0
- package/ts/test/mock-logger.js.map +1 -0
- package/ts/test/mock-logger.test.d.ts +2 -0
- package/ts/test/mock-logger.test.d.ts.map +1 -0
- package/ts/test/mock-logger.test.js +63 -0
- package/ts/test/mock-logger.test.js.map +1 -0
- package/ts/test/test-exit-handler.d.ts +2 -0
- package/ts/test/test-exit-handler.d.ts.map +1 -0
- package/ts/test/test-exit-handler.js +57 -0
- package/ts/test/test-exit-handler.js.map +1 -0
- package/ts/time.d.ts +13 -0
- package/ts/time.d.ts.map +1 -0
- package/ts/time.js +14 -0
- package/ts/time.js.map +1 -0
- package/ts/tracer.d.ts +59 -0
- package/ts/tracer.d.ts.map +1 -0
- package/ts/tracer.js +148 -0
- package/ts/tracer.js.map +1 -0
- package/ts/tracer.test.d.ts +2 -0
- package/ts/tracer.test.d.ts.map +1 -0
- package/ts/tracer.test.js +311 -0
- package/ts/tracer.test.js.map +1 -0
- package/ts/txt-en-decoder.d.ts +10 -0
- package/ts/txt-en-decoder.d.ts.map +1 -0
- package/ts/txt-en-decoder.js +15 -0
- package/ts/txt-en-decoder.js.map +1 -0
- package/ts/uri.d.ts +67 -0
- package/ts/uri.d.ts.map +1 -0
- package/ts/uri.js +283 -0
- package/ts/uri.js.map +1 -0
- package/ts/uri.test.d.ts +2 -0
- package/ts/uri.test.d.ts.map +1 -0
- package/ts/uri.test.js +119 -0
- package/ts/uri.test.js.map +1 -0
- package/ts/utils/console-write-stream.d.ts +21 -0
- package/ts/utils/console-write-stream.d.ts.map +1 -0
- package/ts/utils/console-write-stream.js +62 -0
- package/ts/utils/console-write-stream.js.map +1 -0
- package/ts/utils/fanout-write-stream.d.ts +12 -0
- package/ts/utils/fanout-write-stream.d.ts.map +1 -0
- package/ts/utils/fanout-write-stream.js +24 -0
- package/ts/utils/fanout-write-stream.js.map +1 -0
- package/ts/utils/index.d.ts +7 -0
- package/ts/utils/index.d.ts.map +1 -0
- package/ts/utils/index.js +7 -0
- package/ts/utils/index.js.map +1 -0
- package/ts/utils/rebuffer.d.ts +3 -0
- package/ts/utils/rebuffer.d.ts.map +1 -0
- package/ts/utils/rebuffer.js +60 -0
- package/ts/utils/rebuffer.js.map +1 -0
- package/ts/utils/rebuffer.test.d.ts +2 -0
- package/ts/utils/rebuffer.test.d.ts.map +1 -0
- package/ts/utils/rebuffer.test.js +77 -0
- package/ts/utils/rebuffer.test.js.map +1 -0
- package/ts/utils/stream-map.d.ts +9 -0
- package/ts/utils/stream-map.d.ts.map +1 -0
- package/ts/utils/stream-map.js +62 -0
- package/ts/utils/stream-map.js.map +1 -0
- package/ts/utils/stream-map.test.d.ts +2 -0
- package/ts/utils/stream-map.test.d.ts.map +1 -0
- package/ts/utils/stream-map.test.js +87 -0
- package/ts/utils/stream-map.test.js.map +1 -0
- package/ts/utils/stream-test-helper.d.ts +17 -0
- package/ts/utils/stream-test-helper.d.ts.map +1 -0
- package/ts/utils/stream-test-helper.js +37 -0
- package/ts/utils/stream-test-helper.js.map +1 -0
- package/ts/utils/stream2string.d.ts +3 -0
- package/ts/utils/stream2string.d.ts.map +1 -0
- package/ts/utils/stream2string.js +48 -0
- package/ts/utils/stream2string.js.map +1 -0
- package/ts/utils/stream2string.test.d.ts +2 -0
- package/ts/utils/stream2string.test.d.ts.map +1 -0
- package/ts/utils/stream2string.test.js +29 -0
- package/ts/utils/stream2string.test.js.map +1 -0
- package/ts/utils/string2stream.d.ts +4 -0
- package/ts/utils/string2stream.d.ts.map +1 -0
- package/ts/utils/string2stream.js +13 -0
- package/ts/utils/string2stream.js.map +1 -0
- package/ts/utils/string2stream.test.d.ts +2 -0
- package/ts/utils/string2stream.test.d.ts.map +1 -0
- package/ts/utils/string2stream.test.js +6 -0
- package/ts/utils/string2stream.test.js.map +1 -0
- package/ts/version.d.ts +2 -0
- package/ts/version.d.ts.map +1 -0
- package/ts/version.js +4 -0
- package/ts/version.js.map +1 -0
- package/ts/web/index.d.ts +2 -0
- package/ts/web/index.d.ts.map +1 -0
- package/ts/web/index.js +2 -0
- package/ts/web/index.js.map +1 -0
- package/ts/web/web-sys-abstraction.d.ts +4 -0
- package/ts/web/web-sys-abstraction.d.ts.map +1 -0
- package/ts/web/web-sys-abstraction.js +64 -0
- package/ts/web/web-sys-abstraction.js.map +1 -0
- package/txt-en-decoder-CZYJUju2.d.cts +11 -0
- package/txt-en-decoder-CZYJUju2.d.ts +11 -0
- package/utils/index.cjs +341 -0
- package/utils/index.cjs.map +1 -0
- package/utils/index.d.cts +2 -0
- package/utils/index.d.ts +2 -0
- package/utils/index.js +32 -0
- package/utils/index.js.map +1 -0
- package/web/index.cjs +593 -0
- package/web/index.cjs.map +1 -0
- package/web/index.d.cts +6 -0
- package/web/index.d.ts +6 -0
- package/web/index.js +9 -0
- package/web/index.js.map +1 -0
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../src/node/index.ts","../../../src/node/node-file-service.ts","../../../src/txt-en-decoder.ts","../../../src/time.ts","../../../src/base-sys-abstraction.ts","../../../src/future.ts","../../../src/resolve-once.ts","../../../src/sys-env.ts","../../../src/node/node-sys-abstraction.ts","../../../src/node/deno-sys-abstraction.ts","../../../src/node/deno-file-service.ts","../../../src/node/mock-file-service.ts"],"sourcesContent":["export * from \"./node-file-service.js\";\nexport * from \"./node-sys-abstraction.js\";\nexport * from \"./deno-sys-abstraction.js\";\nexport * from \"./mock-file-service.js\";\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport process from \"node:process\";\nimport { FileService, NamedWritableStream } from \"../file-service.js\";\nimport { TxtEnDecoder, Utf8EnDecoderSingleton } from \"../txt-en-decoder.js\";\n\nexport class NodeFileService implements FileService {\n readonly baseDir: string;\n constructor(baseDir: string = process.cwd()) {\n this.baseDir = this.abs(baseDir);\n }\n\n // nodeImport(fname: string): string {\n // // console.log('nodeImport:'+ fname);\n // if (path.isAbsolute(fname)) {\n // return fname;\n // } else {\n // return \"./\" + path.normalize(fname);\n // }\n // }\n\n readFileString(fname: string): Promise<string> {\n return fs.promises.readFile(fname, { encoding: \"utf-8\" });\n }\n\n dirname(fname: string): string {\n return path.dirname(fname);\n }\n basename(fname: string): string {\n return path.basename(fname);\n }\n\n join(...paths: string[]): string {\n return path.join(...paths);\n }\n\n relative(from: string, to?: string): string {\n if (to === undefined) {\n to = from;\n from = process.cwd();\n }\n const ret = path.relative(from, to);\n // console.log('relative:'+ from + \" -> \" + to + \"= \" + ret);\n return ret;\n }\n\n abs(fname: string): string {\n if (path.isAbsolute(fname)) {\n return fname;\n } else {\n const cwd = process.cwd();\n return path.resolve(cwd, fname);\n }\n }\n\n isAbsolute(fname: string): boolean {\n return path.isAbsolute(fname);\n }\n\n async writeFileString(fname: string, content: string, ende: TxtEnDecoder = Utf8EnDecoderSingleton()): Promise<void> {\n const o = await this.create(fname);\n const wr = o.stream.getWriter();\n await wr.write(ende.encode(content));\n await wr.close();\n }\n\n async create(fname: string): Promise<NamedWritableStream> {\n let oName = fname;\n if (!path.isAbsolute(fname)) {\n oName = this.abs(fname);\n }\n\n const base = path.dirname(oName);\n await fs.promises.mkdir(base, { recursive: true });\n const out = fs.createWriteStream(oName);\n return {\n name: oName,\n stream: new WritableStream<Uint8Array>({\n write(chunk): void {\n out.write(chunk);\n },\n close(): void {\n out.close();\n },\n abort(): void {\n throw new Error(\"not implemented\");\n },\n }),\n };\n }\n}\n","export interface TxtEnDecoder {\n encode(str: string): Uint8Array;\n decode(data: Uint8Array): string;\n}\n\nconst encoder = new TextEncoder();\nconst decoder = new TextDecoder();\n\nexport class Utf8EnDecoder implements TxtEnDecoder {\n encode(str: string): Uint8Array {\n return encoder.encode(str);\n }\n decode(data: Uint8Array): string {\n return decoder.decode(data);\n }\n}\n\nconst utf8EnDecoder = new Utf8EnDecoder();\nexport function Utf8EnDecoderSingleton(): TxtEnDecoder {\n return utf8EnDecoder;\n}\n","export abstract class Time {\n abstract Now(add?: number): Date;\n abstract Sleep(duration: Duration): Promise<void>;\n TimeSince(start: Date): Duration {\n const now = this.Now();\n return now.getTime() - start.getTime();\n }\n}\n\nexport type Duration = number;\n\nexport enum TimeUnits {\n Microsecond = 1,\n // eslint-disable-next-line @typescript-eslint/prefer-literal-enum-member\n Second = 1000 * Microsecond,\n // eslint-disable-next-line @typescript-eslint/prefer-literal-enum-member\n Minute = 60 * Second,\n // eslint-disable-next-line @typescript-eslint/prefer-literal-enum-member\n Hour = 60 * Minute,\n}\n","import { FileService } from \"./file-service.js\";\nimport { TimeMode, RandomMode, IDMode, SystemService, VoidFunc, SysAbstraction } from \"./sys-abstraction.js\";\nimport { Time } from \"./time.js\";\nimport { TxtEnDecoder } from \"./txt-en-decoder.js\";\n\nexport class SysTime extends Time {\n Now(): Date {\n return new Date();\n }\n Sleep(duration: number): Promise<void> {\n return new Promise((resolve) => {\n setTimeout(() => {\n resolve();\n }, duration);\n });\n }\n}\n\nexport class ConstTime extends Time {\n Now(): Date {\n return new Date(2021, 1, 1, 0, 0, 0, 0);\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n Sleep(duration: number): Promise<void> {\n return Promise.resolve();\n }\n}\n\nexport class StepTime extends Time {\n _step: Date;\n readonly _start: Date;\n constructor() {\n super();\n this._step = new ConstTime().Now();\n this._start = this._step;\n }\n Now(steps = 1): Date {\n // if (this._step.getTime() === 0) {\n // this._step = new ConstTime().Now();\n // return this._step;\n // }\n for (let i = 0; steps > 0 && i < steps; i++) {\n this._step = new Date(this._step.getTime() + 1000);\n }\n if (steps < 1) {\n this._step = new Date(this._start.getTime() + steps * -1000);\n }\n // this._step = new Date(this._step.getTime() + 1000);\n return this._step;\n }\n Sleep(duration: number): Promise<void> {\n this._step = new Date(this._step.getTime() + duration);\n return Promise.resolve();\n }\n}\n\nexport function TimeFactory(timeMode: TimeMode): Time {\n switch (timeMode) {\n case TimeMode.REAL:\n return new SysTime();\n case TimeMode.CONST:\n return new ConstTime();\n case TimeMode.STEP:\n return new StepTime();\n }\n return new SysTime();\n}\n\nexport class RandomService {\n readonly _mode: RandomMode;\n _step = 0;\n constructor(mode: RandomMode) {\n this._mode = mode;\n }\n Random0ToValue(value: number): number {\n switch (this._mode) {\n case RandomMode.CONST:\n return 0.5 * value;\n case RandomMode.STEP:\n this._step += 0.0001;\n return this._step * value;\n case RandomMode.RANDOM:\n return Math.random() * value;\n default:\n throw new Error(\"Unknown RandomMode\");\n }\n }\n}\n\nexport class IdService {\n readonly _mode: IDMode;\n _step = 0;\n constructor(mode?: IDMode) {\n if (!mode) {\n mode = IDMode.UUID;\n }\n this._mode = mode;\n }\n NextId(): string {\n switch (this._mode) {\n case IDMode.UUID:\n return crypto.randomUUID();\n case IDMode.CONST:\n return \"VeryUniqueID\";\n case IDMode.STEP:\n return `STEPId-${this._step++}`;\n default:\n throw new Error(\"Unknown IDMode\");\n }\n }\n}\n\nexport interface BaseSysAbstractionParams {\n readonly TxtEnDecoder: TxtEnDecoder;\n readonly FileSystem: FileService;\n readonly SystemService: SystemService;\n}\n\nexport interface ExitHandler {\n readonly hdl: VoidFunc;\n readonly id: string;\n}\n\nexport interface ExitService {\n injectExitHandlers(hdls: ExitHandler[]): void;\n exit(code: number): void;\n}\n\nexport class BaseSysAbstraction {\n readonly _time: SysTime = new SysTime();\n readonly _stdout: WritableStream;\n readonly _stderr: WritableStream;\n\n readonly _idService: IdService = new IdService();\n readonly _randomService: RandomService = new RandomService(RandomMode.RANDOM);\n readonly _fileSystem: FileService;\n readonly _systemService: SystemService;\n readonly _txtEnDe: TxtEnDecoder;\n\n constructor(params: BaseSysAbstractionParams) {\n this._fileSystem = params.FileSystem;\n this._systemService = params.SystemService;\n this._txtEnDe = params.TxtEnDecoder;\n const decoder = this._txtEnDe;\n this._stdout = new WritableStream({\n write(chunk): Promise<void> {\n return new Promise((resolve) => {\n const decoded = decoder.decode(chunk);\n // eslint-disable-next-line no-console\n console.log(decoded.trimEnd());\n resolve();\n });\n },\n });\n this._stderr = new WritableStream({\n write(chunk): Promise<void> {\n return new Promise((resolve) => {\n const decoded = decoder.decode(chunk);\n // eslint-disable-next-line no-console\n console.error(decoded.trimEnd());\n resolve();\n });\n },\n });\n }\n}\n\nexport interface WrapperSysAbstractionParams {\n readonly TimeMode?: TimeMode;\n readonly IdMode?: IDMode;\n readonly Stdout?: WritableStream<Uint8Array>;\n readonly Stderr?: WritableStream<Uint8Array>;\n readonly RandomMode?: RandomMode;\n readonly FileSystem?: FileService;\n readonly SystemService?: SystemService;\n readonly TxtEnDecoder?: TxtEnDecoder;\n}\n\nexport class WrapperSysAbstraction implements SysAbstraction {\n readonly _time: Time;\n readonly _stdout: WritableStream<Uint8Array>;\n readonly _stderr: WritableStream<Uint8Array>;\n readonly _idService: IdService;\n readonly _randomService: RandomService;\n readonly _fileSystem: FileService;\n readonly _systemService: SystemService;\n constructor(base: BaseSysAbstraction, params?: WrapperSysAbstractionParams) {\n this._time = base._time;\n this._stdout = base._stdout;\n this._stderr = base._stderr;\n this._idService = base._idService;\n this._randomService = base._randomService;\n this._fileSystem = base._fileSystem;\n this._systemService = base._systemService;\n if (params) {\n if (params.TimeMode) {\n this._time = TimeFactory(params.TimeMode);\n }\n if (params.Stdout) {\n this._stdout = params.Stdout;\n }\n if (params.Stderr) {\n this._stderr = params.Stderr;\n }\n if (params.IdMode) {\n this._idService = new IdService(params.IdMode);\n }\n if (params.RandomMode) {\n this._randomService = new RandomService(params.RandomMode);\n }\n if (params.FileSystem) {\n this._fileSystem = params.FileSystem;\n }\n if (params.SystemService) {\n this._systemService = params.SystemService;\n }\n }\n }\n Time(): Time {\n return this._time;\n }\n NextId(): string {\n return this._idService.NextId();\n }\n Random0ToValue(value: number): number {\n return this._randomService.Random0ToValue(value);\n }\n Stdout(): WritableStream {\n return this._stdout;\n }\n Stderr(): WritableStream {\n return this._stderr;\n }\n\n System(): SystemService {\n return this._systemService;\n }\n FileSystem(): FileService {\n return this._fileSystem;\n }\n}\n// export const BaseSysAbstraction = new BaseSysAbstractionImpl()\n","export class Future<T> {\n readonly #promise: Promise<T>;\n #resolveFn: (value: T) => void = () => {\n throw new Error(\"This Promise is not working as expected.\");\n };\n #rejectFn: (reason: unknown) => void = () => {\n throw new Error(\"This Promise is not working as expected.\");\n };\n\n constructor() {\n this.#promise = new Promise<T>((resolve, reject) => {\n this.#resolveFn = resolve;\n this.#rejectFn = reject;\n });\n }\n\n async asPromise(): Promise<T> {\n return this.#promise;\n }\n\n resolve(value: T): void {\n this.#resolveFn(value);\n }\n reject(reason: unknown): void {\n this.#rejectFn(reason);\n }\n}\n","import { Future } from \"./future.js\";\n\ninterface ResolveSeqItem<T, C> {\n readonly future: Future<T>;\n readonly fn: (c: C) => Promise<T>;\n readonly id?: number;\n}\n\nexport class ResolveSeq<T, C = void> {\n readonly ctx: C;\n constructor(ctx?: C) {\n this.ctx = ctx as C;\n }\n reset(): void {\n /* noop */\n }\n async _step(item?: ResolveSeqItem<T, C> | undefined): Promise<void> {\n if (!item) {\n // done\n return;\n }\n item\n .fn(this.ctx)\n .then((value) => item.future.resolve(value))\n .catch((e) => item.future.reject(e as Error))\n .finally(() => {\n this._seqFutures.shift();\n this._step(this._seqFutures[0]);\n });\n }\n readonly _seqFutures: ResolveSeqItem<T, C>[] = [];\n async add(fn: (c: C) => Promise<T>, id?: number): Promise<T> {\n const future = new Future<T>();\n this._seqFutures.push({ future, fn, id });\n if (this._seqFutures.length === 1) {\n this._step(this._seqFutures[0]);\n }\n return future.asPromise();\n }\n}\n\nexport class ResolveOnce<T, CTX = void> {\n _onceDone = false;\n readonly _onceFutures: Future<T>[] = [];\n _onceOk = false;\n _onceValue?: T;\n _onceError?: Error;\n _isPromise = false;\n\n readonly ctx: CTX;\n\n constructor(ctx?: CTX) {\n this.ctx = ctx as CTX;\n }\n\n get ready(): boolean {\n return this._onceDone;\n }\n\n reset(): void {\n this._onceDone = false;\n this._onceOk = false;\n this._onceValue = undefined;\n this._onceError = undefined;\n this._onceFutures.length = 0;\n }\n\n // T extends Option<infer U> ? U : T\n once<R>(fn: (c: CTX) => R): R {\n if (this._onceDone) {\n if (this._onceError) {\n if (this._isPromise) {\n return Promise.reject(this._onceError) as unknown as R;\n } else {\n throw this._onceError;\n }\n }\n if (this._onceOk) {\n if (this._isPromise) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return Promise.resolve(this._onceValue!) as unknown as R;\n } else {\n return this._onceValue as unknown as R;\n }\n }\n throw new Error(\"ResolveOnce.once impossible\");\n }\n const future = new Future<T>();\n this._onceFutures.push(future);\n if (this._onceFutures.length === 1) {\n const okFn = (value: T): void => {\n this._onceValue = value;\n this._onceOk = true;\n this._onceDone = true;\n if (this._isPromise) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this._onceFutures.forEach((f) => f.resolve(this._onceValue!));\n }\n this._onceFutures.length = 0;\n };\n const catchFn = (e: Error): void => {\n this._onceError = e as Error;\n this._onceOk = false;\n this._onceValue = undefined;\n this._onceDone = true;\n if (this._isPromise) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this._onceFutures.forEach((f) => f.reject(this._onceError!));\n }\n this._onceFutures.length = 0;\n };\n try {\n const ret = fn(this.ctx);\n if (typeof (ret as Promise<T>).then === \"function\") {\n this._isPromise = true;\n (ret as Promise<T>).then(okFn).catch(catchFn);\n } else {\n okFn(ret as unknown as T);\n }\n } catch (e) {\n catchFn(e as Error);\n }\n }\n if (this._isPromise) {\n return future.asPromise() as unknown as R;\n } else {\n // abit funky but i don't want to impl the return just once\n return this.once(fn);\n }\n }\n}\n\nexport class Keyed<T extends { reset: () => void }, K = string> {\n private readonly _map = new Map<K, T>();\n\n readonly factory: (key: K) => T;\n constructor(factory: (key: K) => T) {\n this.factory = factory;\n }\n\n async asyncGet(key: () => Promise<K>): Promise<T> {\n return this.get(await key());\n }\n\n get(key: K | (() => K)): T {\n if (typeof key === \"function\") {\n key = (key as () => K)();\n }\n let keyed = this._map.get(key);\n if (!keyed) {\n keyed = this.factory(key);\n this._map.set(key, keyed);\n }\n return keyed;\n }\n\n unget(key: K): void {\n const keyed = this._map.get(key);\n keyed?.reset();\n this._map.delete(key);\n }\n\n reset(): void {\n this._map.forEach((keyed) => keyed.reset());\n this._map.clear();\n }\n}\n\nexport class KeyedResolvOnce<T, K = string> extends Keyed<ResolveOnce<T, K>, K> {\n constructor() {\n super((key) => new ResolveOnce<T, K>(key));\n }\n}\n\nexport class KeyedResolvSeq<T, K = string> extends Keyed<ResolveSeq<T, K>, K> {\n constructor() {\n super((key) => new ResolveSeq<T, K>(key));\n }\n}\n","import { ResolveOnce } from \"./resolve-once.js\";\n\nexport interface EnvMap {\n get(key: string): string | undefined;\n set(key: string, value?: string): void;\n delete(key: string): void;\n keys(): string[];\n}\nexport interface EnvActions extends EnvMap {\n active(): boolean;\n register(env: Env): Env;\n}\n\nclass NodeEnvActions implements EnvActions {\n readonly #node = globalThis as unknown as { process: { env: Record<string, string> } };\n\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor, @typescript-eslint/no-unused-vars\n constructor(opts: Partial<EnvFactoryOpts>) {\n // do nothing\n }\n\n register(env: Env): Env {\n return env;\n }\n\n active(): boolean {\n return typeof this.#node === \"object\" && typeof this.#node.process === \"object\" && typeof this.#node.process.env === \"object\";\n }\n readonly _env = this.active() ? this.#node.process.env : {};\n keys(): string[] {\n return Object.keys(this._env);\n }\n get(key: string): string | undefined {\n return this._env[key];\n }\n set(key: string, value?: string): void {\n if (value) {\n this._env[key] = value;\n }\n }\n delete(key: string): void {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._env[key];\n }\n}\n\nclass DenoEnvActions implements EnvActions {\n readonly #deno = globalThis as unknown as { Deno: { env: Map<string, string> } };\n\n get _env(): Map<string, string> {\n return this.#deno.Deno.env;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor, @typescript-eslint/no-unused-vars\n constructor(opts: Partial<EnvFactoryOpts>) {\n // do nothing\n }\n\n register(env: Env): Env {\n return env;\n }\n active(): boolean {\n return typeof this.#deno === \"object\" && typeof this.#deno.Deno === \"object\" && typeof this.#deno.Deno.env === \"object\";\n }\n keys(): string[] {\n return Array.from(this._env.keys());\n }\n get(key: string): string | undefined {\n return this._env.get(key);\n }\n set(key: string, value?: string): void {\n if (value) {\n this._env.set(key, value);\n }\n }\n delete(key: string): void {\n this._env.delete(key);\n }\n}\n\nexport class BrowserEnvActions implements EnvActions {\n readonly env: Map<string, string> = new Map<string, string>();\n readonly opts: Partial<EnvFactoryOpts>;\n constructor(opts: Partial<EnvFactoryOpts>) {\n this.opts = opts;\n }\n\n get(key: string): string | undefined {\n return this.env.get(key);\n }\n set(key: string, value?: string): void {\n if (value) {\n this.env.set(key, value);\n }\n }\n delete(key: string): void {\n this.env.delete(key);\n }\n keys(): string[] {\n return Array.from(this.env.keys());\n }\n active(): boolean {\n return true; // that should work on every runtime\n }\n\n register(env: Env): Env {\n const sym = Symbol.for(this.opts.symbol || \"CP_ENV\");\n const browser = globalThis as unknown as Record<symbol, Env>;\n browser[sym] = env;\n return env;\n }\n}\n\nexport interface EnvFactoryOpts {\n readonly symbol: string; // default \"CP_ENV\" used by BrowserEnvActions\n readonly presetEnv: Map<string, string>;\n}\n\ntype OnSetFn = (key: string, value?: string) => void;\nexport interface OnSetItem {\n readonly filter: Set<string>;\n readonly fn: OnSetFn;\n}\n\nexport interface Env extends EnvMap {\n onSet(fn: OnSetFn, ...filter: string[]): void;\n}\n\nconst _envFactory = new ResolveOnce<Env>();\nexport function envFactory(opts: Partial<EnvFactoryOpts> = {}): Env {\n return _envFactory.once(() => {\n const found = [new NodeEnvActions(opts), new DenoEnvActions(opts), new BrowserEnvActions(opts)].find((env) => env.active());\n if (!found) {\n throw new Error(\"SysContainer:envFactory: no env available\");\n }\n const ret = new EnvImpl(found, opts);\n found.register(ret);\n return ret;\n });\n}\n\nexport class EnvImpl implements Env {\n readonly _map: EnvMap;\n constructor(map: EnvMap, opts: Partial<EnvFactoryOpts> = {}) {\n this._map = map;\n this._updatePresets(opts.presetEnv);\n }\n _updatePresets(presetEnv?: Map<string, string>): void {\n if (!presetEnv) {\n return;\n }\n for (const [key, value] of presetEnv) {\n this._map.set(key, value);\n }\n }\n _applyOnSet(onSet: OnSetItem[], key?: string, value?: string): void {\n onSet.forEach((item) => {\n let keys: string[] = [];\n if (key) {\n keys = [key];\n } else {\n keys = this._map.keys();\n }\n keys\n .filter((k) => {\n if (item.filter.size === 0) {\n return true;\n }\n if (item.filter.has(k)) {\n return true;\n }\n return false;\n })\n .forEach((k) => {\n let v;\n if (!key && !value) {\n // init\n v = this._map.get(k);\n } else if (key && !value) {\n // del\n v = undefined;\n } else {\n // set\n v = value;\n }\n item.fn(k, v);\n });\n });\n }\n readonly _onSet: OnSetItem[] = [];\n keys(): string[] {\n return this._map.keys();\n }\n // filter is not set all sets passed\n onSet(fn: OnSetFn, ...filter: string[]): void {\n const item: OnSetItem = { filter: new Set(filter), fn };\n this._onSet.push(item);\n this._applyOnSet([item]);\n }\n get(key: string): string | undefined {\n return this._map.get(key);\n }\n set(key: string, value?: string): void {\n if (!value) {\n return;\n }\n this._map.set(key, value);\n this._applyOnSet(this._onSet, key, value);\n }\n delete(key: string): void {\n this._map.delete(key);\n this._applyOnSet(this._onSet, key);\n }\n}\n\n// export const envImpl = new EnvImpl();\n","import { SysAbstraction, SystemService, VoidFunc } from \"../sys-abstraction.js\";\nimport {\n BaseSysAbstraction,\n ExitHandler,\n ExitService,\n WrapperSysAbstraction,\n WrapperSysAbstractionParams,\n} from \"../base-sys-abstraction.js\";\nimport { NodeFileService } from \"./node-file-service.js\";\nimport { Env, envFactory } from \"../sys-env.js\";\nimport { Utf8EnDecoderSingleton } from \"../txt-en-decoder.js\";\nimport process from \"node:process\";\n\nexport class NodeExitServiceImpl implements ExitService {\n constructor() {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n process.on(\"unhandledRejection\", (reason: string, p: Promise<unknown>) => {\n this.exit(19);\n });\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n process.on(\"uncaughtException\", (error: Error) => {\n this.exit(18);\n });\n process.on(\"close\", () => {\n this.exit(0);\n });\n process.on(\"exit\", () => {\n this.exit(0);\n });\n process.on(\"SIGQUIT\", () => {\n this.exit(3);\n });\n process.on(\"SIGINT\", () => {\n this.exit(2);\n });\n process.on(\"SIGTERM\", () => {\n this.exit(9);\n });\n }\n _exitHandlers: ExitHandler[] = [];\n injectExitHandlers(hdls: ExitHandler[]): void {\n // console.log(\"ExitService: injecting exit handlers\", hdls)\n this._exitHandlers = hdls;\n }\n invoked = false;\n readonly _handleExit = async (): Promise<void> => {\n if (this.invoked) {\n // console.error(\"ExitService: already invoked\");\n return;\n }\n this.invoked = true;\n for (const h of this._exitHandlers) {\n try {\n // console.log(`ExitService: calling handler ${h.id}`)\n const ret = h.hdl();\n // console.log(`ExitService: called handler ${h.id}`, ret)\n if (typeof (ret as Promise<void>).then === \"function\") {\n await ret;\n }\n } finally {\n // ignore\n }\n }\n };\n\n exit(code: number): void {\n // console.log(\"ExitService: exit called\", code)\n this._handleExit()\n .then(() => {\n process.exit(code);\n })\n .catch((err) => {\n // eslint-disable-next-line no-console\n console.error(\"ExitService: failed to handle exit\", err);\n process.exit(code);\n });\n }\n}\n\nexport class NodeSystemService implements SystemService {\n static readonly _exitHandlers: ExitHandler[] = [];\n readonly _exitService: ExitService = new NodeExitServiceImpl();\n constructor() {\n this._exitService.injectExitHandlers(NodeSystemService._exitHandlers);\n }\n\n Env(): Env {\n return envFactory();\n }\n\n Args(): string[] {\n return process.argv;\n }\n\n OnExit(hdl: VoidFunc): VoidFunc {\n const id = crypto.randomUUID();\n NodeSystemService._exitHandlers.push({ hdl, id });\n return () => {\n const idx = NodeSystemService._exitHandlers.findIndex((h) => h.id === id);\n if (idx >= 0) {\n NodeSystemService._exitHandlers.splice(idx, 1);\n }\n };\n }\n\n Exit(code: number): void {\n this._exitService.exit(code);\n }\n}\n\nlet my: BaseSysAbstraction | undefined = undefined;\nexport function NodeSysAbstraction(param?: WrapperSysAbstractionParams): SysAbstraction {\n if (!my) {\n my = new BaseSysAbstraction({\n TxtEnDecoder: param?.TxtEnDecoder || Utf8EnDecoderSingleton(),\n FileSystem: new NodeFileService(),\n SystemService: new NodeSystemService(),\n });\n }\n return new WrapperSysAbstraction(my, param);\n}\n","import { SysAbstraction, SystemService, VoidFunc } from \"../sys-abstraction.js\";\nimport {\n BaseSysAbstraction,\n ExitHandler,\n ExitService,\n WrapperSysAbstraction,\n WrapperSysAbstractionParams,\n} from \"../base-sys-abstraction.js\";\nimport { Env, envFactory } from \"../sys-env.js\";\nimport { Utf8EnDecoderSingleton } from \"../txt-en-decoder.js\";\nimport * as process from \"node:process\";\nimport { DenoFileService } from \"./deno-file-service.js\";\n\nconst Deno = (globalThis as unknown as { Deno: unknown }).Deno as {\n addSignalListener(sig: string, hdl: () => void): void;\n exit(code?: number): void;\n};\n\nexport class DenoExitServiceImpl implements ExitService {\n constructor() {\n globalThis.addEventListener(\"unhandledrejection\", (e) => {\n e.preventDefault();\n this.exit(19);\n });\n globalThis.addEventListener(\"error\", () => {\n this.exit(19);\n });\n globalThis.addEventListener(\"uncaughtException\", () => {\n this.exit(19);\n });\n\n // process.on(\"close\", () => {\n // this.exit(0);\n // });\n globalThis.addEventListener(\"unload\", () => {\n this.exit(0);\n // console.log('goodbye!');\n });\n\n // process.on(\"exit\", () => {\n // });\n Deno.addSignalListener(\"SIGQUIT\", () => {\n this.exit(3);\n });\n Deno.addSignalListener(\"SIGINT\", () => {\n this.exit(2);\n });\n Deno.addSignalListener(\"SIGTERM\", () => {\n this.exit(9);\n });\n }\n _exitHandlers: ExitHandler[] = [];\n injectExitHandlers(hdls: ExitHandler[]): void {\n // console.log(\"ExitService: injecting exit handlers\", hdls)\n this._exitHandlers = hdls;\n }\n invoked = false;\n readonly _handleExit = async (): Promise<void> => {\n if (this.invoked) {\n // console.error(\"ExitService: already invoked\");\n return;\n }\n this.invoked = true;\n for (const h of this._exitHandlers) {\n try {\n // console.log(`ExitService: calling handler ${h.id}`)\n const ret = h.hdl();\n // console.log(`ExitService: called handler ${h.id}`, ret)\n if (typeof (ret as Promise<void>).then === \"function\") {\n await ret;\n }\n } finally {\n // ignore\n }\n }\n };\n\n exit(code: number): void {\n // console.log(\"ExitService: exit called\", code)\n this._handleExit()\n .then(() => {\n Deno.exit(code);\n })\n .catch((err) => {\n // eslint-disable-next-line no-console\n console.error(\"ExitService: failed to handle exit\", err);\n Deno.exit(code);\n });\n }\n}\n\nexport class DenoSystemService implements SystemService {\n static readonly _exitHandlers: ExitHandler[] = [];\n readonly _exitService: ExitService = new DenoExitServiceImpl();\n constructor() {\n this._exitService.injectExitHandlers(DenoSystemService._exitHandlers);\n }\n\n Env(): Env {\n return envFactory();\n }\n\n Args(): string[] {\n return process.argv;\n }\n\n OnExit(hdl: VoidFunc): VoidFunc {\n const id = crypto.randomUUID();\n DenoSystemService._exitHandlers.push({ hdl, id });\n return () => {\n const idx = DenoSystemService._exitHandlers.findIndex((h) => h.id === id);\n if (idx >= 0) {\n DenoSystemService._exitHandlers.splice(idx, 1);\n }\n };\n }\n\n Exit(code: number): void {\n this._exitService.exit(code);\n }\n}\n\nlet my: BaseSysAbstraction | undefined = undefined;\nexport function DenoSysAbstraction(param?: WrapperSysAbstractionParams): SysAbstraction {\n if (!my) {\n my = new BaseSysAbstraction({\n TxtEnDecoder: param?.TxtEnDecoder || Utf8EnDecoderSingleton(),\n FileSystem: new DenoFileService(),\n SystemService: new DenoSystemService(),\n });\n }\n return new WrapperSysAbstraction(my, param);\n}\n","import { FileService, NamedWritableStream } from \"../file-service.js\";\nimport { TxtEnDecoder, Utf8EnDecoderSingleton } from \"../txt-en-decoder.js\";\nimport * as path from \"node:path\";\n\nconst Deno = (globalThis as unknown as { Deno: unknown }).Deno as {\n cwd(): string;\n readFile(fname: string): Promise<Uint8Array>;\n mkdir(base: string, options: { recursive: boolean }): Promise<void>;\n open(fname: string, options: { write: boolean; create: boolean; truncate: boolean }): Promise<WritableStream>;\n};\n\nexport class DenoFileService implements FileService {\n readonly baseDir: string;\n readonly txtEnde: TxtEnDecoder;\n constructor(baseDir: string = Deno.cwd(), txtEnde: TxtEnDecoder = Utf8EnDecoderSingleton()) {\n this.baseDir = this.abs(baseDir);\n this.txtEnde = txtEnde;\n }\n\n // nodeImport(fname: string): string {\n // // console.log('nodeImport:'+ fname);\n // if (path.isAbsolute(fname)) {\n // return fname;\n // } else {\n // return \"./\" + path.normalize(fname);\n // }\n // }\n\n async readFileString(fname: string): Promise<string> {\n return this.txtEnde.decode(await Deno.readFile(fname));\n }\n\n dirname(fname: string): string {\n return path.dirname(fname);\n }\n basename(fname: string): string {\n return path.basename(fname);\n }\n\n join(...paths: string[]): string {\n return path.join(...paths);\n }\n\n relative(from: string, to?: string): string {\n if (to === undefined) {\n to = from;\n from = Deno.cwd();\n }\n const ret = path.relative(from, to);\n // console.log('relative:'+ from + \" -> \" + to + \"= \" + ret);\n return ret;\n }\n\n abs(fname: string): string {\n if (path.isAbsolute(fname)) {\n return fname;\n } else {\n const cwd = Deno.cwd();\n return path.resolve(cwd, fname);\n }\n }\n\n isAbsolute(fname: string): boolean {\n return path.isAbsolute(fname);\n }\n\n async writeFileString(fname: string, content: string, ende = Utf8EnDecoderSingleton()): Promise<void> {\n const o = await this.create(fname);\n const wr = o.stream.getWriter();\n await wr.write(ende.encode(content));\n await wr.close();\n }\n\n async create(fname: string): Promise<NamedWritableStream> {\n let oName = fname;\n if (!path.isAbsolute(fname)) {\n oName = this.abs(fname);\n }\n\n const base = path.dirname(oName);\n await Deno.mkdir(base, { recursive: true });\n const out = await Deno.open(oName, {\n write: true,\n create: true,\n truncate: true,\n });\n return {\n name: oName,\n stream: out,\n };\n }\n}\n","import { NamedWritableStream } from \"../file-service.js\";\nimport { NodeFileService } from \"./node-file-service.js\";\n\nexport interface FileCollector {\n readonly name: string;\n content: string;\n}\n\nexport class MockFileService extends NodeFileService {\n readonly files = {} as Record<string, FileCollector>;\n\n // override abs(fname: string): string {\n // return this.join(\"/mock/\", fname);\n // }\n\n override async create(fname: string): Promise<NamedWritableStream> {\n let oName = fname;\n if (!this.isAbsolute(fname)) {\n oName = await this.abs(fname);\n }\n\n const fc = {\n name: oName,\n content: \"\",\n };\n this.files[oName] = fc;\n this.files[fname] = fc;\n const decoder = new TextDecoder();\n\n return {\n name: oName,\n stream: new WritableStream<Uint8Array>({\n write(chunk): void {\n fc.content = fc.content + decoder.decode(chunk);\n },\n close(): void {\n // do nothing\n },\n abort(): void {\n throw new Error(\"not implemented\");\n },\n }),\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,uBAAiB;AACjB,qBAAe;AACf,0BAAoB;;;ACGpB,IAAM,UAAU,IAAI,YAAY;AAChC,IAAM,UAAU,IAAI,YAAY;AAEzB,IAAM,gBAAN,MAA4C;AAAA,EACjD,OAAO,KAAyB;AAC9B,WAAO,QAAQ,OAAO,GAAG;AAAA,EAC3B;AAAA,EACA,OAAO,MAA0B;AAC/B,WAAO,QAAQ,OAAO,IAAI;AAAA,EAC5B;AACF;AAEA,IAAM,gBAAgB,IAAI,c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AChD;AAAA,QACA,QAAc;AAAA,QAEd;AAAA,QACA,QAAc;AACZ,gBAAM,IAAI,MAAM,iBAAiB;AAAA,QACnC;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":["process","fs","path","resolve","decoder","resolve","import_node_process","process","process","path","Deno","my","decoder"]}
|
package/node/index.d.cts
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
import { F as FileService, N as NamedWritableStream, q as ExitService, p as ExitHandler, c as SystemService, f as Env, V as VoidFunc, W as WrapperSysAbstractionParams, S as SysAbstraction } from '../base-sys-abstraction-Qj7pkY1N.cjs';
|
2
|
+
import { T as TxtEnDecoder } from '../txt-en-decoder-CZYJUju2.cjs';
|
3
|
+
|
4
|
+
declare class NodeFileService implements FileService {
|
5
|
+
readonly baseDir: string;
|
6
|
+
constructor(baseDir?: string);
|
7
|
+
readFileString(fname: string): Promise<string>;
|
8
|
+
dirname(fname: string): string;
|
9
|
+
basename(fname: string): string;
|
10
|
+
join(...paths: string[]): string;
|
11
|
+
relative(from: string, to?: string): string;
|
12
|
+
abs(fname: string): string;
|
13
|
+
isAbsolute(fname: string): boolean;
|
14
|
+
writeFileString(fname: string, content: string, ende?: TxtEnDecoder): Promise<void>;
|
15
|
+
create(fname: string): Promise<NamedWritableStream>;
|
16
|
+
}
|
17
|
+
|
18
|
+
declare class NodeExitServiceImpl implements ExitService {
|
19
|
+
constructor();
|
20
|
+
_exitHandlers: ExitHandler[];
|
21
|
+
injectExitHandlers(hdls: ExitHandler[]): void;
|
22
|
+
invoked: boolean;
|
23
|
+
readonly _handleExit: () => Promise<void>;
|
24
|
+
exit(code: number): void;
|
25
|
+
}
|
26
|
+
declare class NodeSystemService implements SystemService {
|
27
|
+
static readonly _exitHandlers: ExitHandler[];
|
28
|
+
readonly _exitService: ExitService;
|
29
|
+
constructor();
|
30
|
+
Env(): Env;
|
31
|
+
Args(): string[];
|
32
|
+
OnExit(hdl: VoidFunc): VoidFunc;
|
33
|
+
Exit(code: number): void;
|
34
|
+
}
|
35
|
+
declare function NodeSysAbstraction(param?: WrapperSysAbstractionParams): SysAbstraction;
|
36
|
+
|
37
|
+
declare class DenoExitServiceImpl implements ExitService {
|
38
|
+
constructor();
|
39
|
+
_exitHandlers: ExitHandler[];
|
40
|
+
injectExitHandlers(hdls: ExitHandler[]): void;
|
41
|
+
invoked: boolean;
|
42
|
+
readonly _handleExit: () => Promise<void>;
|
43
|
+
exit(code: number): void;
|
44
|
+
}
|
45
|
+
declare class DenoSystemService implements SystemService {
|
46
|
+
static readonly _exitHandlers: ExitHandler[];
|
47
|
+
readonly _exitService: ExitService;
|
48
|
+
constructor();
|
49
|
+
Env(): Env;
|
50
|
+
Args(): string[];
|
51
|
+
OnExit(hdl: VoidFunc): VoidFunc;
|
52
|
+
Exit(code: number): void;
|
53
|
+
}
|
54
|
+
declare function DenoSysAbstraction(param?: WrapperSysAbstractionParams): SysAbstraction;
|
55
|
+
|
56
|
+
interface FileCollector {
|
57
|
+
readonly name: string;
|
58
|
+
content: string;
|
59
|
+
}
|
60
|
+
declare class MockFileService extends NodeFileService {
|
61
|
+
readonly files: Record<string, FileCollector>;
|
62
|
+
create(fname: string): Promise<NamedWritableStream>;
|
63
|
+
}
|
64
|
+
|
65
|
+
export { DenoExitServiceImpl, DenoSysAbstraction, DenoSystemService, type FileCollector, MockFileService, NodeExitServiceImpl, NodeFileService, NodeSysAbstraction, NodeSystemService };
|
package/node/index.d.ts
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
import { F as FileService, N as NamedWritableStream, q as ExitService, p as ExitHandler, c as SystemService, f as Env, V as VoidFunc, W as WrapperSysAbstractionParams, S as SysAbstraction } from '../base-sys-abstraction-BkEiLHl0.js';
|
2
|
+
import { T as TxtEnDecoder } from '../txt-en-decoder-CZYJUju2.js';
|
3
|
+
|
4
|
+
declare class NodeFileService implements FileService {
|
5
|
+
readonly baseDir: string;
|
6
|
+
constructor(baseDir?: string);
|
7
|
+
readFileString(fname: string): Promise<string>;
|
8
|
+
dirname(fname: string): string;
|
9
|
+
basename(fname: string): string;
|
10
|
+
join(...paths: string[]): string;
|
11
|
+
relative(from: string, to?: string): string;
|
12
|
+
abs(fname: string): string;
|
13
|
+
isAbsolute(fname: string): boolean;
|
14
|
+
writeFileString(fname: string, content: string, ende?: TxtEnDecoder): Promise<void>;
|
15
|
+
create(fname: string): Promise<NamedWritableStream>;
|
16
|
+
}
|
17
|
+
|
18
|
+
declare class NodeExitServiceImpl implements ExitService {
|
19
|
+
constructor();
|
20
|
+
_exitHandlers: ExitHandler[];
|
21
|
+
injectExitHandlers(hdls: ExitHandler[]): void;
|
22
|
+
invoked: boolean;
|
23
|
+
readonly _handleExit: () => Promise<void>;
|
24
|
+
exit(code: number): void;
|
25
|
+
}
|
26
|
+
declare class NodeSystemService implements SystemService {
|
27
|
+
static readonly _exitHandlers: ExitHandler[];
|
28
|
+
readonly _exitService: ExitService;
|
29
|
+
constructor();
|
30
|
+
Env(): Env;
|
31
|
+
Args(): string[];
|
32
|
+
OnExit(hdl: VoidFunc): VoidFunc;
|
33
|
+
Exit(code: number): void;
|
34
|
+
}
|
35
|
+
declare function NodeSysAbstraction(param?: WrapperSysAbstractionParams): SysAbstraction;
|
36
|
+
|
37
|
+
declare class DenoExitServiceImpl implements ExitService {
|
38
|
+
constructor();
|
39
|
+
_exitHandlers: ExitHandler[];
|
40
|
+
injectExitHandlers(hdls: ExitHandler[]): void;
|
41
|
+
invoked: boolean;
|
42
|
+
readonly _handleExit: () => Promise<void>;
|
43
|
+
exit(code: number): void;
|
44
|
+
}
|
45
|
+
declare class DenoSystemService implements SystemService {
|
46
|
+
static readonly _exitHandlers: ExitHandler[];
|
47
|
+
readonly _exitService: ExitService;
|
48
|
+
constructor();
|
49
|
+
Env(): Env;
|
50
|
+
Args(): string[];
|
51
|
+
OnExit(hdl: VoidFunc): VoidFunc;
|
52
|
+
Exit(code: number): void;
|
53
|
+
}
|
54
|
+
declare function DenoSysAbstraction(param?: WrapperSysAbstractionParams): SysAbstraction;
|
55
|
+
|
56
|
+
interface FileCollector {
|
57
|
+
readonly name: string;
|
58
|
+
content: string;
|
59
|
+
}
|
60
|
+
declare class MockFileService extends NodeFileService {
|
61
|
+
readonly files: Record<string, FileCollector>;
|
62
|
+
create(fname: string): Promise<NamedWritableStream>;
|
63
|
+
}
|
64
|
+
|
65
|
+
export { DenoExitServiceImpl, DenoSysAbstraction, DenoSystemService, type FileCollector, MockFileService, NodeExitServiceImpl, NodeFileService, NodeSysAbstraction, NodeSystemService };
|
package/node/index.js
ADDED
@@ -0,0 +1,398 @@
|
|
1
|
+
import {
|
2
|
+
BaseSysAbstraction,
|
3
|
+
WrapperSysAbstraction,
|
4
|
+
envFactory
|
5
|
+
} from "../chunk-Q65HLCNL.js";
|
6
|
+
import {
|
7
|
+
Utf8EnDecoderSingleton
|
8
|
+
} from "../chunk-GES3MUGV.js";
|
9
|
+
|
10
|
+
// src/node/node-file-service.ts
|
11
|
+
import path from "node:path";
|
12
|
+
import fs from "node:fs";
|
13
|
+
import process from "node:process";
|
14
|
+
var NodeFileService = class {
|
15
|
+
constructor(baseDir = process.cwd()) {
|
16
|
+
this.baseDir = this.abs(baseDir);
|
17
|
+
}
|
18
|
+
// nodeImport(fname: string): string {
|
19
|
+
// // console.log('nodeImport:'+ fname);
|
20
|
+
// if (path.isAbsolute(fname)) {
|
21
|
+
// return fname;
|
22
|
+
// } else {
|
23
|
+
// return "./" + path.normalize(fname);
|
24
|
+
// }
|
25
|
+
// }
|
26
|
+
readFileString(fname) {
|
27
|
+
return fs.promises.readFile(fname, { encoding: "utf-8" });
|
28
|
+
}
|
29
|
+
dirname(fname) {
|
30
|
+
return path.dirname(fname);
|
31
|
+
}
|
32
|
+
basename(fname) {
|
33
|
+
return path.basename(fname);
|
34
|
+
}
|
35
|
+
join(...paths) {
|
36
|
+
return path.join(...paths);
|
37
|
+
}
|
38
|
+
relative(from, to) {
|
39
|
+
if (to === void 0) {
|
40
|
+
to = from;
|
41
|
+
from = process.cwd();
|
42
|
+
}
|
43
|
+
const ret = path.relative(from, to);
|
44
|
+
return ret;
|
45
|
+
}
|
46
|
+
abs(fname) {
|
47
|
+
if (path.isAbsolute(fname)) {
|
48
|
+
return fname;
|
49
|
+
} else {
|
50
|
+
const cwd = process.cwd();
|
51
|
+
return path.resolve(cwd, fname);
|
52
|
+
}
|
53
|
+
}
|
54
|
+
isAbsolute(fname) {
|
55
|
+
return path.isAbsolute(fname);
|
56
|
+
}
|
57
|
+
async writeFileString(fname, content, ende = Utf8EnDecoderSingleton()) {
|
58
|
+
const o = await this.create(fname);
|
59
|
+
const wr = o.stream.getWriter();
|
60
|
+
await wr.write(ende.encode(content));
|
61
|
+
await wr.close();
|
62
|
+
}
|
63
|
+
async create(fname) {
|
64
|
+
let oName = fname;
|
65
|
+
if (!path.isAbsolute(fname)) {
|
66
|
+
oName = this.abs(fname);
|
67
|
+
}
|
68
|
+
const base = path.dirname(oName);
|
69
|
+
await fs.promises.mkdir(base, { recursive: true });
|
70
|
+
const out = fs.createWriteStream(oName);
|
71
|
+
return {
|
72
|
+
name: oName,
|
73
|
+
stream: new WritableStream({
|
74
|
+
write(chunk) {
|
75
|
+
out.write(chunk);
|
76
|
+
},
|
77
|
+
close() {
|
78
|
+
out.close();
|
79
|
+
},
|
80
|
+
abort() {
|
81
|
+
throw new Error("not implemented");
|
82
|
+
}
|
83
|
+
})
|
84
|
+
};
|
85
|
+
}
|
86
|
+
};
|
87
|
+
|
88
|
+
// src/node/node-sys-abstraction.ts
|
89
|
+
import process2 from "node:process";
|
90
|
+
var NodeExitServiceImpl = class {
|
91
|
+
constructor() {
|
92
|
+
this._exitHandlers = [];
|
93
|
+
this.invoked = false;
|
94
|
+
this._handleExit = async () => {
|
95
|
+
if (this.invoked) {
|
96
|
+
return;
|
97
|
+
}
|
98
|
+
this.invoked = true;
|
99
|
+
for (const h of this._exitHandlers) {
|
100
|
+
try {
|
101
|
+
const ret = h.hdl();
|
102
|
+
if (typeof ret.then === "function") {
|
103
|
+
await ret;
|
104
|
+
}
|
105
|
+
} finally {
|
106
|
+
}
|
107
|
+
}
|
108
|
+
};
|
109
|
+
process2.on("unhandledRejection", (reason, p) => {
|
110
|
+
this.exit(19);
|
111
|
+
});
|
112
|
+
process2.on("uncaughtException", (error) => {
|
113
|
+
this.exit(18);
|
114
|
+
});
|
115
|
+
process2.on("close", () => {
|
116
|
+
this.exit(0);
|
117
|
+
});
|
118
|
+
process2.on("exit", () => {
|
119
|
+
this.exit(0);
|
120
|
+
});
|
121
|
+
process2.on("SIGQUIT", () => {
|
122
|
+
this.exit(3);
|
123
|
+
});
|
124
|
+
process2.on("SIGINT", () => {
|
125
|
+
this.exit(2);
|
126
|
+
});
|
127
|
+
process2.on("SIGTERM", () => {
|
128
|
+
this.exit(9);
|
129
|
+
});
|
130
|
+
}
|
131
|
+
injectExitHandlers(hdls) {
|
132
|
+
this._exitHandlers = hdls;
|
133
|
+
}
|
134
|
+
exit(code) {
|
135
|
+
this._handleExit().then(() => {
|
136
|
+
process2.exit(code);
|
137
|
+
}).catch((err) => {
|
138
|
+
console.error("ExitService: failed to handle exit", err);
|
139
|
+
process2.exit(code);
|
140
|
+
});
|
141
|
+
}
|
142
|
+
};
|
143
|
+
var _NodeSystemService = class _NodeSystemService {
|
144
|
+
constructor() {
|
145
|
+
this._exitService = new NodeExitServiceImpl();
|
146
|
+
this._exitService.injectExitHandlers(_NodeSystemService._exitHandlers);
|
147
|
+
}
|
148
|
+
Env() {
|
149
|
+
return envFactory();
|
150
|
+
}
|
151
|
+
Args() {
|
152
|
+
return process2.argv;
|
153
|
+
}
|
154
|
+
OnExit(hdl) {
|
155
|
+
const id = crypto.randomUUID();
|
156
|
+
_NodeSystemService._exitHandlers.push({ hdl, id });
|
157
|
+
return () => {
|
158
|
+
const idx = _NodeSystemService._exitHandlers.findIndex((h) => h.id === id);
|
159
|
+
if (idx >= 0) {
|
160
|
+
_NodeSystemService._exitHandlers.splice(idx, 1);
|
161
|
+
}
|
162
|
+
};
|
163
|
+
}
|
164
|
+
Exit(code) {
|
165
|
+
this._exitService.exit(code);
|
166
|
+
}
|
167
|
+
};
|
168
|
+
_NodeSystemService._exitHandlers = [];
|
169
|
+
var NodeSystemService = _NodeSystemService;
|
170
|
+
var my = void 0;
|
171
|
+
function NodeSysAbstraction(param) {
|
172
|
+
if (!my) {
|
173
|
+
my = new BaseSysAbstraction({
|
174
|
+
TxtEnDecoder: (param == null ? void 0 : param.TxtEnDecoder) || Utf8EnDecoderSingleton(),
|
175
|
+
FileSystem: new NodeFileService(),
|
176
|
+
SystemService: new NodeSystemService()
|
177
|
+
});
|
178
|
+
}
|
179
|
+
return new WrapperSysAbstraction(my, param);
|
180
|
+
}
|
181
|
+
|
182
|
+
// src/node/deno-sys-abstraction.ts
|
183
|
+
import * as process3 from "node:process";
|
184
|
+
|
185
|
+
// src/node/deno-file-service.ts
|
186
|
+
import * as path2 from "node:path";
|
187
|
+
var Deno = globalThis.Deno;
|
188
|
+
var DenoFileService = class {
|
189
|
+
constructor(baseDir = Deno.cwd(), txtEnde = Utf8EnDecoderSingleton()) {
|
190
|
+
this.baseDir = this.abs(baseDir);
|
191
|
+
this.txtEnde = txtEnde;
|
192
|
+
}
|
193
|
+
// nodeImport(fname: string): string {
|
194
|
+
// // console.log('nodeImport:'+ fname);
|
195
|
+
// if (path.isAbsolute(fname)) {
|
196
|
+
// return fname;
|
197
|
+
// } else {
|
198
|
+
// return "./" + path.normalize(fname);
|
199
|
+
// }
|
200
|
+
// }
|
201
|
+
async readFileString(fname) {
|
202
|
+
return this.txtEnde.decode(await Deno.readFile(fname));
|
203
|
+
}
|
204
|
+
dirname(fname) {
|
205
|
+
return path2.dirname(fname);
|
206
|
+
}
|
207
|
+
basename(fname) {
|
208
|
+
return path2.basename(fname);
|
209
|
+
}
|
210
|
+
join(...paths) {
|
211
|
+
return path2.join(...paths);
|
212
|
+
}
|
213
|
+
relative(from, to) {
|
214
|
+
if (to === void 0) {
|
215
|
+
to = from;
|
216
|
+
from = Deno.cwd();
|
217
|
+
}
|
218
|
+
const ret = path2.relative(from, to);
|
219
|
+
return ret;
|
220
|
+
}
|
221
|
+
abs(fname) {
|
222
|
+
if (path2.isAbsolute(fname)) {
|
223
|
+
return fname;
|
224
|
+
} else {
|
225
|
+
const cwd = Deno.cwd();
|
226
|
+
return path2.resolve(cwd, fname);
|
227
|
+
}
|
228
|
+
}
|
229
|
+
isAbsolute(fname) {
|
230
|
+
return path2.isAbsolute(fname);
|
231
|
+
}
|
232
|
+
async writeFileString(fname, content, ende = Utf8EnDecoderSingleton()) {
|
233
|
+
const o = await this.create(fname);
|
234
|
+
const wr = o.stream.getWriter();
|
235
|
+
await wr.write(ende.encode(content));
|
236
|
+
await wr.close();
|
237
|
+
}
|
238
|
+
async create(fname) {
|
239
|
+
let oName = fname;
|
240
|
+
if (!path2.isAbsolute(fname)) {
|
241
|
+
oName = this.abs(fname);
|
242
|
+
}
|
243
|
+
const base = path2.dirname(oName);
|
244
|
+
await Deno.mkdir(base, { recursive: true });
|
245
|
+
const out = await Deno.open(oName, {
|
246
|
+
write: true,
|
247
|
+
create: true,
|
248
|
+
truncate: true
|
249
|
+
});
|
250
|
+
return {
|
251
|
+
name: oName,
|
252
|
+
stream: out
|
253
|
+
};
|
254
|
+
}
|
255
|
+
};
|
256
|
+
|
257
|
+
// src/node/deno-sys-abstraction.ts
|
258
|
+
var Deno2 = globalThis.Deno;
|
259
|
+
var DenoExitServiceImpl = class {
|
260
|
+
constructor() {
|
261
|
+
this._exitHandlers = [];
|
262
|
+
this.invoked = false;
|
263
|
+
this._handleExit = async () => {
|
264
|
+
if (this.invoked) {
|
265
|
+
return;
|
266
|
+
}
|
267
|
+
this.invoked = true;
|
268
|
+
for (const h of this._exitHandlers) {
|
269
|
+
try {
|
270
|
+
const ret = h.hdl();
|
271
|
+
if (typeof ret.then === "function") {
|
272
|
+
await ret;
|
273
|
+
}
|
274
|
+
} finally {
|
275
|
+
}
|
276
|
+
}
|
277
|
+
};
|
278
|
+
globalThis.addEventListener("unhandledrejection", (e) => {
|
279
|
+
e.preventDefault();
|
280
|
+
this.exit(19);
|
281
|
+
});
|
282
|
+
globalThis.addEventListener("error", () => {
|
283
|
+
this.exit(19);
|
284
|
+
});
|
285
|
+
globalThis.addEventListener("uncaughtException", () => {
|
286
|
+
this.exit(19);
|
287
|
+
});
|
288
|
+
globalThis.addEventListener("unload", () => {
|
289
|
+
this.exit(0);
|
290
|
+
});
|
291
|
+
Deno2.addSignalListener("SIGQUIT", () => {
|
292
|
+
this.exit(3);
|
293
|
+
});
|
294
|
+
Deno2.addSignalListener("SIGINT", () => {
|
295
|
+
this.exit(2);
|
296
|
+
});
|
297
|
+
Deno2.addSignalListener("SIGTERM", () => {
|
298
|
+
this.exit(9);
|
299
|
+
});
|
300
|
+
}
|
301
|
+
injectExitHandlers(hdls) {
|
302
|
+
this._exitHandlers = hdls;
|
303
|
+
}
|
304
|
+
exit(code) {
|
305
|
+
this._handleExit().then(() => {
|
306
|
+
Deno2.exit(code);
|
307
|
+
}).catch((err) => {
|
308
|
+
console.error("ExitService: failed to handle exit", err);
|
309
|
+
Deno2.exit(code);
|
310
|
+
});
|
311
|
+
}
|
312
|
+
};
|
313
|
+
var _DenoSystemService = class _DenoSystemService {
|
314
|
+
constructor() {
|
315
|
+
this._exitService = new DenoExitServiceImpl();
|
316
|
+
this._exitService.injectExitHandlers(_DenoSystemService._exitHandlers);
|
317
|
+
}
|
318
|
+
Env() {
|
319
|
+
return envFactory();
|
320
|
+
}
|
321
|
+
Args() {
|
322
|
+
return process3.argv;
|
323
|
+
}
|
324
|
+
OnExit(hdl) {
|
325
|
+
const id = crypto.randomUUID();
|
326
|
+
_DenoSystemService._exitHandlers.push({ hdl, id });
|
327
|
+
return () => {
|
328
|
+
const idx = _DenoSystemService._exitHandlers.findIndex((h) => h.id === id);
|
329
|
+
if (idx >= 0) {
|
330
|
+
_DenoSystemService._exitHandlers.splice(idx, 1);
|
331
|
+
}
|
332
|
+
};
|
333
|
+
}
|
334
|
+
Exit(code) {
|
335
|
+
this._exitService.exit(code);
|
336
|
+
}
|
337
|
+
};
|
338
|
+
_DenoSystemService._exitHandlers = [];
|
339
|
+
var DenoSystemService = _DenoSystemService;
|
340
|
+
var my2 = void 0;
|
341
|
+
function DenoSysAbstraction(param) {
|
342
|
+
if (!my2) {
|
343
|
+
my2 = new BaseSysAbstraction({
|
344
|
+
TxtEnDecoder: (param == null ? void 0 : param.TxtEnDecoder) || Utf8EnDecoderSingleton(),
|
345
|
+
FileSystem: new DenoFileService(),
|
346
|
+
SystemService: new DenoSystemService()
|
347
|
+
});
|
348
|
+
}
|
349
|
+
return new WrapperSysAbstraction(my2, param);
|
350
|
+
}
|
351
|
+
|
352
|
+
// src/node/mock-file-service.ts
|
353
|
+
var MockFileService = class extends NodeFileService {
|
354
|
+
constructor() {
|
355
|
+
super(...arguments);
|
356
|
+
this.files = {};
|
357
|
+
}
|
358
|
+
// override abs(fname: string): string {
|
359
|
+
// return this.join("/mock/", fname);
|
360
|
+
// }
|
361
|
+
async create(fname) {
|
362
|
+
let oName = fname;
|
363
|
+
if (!this.isAbsolute(fname)) {
|
364
|
+
oName = await this.abs(fname);
|
365
|
+
}
|
366
|
+
const fc = {
|
367
|
+
name: oName,
|
368
|
+
content: ""
|
369
|
+
};
|
370
|
+
this.files[oName] = fc;
|
371
|
+
this.files[fname] = fc;
|
372
|
+
const decoder = new TextDecoder();
|
373
|
+
return {
|
374
|
+
name: oName,
|
375
|
+
stream: new WritableStream({
|
376
|
+
write(chunk) {
|
377
|
+
fc.content = fc.content + decoder.decode(chunk);
|
378
|
+
},
|
379
|
+
close() {
|
380
|
+
},
|
381
|
+
abort() {
|
382
|
+
throw new Error("not implemented");
|
383
|
+
}
|
384
|
+
})
|
385
|
+
};
|
386
|
+
}
|
387
|
+
};
|
388
|
+
export {
|
389
|
+
DenoExitServiceImpl,
|
390
|
+
DenoSysAbstraction,
|
391
|
+
DenoSystemService,
|
392
|
+
MockFileService,
|
393
|
+
NodeExitServiceImpl,
|
394
|
+
NodeFileService,
|
395
|
+
NodeSysAbstraction,
|
396
|
+
NodeSystemService
|
397
|
+
};
|
398
|
+
//# sourceMappingURL=index.js.map
|