@adviser/cement 0.3.19 → 0.4.0
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-sys-abstraction-DgTynXGV.d.cts +95 -0
- package/base-sys-abstraction-h0dB3nZ5.d.ts +95 -0
- package/cf/index.cjs +232 -283
- package/cf/index.cjs.map +1 -1
- package/cf/index.d.cts +10 -8
- package/cf/index.d.ts +10 -8
- package/cf/index.js +6 -41
- package/cf/index.js.map +1 -1
- package/{chunk-GDTTUMIL.js → chunk-6F3ACVHD.js} +62 -22
- package/chunk-6F3ACVHD.js.map +1 -0
- package/{chunk-PHS255C5.js → chunk-FOALXQST.js} +1 -68
- package/chunk-FOALXQST.js.map +1 -0
- package/{chunk-23MCJYE6.js → chunk-X3IV2RYT.js} +422 -602
- package/chunk-X3IV2RYT.js.map +1 -0
- package/chunk-YKGCONBX.js +677 -0
- package/chunk-YKGCONBX.js.map +1 -0
- package/{chunk-55W4AK2Z.js → chunk-YVACAIUX.js} +5 -5
- package/deno/index.cjs +257 -241
- package/deno/index.cjs.map +1 -1
- package/deno/index.d.cts +3 -5
- package/deno/index.d.ts +3 -5
- package/deno/index.js +14 -16
- package/deno/index.js.map +1 -1
- package/{index-D1j1fPYg.d.ts → index-N0bkrgSt.d.ts} +15 -3
- package/{index-Cp1NspHH.d.cts → index-TtYD7HhB.d.cts} +15 -3
- package/index.cjs +1851 -1709
- package/index.cjs.map +1 -1
- package/index.d.cts +9 -8
- package/index.d.ts +9 -8
- package/index.js +21 -16
- package/index.js.map +1 -1
- package/metafile-cjs.json +1 -1
- package/metafile-esm.json +1 -1
- package/node/index.cjs +499 -474
- package/node/index.cjs.map +1 -1
- package/node/index.d.cts +3 -5
- package/node/index.d.ts +3 -5
- package/node/index.js +14 -16
- package/node/index.js.map +1 -1
- package/package.json +6 -6
- package/src/base-sys-abstraction.ts +106 -116
- package/src/cf/cf-basic-sys-abstraction.ts +79 -0
- package/src/cf/index.ts +1 -1
- package/src/cf-test-main.ts +10 -1
- package/src/deno/deno-basic-sys-abstraction.ts +39 -0
- package/src/deno/deno-file-service.ts +1 -1
- package/src/deno/deno-sys-abstraction.ts +19 -22
- package/src/jsr.json +1 -1
- package/src/log-writer-impl.ts +6 -0
- package/src/logger-impl.ts +17 -19
- package/src/node/node-basic-sys-abstraction.ts +59 -0
- package/src/node/node-sys-abstraction.ts +19 -22
- package/src/sys-abstraction.ts +12 -6
- package/src/test/mock-logger.ts +2 -2
- package/src/txt-en-decoder.ts +3 -3
- package/src/uri.ts +71 -0
- package/src/web/index.ts +1 -1
- package/src/web/web-basic-sys-abstraction.ts +105 -0
- package/{sys-abstraction-B0x6IE7r.d.ts → sys-abstraction-CeAxxg9H.d.ts} +11 -7
- package/{sys-abstraction-BTs3Vzy4.d.cts → sys-abstraction-DDAwGTnk.d.cts} +11 -7
- package/test/index.cjs +1534 -1419
- package/test/index.cjs.map +1 -1
- package/test/index.d.cts +2 -2
- package/test/index.d.ts +2 -2
- package/test/index.js +4 -5
- package/ts/smoke/smoke.js +7 -8
- package/ts/smoke/smoke.js.map +1 -1
- package/ts/src/base-basic-sys-abstraction.test.d.ts +2 -0
- package/ts/src/base-basic-sys-abstraction.test.d.ts.map +1 -0
- package/ts/src/{base-sys-abstraction.test.js → base-basic-sys-abstraction.test.js} +9 -9
- package/ts/src/base-basic-sys-abstraction.test.js.map +1 -0
- package/ts/src/base-sys-abstraction.d.ts +33 -21
- package/ts/src/base-sys-abstraction.d.ts.map +1 -1
- package/ts/src/base-sys-abstraction.js +54 -67
- package/ts/src/base-sys-abstraction.js.map +1 -1
- package/ts/src/cf/cf-basic-sys-abstraction.d.ts +14 -0
- package/ts/src/cf/cf-basic-sys-abstraction.d.ts.map +1 -0
- package/ts/src/cf/cf-basic-sys-abstraction.js +67 -0
- package/ts/src/cf/cf-basic-sys-abstraction.js.map +1 -0
- package/ts/src/cf/index.d.ts +1 -1
- package/ts/src/cf/index.d.ts.map +1 -1
- package/ts/src/cf/index.js +1 -1
- package/ts/src/cf/index.js.map +1 -1
- package/ts/src/cf-test-main.d.ts.map +1 -1
- package/ts/src/cf-test-main.js +7 -1
- package/ts/src/cf-test-main.js.map +1 -1
- package/ts/src/deno/deno-basic-sys-abstraction.d.ts +14 -0
- package/ts/src/deno/deno-basic-sys-abstraction.d.ts.map +1 -0
- package/ts/src/deno/deno-basic-sys-abstraction.js +35 -0
- package/ts/src/deno/deno-basic-sys-abstraction.js.map +1 -0
- package/ts/src/deno/deno-file-service.d.ts +1 -1
- package/ts/src/deno/deno-file-service.d.ts.map +1 -1
- package/ts/src/deno/deno-sys-abstraction.d.ts +3 -6
- package/ts/src/deno/deno-sys-abstraction.d.ts.map +1 -1
- package/ts/src/deno/deno-sys-abstraction.js +13 -17
- package/ts/src/deno/deno-sys-abstraction.js.map +1 -1
- package/ts/src/log-writer-impl.d.ts +1 -0
- package/ts/src/log-writer-impl.d.ts.map +1 -1
- package/ts/src/log-writer-impl.js +1 -0
- package/ts/src/log-writer-impl.js.map +1 -1
- package/ts/src/logger-impl.d.ts +3 -3
- package/ts/src/logger-impl.d.ts.map +1 -1
- package/ts/src/logger-impl.js +3 -18
- package/ts/src/logger-impl.js.map +1 -1
- package/ts/src/logger.test.js +3 -4
- package/ts/src/logger.test.js.map +1 -1
- package/ts/src/node/node-basic-sys-abstraction.d.ts +25 -0
- package/ts/src/node/node-basic-sys-abstraction.d.ts.map +1 -0
- package/ts/src/node/node-basic-sys-abstraction.js +44 -0
- package/ts/src/node/node-basic-sys-abstraction.js.map +1 -0
- package/ts/src/node/node-sys-abstraction.d.ts +3 -6
- package/ts/src/node/node-sys-abstraction.d.ts.map +1 -1
- package/ts/src/node/node-sys-abstraction.js +13 -17
- package/ts/src/node/node-sys-abstraction.js.map +1 -1
- package/ts/src/node/node-sys-abstraction.test.js +1 -1
- package/ts/src/node/node-sys-abstraction.test.js.map +1 -1
- package/ts/src/resolve-once.test.js +1 -1
- package/ts/src/sys-abstraction.d.ts +10 -6
- package/ts/src/sys-abstraction.d.ts.map +1 -1
- package/ts/src/test/mock-logger.d.ts +2 -2
- package/ts/src/test/mock-logger.d.ts.map +1 -1
- package/ts/src/test/mock-logger.js.map +1 -1
- package/ts/src/tracer.test.js +5 -8
- package/ts/src/tracer.test.js.map +1 -1
- package/ts/src/txt-en-decoder.d.ts.map +1 -1
- package/ts/src/txt-en-decoder.js +3 -3
- package/ts/src/txt-en-decoder.js.map +1 -1
- package/ts/src/uri.d.ts +12 -0
- package/ts/src/uri.d.ts.map +1 -1
- package/ts/src/uri.js +55 -0
- package/ts/src/uri.js.map +1 -1
- package/ts/src/uri.test.js +48 -0
- package/ts/src/uri.test.js.map +1 -1
- package/ts/src/web/index.d.ts +1 -1
- package/ts/src/web/index.d.ts.map +1 -1
- package/ts/src/web/index.js +1 -1
- package/ts/src/web/index.js.map +1 -1
- package/ts/src/web/web-basic-sys-abstraction.d.ts +4 -0
- package/ts/src/web/web-basic-sys-abstraction.d.ts.map +1 -0
- package/ts/src/web/web-basic-sys-abstraction.js +45 -0
- package/ts/src/web/web-basic-sys-abstraction.js.map +1 -0
- package/ts/vitest.workspace.d.ts +1 -1
- package/utils/index.cjs +132 -3
- package/utils/index.cjs.map +1 -1
- package/utils/index.js +5 -5
- package/web/index.cjs +277 -281
- package/web/index.cjs.map +1 -1
- package/web/index.d.cts +4 -17
- package/web/index.d.ts +4 -17
- package/web/index.js +4 -7
- package/base-sys-abstraction-BnBZ6zd0.d.ts +0 -84
- package/base-sys-abstraction-DAZ8tx5F.d.cts +0 -84
- package/chunk-23MCJYE6.js.map +0 -1
- package/chunk-GDTTUMIL.js.map +0 -1
- package/chunk-H6MLKWIZ.js +0 -88
- package/chunk-H6MLKWIZ.js.map +0 -1
- package/chunk-LXTKPZ6M.js +0 -255
- package/chunk-LXTKPZ6M.js.map +0 -1
- package/chunk-PHS255C5.js.map +0 -1
- package/src/cf/cf-sys-abstraction.ts +0 -34
- package/src/web/web-sys-abstraction.ts +0 -80
- package/ts/src/base-sys-abstraction.test.d.ts +0 -2
- package/ts/src/base-sys-abstraction.test.d.ts.map +0 -1
- package/ts/src/base-sys-abstraction.test.js.map +0 -1
- package/ts/src/cf/cf-sys-abstraction.d.ts +0 -11
- package/ts/src/cf/cf-sys-abstraction.d.ts.map +0 -1
- package/ts/src/cf/cf-sys-abstraction.js +0 -30
- package/ts/src/cf/cf-sys-abstraction.js.map +0 -1
- package/ts/src/web/web-sys-abstraction.d.ts +0 -18
- package/ts/src/web/web-sys-abstraction.d.ts.map +0 -1
- package/ts/src/web/web-sys-abstraction.js +0 -64
- package/ts/src/web/web-sys-abstraction.js.map +0 -1
- /package/{chunk-55W4AK2Z.js.map → chunk-YVACAIUX.js.map} +0 -0
@@ -1,15 +1,16 @@
|
|
1
|
-
import {
|
1
|
+
import { RuntimeSysAbstraction, SystemService, VoidFunc } from "../sys-abstraction.js";
|
2
2
|
import {
|
3
3
|
BaseSysAbstraction,
|
4
4
|
ExitHandler,
|
5
5
|
ExitService,
|
6
|
-
|
7
|
-
|
6
|
+
WrapperBasicSysAbstractionParams,
|
7
|
+
WrapperRuntimeSysAbstraction,
|
8
8
|
} from "../base-sys-abstraction.js";
|
9
9
|
import { NodeFileService } from "./node-file-service.js";
|
10
|
-
import { Env, envFactory } from "../sys-env.js";
|
11
10
|
import { TxtEnDecoderSingleton } from "../txt-en-decoder.js";
|
12
11
|
import process from "node:process";
|
12
|
+
import { ResolveOnce } from "../resolve-once.js";
|
13
|
+
import { NodeBasicSysAbstraction } from "./node-basic-sys-abstraction.js";
|
13
14
|
|
14
15
|
export class NodeExitServiceImpl implements ExitService {
|
15
16
|
constructor() {
|
@@ -84,14 +85,6 @@ export class NodeSystemService implements SystemService {
|
|
84
85
|
this._exitService.injectExitHandlers(NodeSystemService._exitHandlers);
|
85
86
|
}
|
86
87
|
|
87
|
-
Env(): Env {
|
88
|
-
return envFactory();
|
89
|
-
}
|
90
|
-
|
91
|
-
Args(): string[] {
|
92
|
-
return process.argv;
|
93
|
-
}
|
94
|
-
|
95
88
|
OnExit(hdl: VoidFunc): VoidFunc {
|
96
89
|
const id = crypto.randomUUID();
|
97
90
|
NodeSystemService._exitHandlers.push({ hdl, id });
|
@@ -108,14 +101,18 @@ export class NodeSystemService implements SystemService {
|
|
108
101
|
}
|
109
102
|
}
|
110
103
|
|
111
|
-
|
112
|
-
export function NodeSysAbstraction(param?:
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
104
|
+
const baseSysAbstraction = new ResolveOnce<BaseSysAbstraction>();
|
105
|
+
export function NodeSysAbstraction(param?: WrapperBasicSysAbstractionParams): RuntimeSysAbstraction {
|
106
|
+
const my = baseSysAbstraction.once(
|
107
|
+
() =>
|
108
|
+
new BaseSysAbstraction({
|
109
|
+
TxtEnDecoder: param?.TxtEnDecoder || TxtEnDecoderSingleton(),
|
110
|
+
FileSystem: new NodeFileService(),
|
111
|
+
SystemService: new NodeSystemService(),
|
112
|
+
}),
|
113
|
+
);
|
114
|
+
return new WrapperRuntimeSysAbstraction(my, {
|
115
|
+
basicRuntimeService: NodeBasicSysAbstraction(param),
|
116
|
+
...param,
|
117
|
+
});
|
121
118
|
}
|
package/src/sys-abstraction.ts
CHANGED
@@ -39,18 +39,24 @@ export function String2TimeMode(s?: string): TimeMode {
|
|
39
39
|
export type VoidFunc = () => void | Promise<void>;
|
40
40
|
|
41
41
|
export interface SystemService {
|
42
|
-
Env(): Env;
|
43
|
-
Args(): string[];
|
44
42
|
OnExit(hdl: VoidFunc): VoidFunc;
|
45
43
|
Exit(code: number): void;
|
46
44
|
}
|
47
45
|
|
48
|
-
export interface
|
49
|
-
|
46
|
+
export interface RuntimeSysAbstraction extends BasicSysAbstraction {
|
47
|
+
System(): SystemService;
|
48
|
+
FileSystem(): FileService;
|
49
|
+
}
|
50
|
+
|
51
|
+
export interface BasicRuntimeService {
|
50
52
|
Stdout(): WritableStream<Uint8Array>;
|
51
53
|
Stderr(): WritableStream<Uint8Array>;
|
54
|
+
Env(): Env;
|
55
|
+
Args(): string[];
|
56
|
+
}
|
57
|
+
|
58
|
+
export interface BasicSysAbstraction extends BasicRuntimeService {
|
59
|
+
Time(): Time;
|
52
60
|
NextId(): string;
|
53
61
|
Random0ToValue(value: number): number;
|
54
|
-
System(): SystemService;
|
55
|
-
FileSystem(): FileService;
|
56
62
|
}
|
package/src/test/mock-logger.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import { LevelHandlerImpl } from "../log-level-impl.js";
|
2
2
|
import { Logger } from "../logger.js";
|
3
3
|
import { LoggerImpl } from "../logger-impl.js";
|
4
|
-
import { SysAbstraction } from "../sys-abstraction.js";
|
5
4
|
import { LogCollector } from "./log-write-stream.js";
|
5
|
+
import { BasicSysAbstraction } from "../sys-abstraction.js";
|
6
6
|
|
7
7
|
export interface MockLoggerReturn {
|
8
8
|
readonly logger: Logger;
|
@@ -10,7 +10,7 @@ export interface MockLoggerReturn {
|
|
10
10
|
}
|
11
11
|
|
12
12
|
export function MockLogger(params?: {
|
13
|
-
readonly sys?:
|
13
|
+
readonly sys?: BasicSysAbstraction;
|
14
14
|
readonly pass?: WritableStreamDefaultWriter<Uint8Array>;
|
15
15
|
moduleName?: string | string[];
|
16
16
|
readonly disableDebug?: boolean;
|
package/src/txt-en-decoder.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import { ResolveOnce } from "./resolve-once.js";
|
1
2
|
import { Result } from "./result.js";
|
2
3
|
import { coerceIntoUint8, ToUInt8 } from "./utils/coerce-uint8.js";
|
3
4
|
|
@@ -43,8 +44,7 @@ class TxtOps implements TxtEnDecoder {
|
|
43
44
|
}
|
44
45
|
}
|
45
46
|
|
46
|
-
|
47
|
+
const txtEnDecoder = new ResolveOnce<TxtEnDecoder>();
|
47
48
|
export function TxtEnDecoderSingleton(): TxtEnDecoder {
|
48
|
-
|
49
|
-
return txtEnDecoder;
|
49
|
+
return txtEnDecoder.once(() => new TxtOps());
|
50
50
|
}
|
package/src/uri.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import type { DeepWritable } from "ts-essentials";
|
1
2
|
import { exception2Result, Result } from "./result.js";
|
2
3
|
import { getParamsResult, KeysParam } from "./utils/get-params-result.js";
|
3
4
|
import { relativePath } from "./utils/relative-path.js";
|
@@ -38,6 +39,7 @@ export interface URIInterface<R extends URIInterface<R>> {
|
|
38
39
|
getParam<T extends string | undefined>(key: string | OneKey<string>, def?: T): T extends string ? string : string | undefined;
|
39
40
|
getParamResult(key: string, msgFn?: (key: string) => string): Result<string>;
|
40
41
|
getParamsResult(...keys: KeysParam): Result<Record<string, string>>;
|
42
|
+
match(other: CoerceURI): MatchResult;
|
41
43
|
clone(): R;
|
42
44
|
asURL(): URL;
|
43
45
|
toString(): string;
|
@@ -45,6 +47,67 @@ export interface URIInterface<R extends URIInterface<R>> {
|
|
45
47
|
asObj(...strips: StripCommand[]): Partial<HostURIObject | PathURIObject>;
|
46
48
|
}
|
47
49
|
|
50
|
+
export interface MatchResult {
|
51
|
+
readonly score: number;
|
52
|
+
readonly protocol: boolean;
|
53
|
+
readonly hostname: boolean;
|
54
|
+
readonly port: boolean;
|
55
|
+
readonly pathname: boolean;
|
56
|
+
readonly pathParts: string[];
|
57
|
+
readonly params: Record<string, string>;
|
58
|
+
}
|
59
|
+
|
60
|
+
function match(iref: CoerceURI, ioth: CoerceURI): MatchResult {
|
61
|
+
const mr: DeepWritable<MatchResult> = {
|
62
|
+
score: 0,
|
63
|
+
protocol: false,
|
64
|
+
hostname: false,
|
65
|
+
port: false,
|
66
|
+
pathname: false,
|
67
|
+
pathParts: [],
|
68
|
+
params: {},
|
69
|
+
};
|
70
|
+
const ref = URI.from(iref);
|
71
|
+
const oth = URI.from(ioth);
|
72
|
+
if (ref.protocol === oth.protocol) {
|
73
|
+
mr.score += 1;
|
74
|
+
mr.protocol = true;
|
75
|
+
}
|
76
|
+
try {
|
77
|
+
const refH = ref.hostname;
|
78
|
+
const refP = ref.port;
|
79
|
+
if (refH === oth.hostname) {
|
80
|
+
mr.score += 1;
|
81
|
+
mr.hostname = true;
|
82
|
+
}
|
83
|
+
if (refP.length && refP === oth.port) {
|
84
|
+
mr.score += 1;
|
85
|
+
mr.port = true;
|
86
|
+
}
|
87
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
88
|
+
} catch (e) {
|
89
|
+
// ignore
|
90
|
+
}
|
91
|
+
if (ref.pathname.length && ref.pathname !== "/") {
|
92
|
+
const pref = ref.pathname.split("/").filter((p) => p.length);
|
93
|
+
const poth = oth.pathname.split("/").filter((p) => p.length);
|
94
|
+
for (let i = 0; i < pref.length && i < poth.length; i++) {
|
95
|
+
if (poth[i] === pref[i]) {
|
96
|
+
mr.score += 1;
|
97
|
+
mr.pathname = true;
|
98
|
+
mr.pathParts.push(pref[i]);
|
99
|
+
}
|
100
|
+
}
|
101
|
+
}
|
102
|
+
for (const [key, value] of ref.getParams) {
|
103
|
+
if (oth.getParam(key) === value) {
|
104
|
+
mr.score += 1;
|
105
|
+
mr.params[key] = value;
|
106
|
+
}
|
107
|
+
}
|
108
|
+
return mr;
|
109
|
+
}
|
110
|
+
|
48
111
|
function coerceKey(key: string | OneKey<string>, def?: string): { key: string; def?: string } {
|
49
112
|
if (typeof key === "object") {
|
50
113
|
const keys = Object.keys(key);
|
@@ -274,6 +337,10 @@ export class BuildURI implements URIInterface<BuildURI> {
|
|
274
337
|
return from((url) => new BuildURI(url), strURLUri, defaultProtocol);
|
275
338
|
}
|
276
339
|
|
340
|
+
match(other: CoerceURI): MatchResult {
|
341
|
+
return match(this.URI(), URI.from(other));
|
342
|
+
}
|
343
|
+
|
277
344
|
port(p: string): BuildURI {
|
278
345
|
this._url.port = p;
|
279
346
|
return this;
|
@@ -454,6 +521,10 @@ export class URI implements URIInterface<URI> {
|
|
454
521
|
};
|
455
522
|
}
|
456
523
|
|
524
|
+
match(other: CoerceURI): MatchResult {
|
525
|
+
return match(this, other);
|
526
|
+
}
|
527
|
+
|
457
528
|
// if no protocol is provided, default to file:
|
458
529
|
static merge(into: CoerceURI, from: CoerceURI, defaultProtocol = "file:"): URI {
|
459
530
|
const intoUrl = BuildURI.from(into, defaultProtocol);
|
package/src/web/index.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export * from "./web-sys-abstraction.js";
|
1
|
+
export * from "./web-basic-sys-abstraction.js";
|
@@ -0,0 +1,105 @@
|
|
1
|
+
import { BaseBasicSysAbstraction, WrapperBasicSysAbstraction, WrapperBasicSysAbstractionParams } from "../base-sys-abstraction.js";
|
2
|
+
import { ResolveOnce } from "../resolve-once.js";
|
3
|
+
import { BasicRuntimeService, BasicSysAbstraction } from "../sys-abstraction.js";
|
4
|
+
import { Env, envFactory } from "../sys-env.js";
|
5
|
+
import { TxtEnDecoder, TxtEnDecoderSingleton } from "../txt-en-decoder.js";
|
6
|
+
import { ConsoleWriterStream } from "../utils/console-write-stream.js";
|
7
|
+
|
8
|
+
// export class WebFileService implements FileService {
|
9
|
+
// get baseDir(): string {
|
10
|
+
// throw new Error("basedir-Method not implemented.");
|
11
|
+
// }
|
12
|
+
// // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
13
|
+
// create(fname: string): Promise<NamedWritableStream> {
|
14
|
+
// throw new Error("create-Method not implemented.");
|
15
|
+
// }
|
16
|
+
// // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
17
|
+
// readFileString(fname: string): Promise<string> {
|
18
|
+
// throw new Error("readFileString-Method not implemented.");
|
19
|
+
// }
|
20
|
+
// // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
21
|
+
// writeFileString(fname: string, content: string): Promise<void> {
|
22
|
+
// throw new Error("writeFileString-Method not implemented.");
|
23
|
+
// }
|
24
|
+
// // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
25
|
+
// abs(fname: string): string {
|
26
|
+
// throw new Error("abs-Method not implemented.");
|
27
|
+
// }
|
28
|
+
// // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
29
|
+
// join(...paths: string[]): string {
|
30
|
+
// throw new Error("join-Method not implemented.");
|
31
|
+
// }
|
32
|
+
// // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
33
|
+
// relative(from: string, to?: string): string {
|
34
|
+
// throw new Error("relative-Method not implemented.");
|
35
|
+
// }
|
36
|
+
// // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
37
|
+
// dirname(fname: string): string {
|
38
|
+
// throw new Error("dirname-Method not implemented.");
|
39
|
+
// }
|
40
|
+
// // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
41
|
+
// basename(fname: string): string {
|
42
|
+
// throw new Error("basename-Method not implemented.");
|
43
|
+
// }
|
44
|
+
// // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
45
|
+
// nodeImport(fname: string): string {
|
46
|
+
// throw new Error("nodeImport-Method not implemented.");
|
47
|
+
// }
|
48
|
+
// // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
49
|
+
// isAbsolute(fname: string): boolean {
|
50
|
+
// throw new Error("isAbsolute-Method not implemented.");
|
51
|
+
// }
|
52
|
+
// }
|
53
|
+
|
54
|
+
class WebSystemService implements BasicRuntimeService {
|
55
|
+
readonly _txtEnDe: TxtEnDecoder;
|
56
|
+
constructor(ende: TxtEnDecoder) {
|
57
|
+
this._txtEnDe = ende;
|
58
|
+
}
|
59
|
+
Env(): Env {
|
60
|
+
return envFactory();
|
61
|
+
}
|
62
|
+
Args(): string[] {
|
63
|
+
throw new Error("Args-Method not implemented.");
|
64
|
+
}
|
65
|
+
Stdout(): WritableStream<Uint8Array> {
|
66
|
+
return new ConsoleWriterStream();
|
67
|
+
// const decoder = this._txtEnDe;
|
68
|
+
// return new WritableStream({
|
69
|
+
// write(chunk): Promise<void> {
|
70
|
+
// return new Promise((resolve) => {
|
71
|
+
// const decoded = decoder.decode(chunk);
|
72
|
+
// // eslint-disable-next-line no-console
|
73
|
+
// console.log(decoded.trimEnd());
|
74
|
+
// resolve();
|
75
|
+
// });
|
76
|
+
// },
|
77
|
+
// });
|
78
|
+
}
|
79
|
+
Stderr(): WritableStream<Uint8Array> {
|
80
|
+
const decoder = this._txtEnDe;
|
81
|
+
return new WritableStream({
|
82
|
+
write(chunk): Promise<void> {
|
83
|
+
return new Promise((resolve) => {
|
84
|
+
const decoded = decoder.decode(chunk);
|
85
|
+
// eslint-disable-next-line no-console
|
86
|
+
console.error(decoded.trimEnd());
|
87
|
+
resolve();
|
88
|
+
});
|
89
|
+
},
|
90
|
+
});
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
const baseSysAbstraction = new ResolveOnce();
|
95
|
+
export function WebBasicSysAbstraction(param?: WrapperBasicSysAbstractionParams): BasicSysAbstraction {
|
96
|
+
const my = baseSysAbstraction.once(() => {
|
97
|
+
return new BaseBasicSysAbstraction({
|
98
|
+
TxtEnDecoder: param?.TxtEnDecoder || TxtEnDecoderSingleton(),
|
99
|
+
});
|
100
|
+
});
|
101
|
+
return new WrapperBasicSysAbstraction(my, {
|
102
|
+
basicRuntimeService: new WebSystemService(param?.TxtEnDecoder ?? my._txtEnDe),
|
103
|
+
...param,
|
104
|
+
});
|
105
|
+
}
|
@@ -95,19 +95,23 @@ type IDMode = (typeof IDMode)[keyof typeof IDMode];
|
|
95
95
|
declare function String2TimeMode(s?: string): TimeMode;
|
96
96
|
type VoidFunc = () => void | Promise<void>;
|
97
97
|
interface SystemService {
|
98
|
-
Env(): Env;
|
99
|
-
Args(): string[];
|
100
98
|
OnExit(hdl: VoidFunc): VoidFunc;
|
101
99
|
Exit(code: number): void;
|
102
100
|
}
|
103
|
-
interface
|
104
|
-
|
101
|
+
interface RuntimeSysAbstraction extends BasicSysAbstraction {
|
102
|
+
System(): SystemService;
|
103
|
+
FileSystem(): FileService;
|
104
|
+
}
|
105
|
+
interface BasicRuntimeService {
|
105
106
|
Stdout(): WritableStream<Uint8Array>;
|
106
107
|
Stderr(): WritableStream<Uint8Array>;
|
108
|
+
Env(): Env;
|
109
|
+
Args(): string[];
|
110
|
+
}
|
111
|
+
interface BasicSysAbstraction extends BasicRuntimeService {
|
112
|
+
Time(): Time;
|
107
113
|
NextId(): string;
|
108
114
|
Random0ToValue(value: number): number;
|
109
|
-
System(): SystemService;
|
110
|
-
FileSystem(): FileService;
|
111
115
|
}
|
112
116
|
|
113
|
-
export { type Duration as D, type Env as E, type FileService as F, IDMode as I, type NamedWritableStream as N, type OnSetItem as O, RandomMode as R, type
|
117
|
+
export { type BasicSysAbstraction as B, type Duration as D, type Env as E, type FileService as F, IDMode as I, type NamedWritableStream as N, type OnSetItem as O, RandomMode as R, type SystemService as S, Time as T, type VoidFunc as V, TimeMode as a, type BasicRuntimeService as b, type EnvActions as c, EnvImpl as d, type EnvFactoryOpts as e, type RuntimeSysAbstraction as f, String2TimeMode as g, type EnvTuple as h, type EnvMap as i, type EnvFactoryFn as j, envFactory as k, TimeUnits as l, type TimeUnit as m, registerEnvAction as r };
|
@@ -95,19 +95,23 @@ type IDMode = (typeof IDMode)[keyof typeof IDMode];
|
|
95
95
|
declare function String2TimeMode(s?: string): TimeMode;
|
96
96
|
type VoidFunc = () => void | Promise<void>;
|
97
97
|
interface SystemService {
|
98
|
-
Env(): Env;
|
99
|
-
Args(): string[];
|
100
98
|
OnExit(hdl: VoidFunc): VoidFunc;
|
101
99
|
Exit(code: number): void;
|
102
100
|
}
|
103
|
-
interface
|
104
|
-
|
101
|
+
interface RuntimeSysAbstraction extends BasicSysAbstraction {
|
102
|
+
System(): SystemService;
|
103
|
+
FileSystem(): FileService;
|
104
|
+
}
|
105
|
+
interface BasicRuntimeService {
|
105
106
|
Stdout(): WritableStream<Uint8Array>;
|
106
107
|
Stderr(): WritableStream<Uint8Array>;
|
108
|
+
Env(): Env;
|
109
|
+
Args(): string[];
|
110
|
+
}
|
111
|
+
interface BasicSysAbstraction extends BasicRuntimeService {
|
112
|
+
Time(): Time;
|
107
113
|
NextId(): string;
|
108
114
|
Random0ToValue(value: number): number;
|
109
|
-
System(): SystemService;
|
110
|
-
FileSystem(): FileService;
|
111
115
|
}
|
112
116
|
|
113
|
-
export { type Duration as D, type Env as E, type FileService as F, IDMode as I, type NamedWritableStream as N, type OnSetItem as O, RandomMode as R, type
|
117
|
+
export { type BasicSysAbstraction as B, type Duration as D, type Env as E, type FileService as F, IDMode as I, type NamedWritableStream as N, type OnSetItem as O, RandomMode as R, type SystemService as S, Time as T, type VoidFunc as V, TimeMode as a, type BasicRuntimeService as b, type EnvActions as c, EnvImpl as d, type EnvFactoryOpts as e, type RuntimeSysAbstraction as f, String2TimeMode as g, type EnvTuple as h, type EnvMap as i, type EnvFactoryFn as j, envFactory as k, TimeUnits as l, type TimeUnit as m, registerEnvAction as r };
|