@adviser/cement 0.1.26 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- package/{base_sys_abstraction-BYZvxqsW.d.cts → base_sys_abstraction-BsaOQtnz.d.cts} +1 -1
- package/{base_sys_abstraction-BCdXJHNa.d.ts → base_sys_abstraction-CQ7PJOct.d.ts} +1 -1
- package/{chunk-PZTL4UNG.js → chunk-CI63N5CK.js} +176 -2
- package/chunk-CI63N5CK.js.map +1 -0
- package/{chunk-MWAFFTM4.js → chunk-XBYS4FSO.js} +5 -4
- package/chunk-XBYS4FSO.js.map +1 -0
- package/{chunk-J2IM7FHM.js → chunk-ZYFWDQGV.js} +3 -1
- package/index.cjs +173 -3
- package/index.cjs.map +1 -1
- package/index.d.cts +2 -2
- package/index.d.ts +2 -2
- package/index.js +9 -5
- package/index.js.map +1 -1
- package/node/index.cjs +174 -1
- package/node/index.cjs.map +1 -1
- package/node/index.d.cts +3 -3
- package/node/index.d.ts +3 -3
- package/node/index.js +5 -4
- package/node/index.js.map +1 -1
- package/package.json +6 -6
- package/{sys_abstraction-CjljYIkv.d.cts → sys_abstraction-BzkoCY1p.d.cts} +32 -2
- package/{sys_abstraction-CjljYIkv.d.ts → sys_abstraction-BzkoCY1p.d.ts} +32 -2
- package/utils/index.cjs.map +1 -1
- package/utils/index.d.cts +1 -1
- package/utils/index.d.ts +1 -1
- package/utils/index.js +1 -1
- package/utils/index.js.map +1 -1
- package/web/index.cjs +174 -1
- package/web/index.cjs.map +1 -1
- package/web/index.d.cts +2 -2
- package/web/index.d.ts +2 -2
- package/web/index.js +3 -3
- package/chunk-MWAFFTM4.js.map +0 -1
- package/chunk-PZTL4UNG.js.map +0 -1
- /package/{chunk-J2IM7FHM.js.map → chunk-ZYFWDQGV.js.map} +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
import { V as VoidFunc, T as TimeMode, I as IDMode, R as RandomMode, F as FileService, b as SystemService } from './sys_abstraction-
|
1
|
+
import { V as VoidFunc, T as TimeMode, I as IDMode, R as RandomMode, F as FileService, b as SystemService } from './sys_abstraction-BzkoCY1p.cjs';
|
2
2
|
|
3
3
|
interface ExitHandler {
|
4
4
|
readonly hdl: VoidFunc;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { V as VoidFunc, T as TimeMode, I as IDMode, R as RandomMode, F as FileService, b as SystemService } from './sys_abstraction-
|
1
|
+
import { V as VoidFunc, T as TimeMode, I as IDMode, R as RandomMode, F as FileService, b as SystemService } from './sys_abstraction-BzkoCY1p.js';
|
2
2
|
|
3
3
|
interface ExitHandler {
|
4
4
|
readonly hdl: VoidFunc;
|
@@ -1,3 +1,10 @@
|
|
1
|
+
import {
|
2
|
+
__privateAdd,
|
3
|
+
__privateGet,
|
4
|
+
__privateMethod,
|
5
|
+
__privateSet
|
6
|
+
} from "./chunk-ZYFWDQGV.js";
|
7
|
+
|
1
8
|
// src/sys_abstraction.ts
|
2
9
|
var TimeMode = /* @__PURE__ */ ((TimeMode2) => {
|
3
10
|
TimeMode2["REAL"] = "real";
|
@@ -45,6 +52,171 @@ var TimeUnits = /* @__PURE__ */ ((TimeUnits2) => {
|
|
45
52
|
return TimeUnits2;
|
46
53
|
})(TimeUnits || {});
|
47
54
|
|
55
|
+
// src/sys_env.ts
|
56
|
+
var _node, _env;
|
57
|
+
var NodeEnvActions = class {
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-useless-constructor, @typescript-eslint/no-unused-vars
|
59
|
+
constructor(opts) {
|
60
|
+
__privateAdd(this, _node, globalThis);
|
61
|
+
__privateAdd(this, _env, this.use() ? process.env : {});
|
62
|
+
}
|
63
|
+
use() {
|
64
|
+
return typeof __privateGet(this, _node) === "object" && typeof __privateGet(this, _node).process === "object" && typeof __privateGet(this, _node).process.env === "object";
|
65
|
+
}
|
66
|
+
keys() {
|
67
|
+
return Object.keys(__privateGet(this, _env));
|
68
|
+
}
|
69
|
+
get(key) {
|
70
|
+
return __privateGet(this, _env)[key];
|
71
|
+
}
|
72
|
+
set(key, value) {
|
73
|
+
if (value) {
|
74
|
+
__privateGet(this, _env)[key] = value;
|
75
|
+
}
|
76
|
+
}
|
77
|
+
del(key) {
|
78
|
+
delete __privateGet(this, _env)[key];
|
79
|
+
}
|
80
|
+
};
|
81
|
+
_node = new WeakMap();
|
82
|
+
_env = new WeakMap();
|
83
|
+
var _deno, _env2;
|
84
|
+
var DenoEnvActions = class {
|
85
|
+
constructor(opts, env) {
|
86
|
+
__privateAdd(this, _deno, globalThis);
|
87
|
+
__privateAdd(this, _env2);
|
88
|
+
if (env) {
|
89
|
+
__privateSet(this, _env2, env);
|
90
|
+
} else {
|
91
|
+
__privateSet(this, _env2, this.use() ? __privateGet(this, _deno).Deno.env : /* @__PURE__ */ new Map());
|
92
|
+
}
|
93
|
+
}
|
94
|
+
use() {
|
95
|
+
return typeof __privateGet(this, _deno) === "object" && typeof __privateGet(this, _deno).Deno === "object" && typeof __privateGet(this, _deno).Deno.env === "object";
|
96
|
+
}
|
97
|
+
keys() {
|
98
|
+
return Array.from(__privateGet(this, _env2).keys());
|
99
|
+
}
|
100
|
+
get(key) {
|
101
|
+
return __privateGet(this, _env2).get(key);
|
102
|
+
}
|
103
|
+
set(key, value) {
|
104
|
+
if (value) {
|
105
|
+
__privateGet(this, _env2).set(key, value);
|
106
|
+
}
|
107
|
+
}
|
108
|
+
del(key) {
|
109
|
+
__privateGet(this, _env2).delete(key);
|
110
|
+
}
|
111
|
+
};
|
112
|
+
_deno = new WeakMap();
|
113
|
+
_env2 = new WeakMap();
|
114
|
+
var BrowserEnvActions = class _BrowserEnvActions extends DenoEnvActions {
|
115
|
+
static globalBEA(sym) {
|
116
|
+
const browser = globalThis;
|
117
|
+
if (typeof browser === "object" && typeof browser[sym] === "object") {
|
118
|
+
return { map: browser[sym]._map, finalize: () => browser[sym]._map };
|
119
|
+
}
|
120
|
+
const map = /* @__PURE__ */ new Map();
|
121
|
+
return {
|
122
|
+
map,
|
123
|
+
finalize: (bea) => {
|
124
|
+
browser[sym] = bea;
|
125
|
+
return map;
|
126
|
+
}
|
127
|
+
};
|
128
|
+
}
|
129
|
+
constructor(opts) {
|
130
|
+
const { map, finalize } = _BrowserEnvActions.globalBEA(Symbol.for(opts.symbol || "CP_ENV"));
|
131
|
+
super(opts, map);
|
132
|
+
this._map = finalize(this);
|
133
|
+
}
|
134
|
+
use() {
|
135
|
+
return true;
|
136
|
+
}
|
137
|
+
};
|
138
|
+
function envFactory(opts = {}) {
|
139
|
+
const found = [new NodeEnvActions(opts), new DenoEnvActions(opts), new BrowserEnvActions(opts)].find((env) => env.use());
|
140
|
+
if (!found) {
|
141
|
+
throw new Error("SysContainer:envFactory: no env available");
|
142
|
+
}
|
143
|
+
return found;
|
144
|
+
}
|
145
|
+
var _envImpl, _EnvImpl_instances, updatePresets_fn, applyOnSet_fn, _onSet;
|
146
|
+
var EnvImpl = class {
|
147
|
+
constructor(opts = {}) {
|
148
|
+
__privateAdd(this, _EnvImpl_instances);
|
149
|
+
__privateAdd(this, _envImpl);
|
150
|
+
__privateAdd(this, _onSet, []);
|
151
|
+
__privateSet(this, _envImpl, envFactory(opts));
|
152
|
+
__privateMethod(this, _EnvImpl_instances, updatePresets_fn).call(this, opts.presetEnv);
|
153
|
+
}
|
154
|
+
keys() {
|
155
|
+
return __privateGet(this, _envImpl).keys();
|
156
|
+
}
|
157
|
+
// filter is not set all sets passed
|
158
|
+
onSet(fn, ...filter) {
|
159
|
+
const item = { filter: new Set(filter), fn };
|
160
|
+
__privateGet(this, _onSet).push(item);
|
161
|
+
__privateMethod(this, _EnvImpl_instances, applyOnSet_fn).call(this, [item]);
|
162
|
+
}
|
163
|
+
get(key) {
|
164
|
+
return __privateGet(this, _envImpl).get(key);
|
165
|
+
}
|
166
|
+
set(key, value) {
|
167
|
+
if (!value) {
|
168
|
+
return;
|
169
|
+
}
|
170
|
+
__privateGet(this, _envImpl).set(key, value);
|
171
|
+
__privateMethod(this, _EnvImpl_instances, applyOnSet_fn).call(this, __privateGet(this, _onSet), key, value);
|
172
|
+
}
|
173
|
+
del(key) {
|
174
|
+
__privateGet(this, _envImpl).del(key);
|
175
|
+
__privateMethod(this, _EnvImpl_instances, applyOnSet_fn).call(this, __privateGet(this, _onSet), key);
|
176
|
+
}
|
177
|
+
};
|
178
|
+
_envImpl = new WeakMap();
|
179
|
+
_EnvImpl_instances = new WeakSet();
|
180
|
+
updatePresets_fn = function(presetEnv) {
|
181
|
+
if (!presetEnv) {
|
182
|
+
return;
|
183
|
+
}
|
184
|
+
for (const [key, value] of presetEnv) {
|
185
|
+
__privateGet(this, _envImpl).set(key, value);
|
186
|
+
}
|
187
|
+
};
|
188
|
+
applyOnSet_fn = function(onSet, key, value) {
|
189
|
+
onSet.forEach((item) => {
|
190
|
+
let keys = [];
|
191
|
+
if (key) {
|
192
|
+
keys = [key];
|
193
|
+
} else {
|
194
|
+
keys = __privateGet(this, _envImpl).keys();
|
195
|
+
}
|
196
|
+
keys.filter((k) => {
|
197
|
+
if (item.filter.size === 0) {
|
198
|
+
return true;
|
199
|
+
}
|
200
|
+
if (item.filter.has(k)) {
|
201
|
+
return true;
|
202
|
+
}
|
203
|
+
return false;
|
204
|
+
}).forEach((k) => {
|
205
|
+
let v;
|
206
|
+
if (!key && !value) {
|
207
|
+
v = __privateGet(this, _envImpl).get(k);
|
208
|
+
} else if (key && !value) {
|
209
|
+
v = void 0;
|
210
|
+
} else {
|
211
|
+
v = value;
|
212
|
+
}
|
213
|
+
item.fn(k, v);
|
214
|
+
});
|
215
|
+
});
|
216
|
+
};
|
217
|
+
_onSet = new WeakMap();
|
218
|
+
var envImpl = new EnvImpl();
|
219
|
+
|
48
220
|
// src/base_sys_abstraction.ts
|
49
221
|
var SysTime = class extends Time {
|
50
222
|
Now() {
|
@@ -228,6 +400,8 @@ export {
|
|
228
400
|
Time,
|
229
401
|
TimeUnits,
|
230
402
|
BaseSysAbstraction,
|
231
|
-
WrapperSysAbstraction
|
403
|
+
WrapperSysAbstraction,
|
404
|
+
EnvImpl,
|
405
|
+
envImpl
|
232
406
|
};
|
233
|
-
//# sourceMappingURL=chunk-
|
407
|
+
//# sourceMappingURL=chunk-CI63N5CK.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/sys_abstraction.ts","../../src/time.ts","../../src/sys_env.ts","../../src/base_sys_abstraction.ts"],"sourcesContent":["import { FileService } from \"./file_service\";\nimport { Env } from \"./sys_env\";\nimport { Time } from \"./time\";\n\nexport enum TimeMode {\n REAL = \"real\",\n CONST = \"const\",\n STEP = \"step\",\n}\n\nexport enum RandomMode {\n CONST = \"const\",\n STEP = \"step\",\n RANDOM = \"random\",\n}\n\nexport enum IDMode {\n UUID = \"uuid\",\n CONST = \"const\",\n STEP = \"step\",\n}\n\nexport function String2TimeMode(s?: string): TimeMode {\n switch (s?.toLowerCase()) {\n case \"real\":\n return TimeMode.REAL;\n case \"const\":\n return TimeMode.CONST;\n case \"step\":\n return TimeMode.STEP;\n default:\n return TimeMode.REAL;\n }\n}\n\nexport type VoidFunc = () => void | Promise<void>;\n\nexport interface SystemService {\n Env(): Env;\n Args(): string[];\n OnExit(hdl: VoidFunc): VoidFunc;\n Exit(code: number): void;\n}\n\nexport interface SysAbstraction {\n Time(): Time;\n Stdout(): WritableStream<Uint8Array>;\n Stderr(): WritableStream<Uint8Array>;\n NextId(): string;\n Random0ToValue(value: number): number;\n System(): SystemService;\n FileSystem(): FileService;\n}\n","export abstract class Time {\n abstract Now(): 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","export interface EnvActions {\n get(key: string): string | undefined;\n set(key: string, value?: string): void;\n del(key: string): void;\n keys(): string[];\n use(): boolean;\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 use(): boolean {\n return typeof this.#node === \"object\" && typeof this.#node.process === \"object\" && typeof this.#node.process.env === \"object\";\n }\n readonly #env = this.use() ? 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 del(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 readonly #env: Map<string, string>;\n constructor(opts: Partial<EnvFactoryOpts>, env?: Map<string, string>) {\n if (env) {\n this.#env = env;\n } else {\n this.#env = this.use() ? this.#deno.Deno.env : new Map();\n }\n }\n use(): 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 del(key: string): void {\n this.#env.delete(key);\n }\n}\n\nclass BrowserEnvActions extends DenoEnvActions {\n static globalBEA(sym: symbol) {\n const browser = globalThis as unknown as Record<symbol, BrowserEnvActions>;\n if (typeof browser === \"object\" && typeof browser[sym] === \"object\") {\n return { map: browser[sym]._map, finalize: () => browser[sym]._map };\n }\n const map = new Map<string, string>();\n return {\n map,\n finalize: (bea: BrowserEnvActions) => {\n browser[sym] = bea;\n return map;\n },\n };\n }\n\n readonly _map: Map<string, string>;\n constructor(opts: Partial<EnvFactoryOpts>) {\n const { map, finalize } = BrowserEnvActions.globalBEA(Symbol.for(opts.symbol || \"CP_ENV\"));\n // not perfect the globalThis will be polluted\n // also in the case it is not need.\n // better we have a lazy init\n super(opts, map);\n this._map = finalize(this);\n }\n use(): boolean {\n return true;\n }\n}\n\ninterface EnvFactoryOpts {\n readonly symbol: string; // default \"CP_ENV\" used by BrowserEnvActions\n readonly presetEnv: Map<string, string>;\n}\n\nfunction envFactory(opts: Partial<EnvFactoryOpts> = {}): EnvActions {\n const found = [new NodeEnvActions(opts), new DenoEnvActions(opts), new BrowserEnvActions(opts)].find((env) => env.use());\n if (!found) {\n throw new Error(\"SysContainer:envFactory: no env available\");\n }\n return found;\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 Omit<EnvActions, \"use\"> {\n onSet(fn: OnSetFn, ...filter: string[]): void;\n}\n\nexport class EnvImpl implements Env {\n readonly #envImpl: EnvActions;\n constructor(opts: Partial<EnvFactoryOpts> = {}) {\n this.#envImpl = envFactory(opts);\n // do nothing\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.#envImpl.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.#envImpl.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.#envImpl.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.#envImpl.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.#envImpl.get(key);\n }\n set(key: string, value?: string): void {\n if (!value) {\n return;\n }\n this.#envImpl.set(key, value);\n this.#applyOnSet(this.#onSet, key, value);\n }\n del(key: string): void {\n this.#envImpl.del(key);\n this.#applyOnSet(this.#onSet, key);\n }\n}\n\nexport const envImpl = new EnvImpl();\n","import { FileService } from \"./file_service\";\nimport { TimeMode, RandomMode, IDMode, SystemService, VoidFunc, SysAbstraction } from \"./sys_abstraction\";\nimport { Time } from \"./time\";\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 constructor() {\n super();\n this._step = new ConstTime().Now();\n }\n Now() {\n if (this._step.getTime() === 0) {\n this._step = new ConstTime().Now();\n return this._step;\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 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\nconst decoder = new TextDecoder();\nexport class BaseSysAbstraction {\n readonly _time = new SysTime();\n readonly _stdout = new WritableStream({\n write(chunk) {\n return new Promise((resolve) => {\n const decoded = decoder.decode(chunk);\n console.log(decoded.trimEnd());\n resolve();\n });\n },\n });\n readonly _stderr = new WritableStream({\n write(chunk) {\n return new Promise((resolve) => {\n const decoded = decoder.decode(chunk);\n console.error(decoded.trimEnd());\n resolve();\n });\n },\n });\n\n readonly _idService = new IdService();\n readonly _randomService = new RandomService(RandomMode.RANDOM);\n readonly _fileSystem: FileService;\n readonly _systemService: SystemService;\n\n constructor(params: BaseSysAbstractionParams) {\n this._fileSystem = params.FileSystem;\n this._systemService = params.SystemService;\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}\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"],"mappings":";;;;;;;;AAIO,IAAK,WAAL,kBAAKA,cAAL;AACL,EAAAA,UAAA,UAAO;AACP,EAAAA,UAAA,WAAQ;AACR,EAAAA,UAAA,UAAO;AAHG,SAAAA;AAAA,GAAA;AAML,IAAK,aAAL,kBAAKC,gBAAL;AACL,EAAAA,YAAA,WAAQ;AACR,EAAAA,YAAA,UAAO;AACP,EAAAA,YAAA,YAAS;AAHC,SAAAA;AAAA,GAAA;AAML,IAAK,SAAL,kBAAKC,YAAL;AACL,EAAAA,QAAA,UAAO;AACP,EAAAA,QAAA,WAAQ;AACR,EAAAA,QAAA,UAAO;AAHG,SAAAA;AAAA,GAAA;AAML,SA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I,OAAO,QAAQ;AACjB,aAAK,aAAa,IAAI,UAAU,OAAO,MAAM;AAAA,MAC/C;AACA,UAAI,OAAO,YAAY;AACrB,aAAK,iBAAiB,IAAI,cAAc,OAAO,UAAU;AAAA,MAC3D;AACA,UAAI,OAAO,YAAY;AACrB,aAAK,cAAc,OAAO;AAAA,MAC5B;AACA,UAAI,OAAO,eAAe;AACxB,aAAK,iBAAiB,OAAO;AAAA,MAC/B;AAAA,IACF;AAAA,EACF;AAAA,EACA,OAAa;AACX,WAAO,KAAK;AAAA,EACd;AAAA,EACA,SAAiB;AACf,WAAO,KAAK,WAAW,OAAO;AAAA,EAChC;AAAA,EACA,eAAe,OAAuB;AACpC,WAAO,KAAK,eAAe,eAAe,KAAK;AAAA,EACjD;AAAA,EACA,SAAyB;AACvB,WAAO,KAAK;AAAA,EACd;AAAA,EACA,SAAyB;AACvB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,SAAwB;AACtB,WAAO,KAAK;AAAA,EACd;AAAA,EACA,aAA0B;AACxB,WAAO,KAAK;AAAA,EACd;AACF;","names":["TimeMode","RandomMode","IDMode","TimeUnits","_env"]}
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import {
|
2
2
|
BaseSysAbstraction,
|
3
|
-
WrapperSysAbstraction
|
4
|
-
|
3
|
+
WrapperSysAbstraction,
|
4
|
+
envImpl
|
5
|
+
} from "./chunk-CI63N5CK.js";
|
5
6
|
|
6
7
|
// src/web/web_sys_abstraction.ts
|
7
8
|
var WebFileService = class {
|
@@ -51,7 +52,7 @@ var WebFileService = class {
|
|
51
52
|
};
|
52
53
|
var WebSystemService = class {
|
53
54
|
Env() {
|
54
|
-
|
55
|
+
return envImpl;
|
55
56
|
}
|
56
57
|
Args() {
|
57
58
|
throw new Error("Args-Method not implemented.");
|
@@ -79,4 +80,4 @@ function WebSysAbstraction(param) {
|
|
79
80
|
export {
|
80
81
|
WebSysAbstraction
|
81
82
|
};
|
82
|
-
//# sourceMappingURL=chunk-
|
83
|
+
//# sourceMappingURL=chunk-XBYS4FSO.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/web/web_sys_abstraction.ts"],"sourcesContent":["import { BaseSysAbstraction, WrapperSysAbstraction, WrapperSysAbstractionParams } from \"../base_sys_abstraction\";\nimport { FileService, NamedWritableStream } from \"../file_service\";\nimport { SysAbstraction, SystemService, VoidFunc } from \"../sys_abstraction\";\nimport { envImpl } from \"../sys_env\";\n\nclass WebFileService implements FileService {\n get baseDir(): string {\n throw new Error(\"basedir-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n create(fname: string): Promise<NamedWritableStream> {\n throw new Error(\"create-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n readFileString(fname: string): Promise<string> {\n throw new Error(\"readFileString-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n writeFileString(fname: string, content: string): Promise<void> {\n throw new Error(\"writeFileString-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abs(fname: string): string {\n throw new Error(\"abs-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n join(...paths: string[]): string {\n throw new Error(\"join-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n relative(from: string, to?: string | undefined): string {\n throw new Error(\"relative-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n dirname(fname: string): string {\n throw new Error(\"dirname-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n basename(fname: string): string {\n throw new Error(\"basename-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n nodeImport(fname: string): string {\n throw new Error(\"nodeImport-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n isAbsolute(fname: string): boolean {\n throw new Error(\"isAbsolute-Method not implemented.\");\n }\n}\n\nclass WebSystemService implements SystemService {\n Env() {\n return envImpl;\n }\n Args(): string[] {\n throw new Error(\"Args-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n OnExit(hdl: VoidFunc): VoidFunc {\n throw new Error(\"OnExit-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n Exit(code: number): void {\n throw new Error(\"Exit-Method not implemented.\");\n }\n}\n\nlet my: BaseSysAbstraction | undefined = undefined;\nexport function WebSysAbstraction(param?: WrapperSysAbstractionParams): SysAbstraction {\n if (!my) {\n my = new BaseSysAbstraction({\n FileSystem: new WebFileService(),\n SystemService: new WebSystemService(),\n });\n }\n return new WrapperSysAbstraction(my, param);\n}\n"],"mappings":";;;;;;;AAKA,IAAM,iBAAN,MAA4C;AAAA,EAC1C,IAAI,UAAkB;AACpB,UAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AAAA;AAAA,EAEA,OAAO,OAA6C;AAClD,UAAM,IAAI,MAAM,gCAAgC;AAAA,EAClD;AAAA;AAAA,EAEA,eAAe,OAAgC;AAC7C,UAAM,IAAI,MAAM,wCAAwC;AAAA,EAC1D;AAAA;AAAA,EAEA,gBAAgB,OAAe,SAAgC;AAC7D,UAAM,IAAI,MAAM,yCAAyC;AAAA,EAC3D;AAAA;AAAA,EAEA,IAAI,OAAuB;AACzB,UAAM,IAAI,MAAM,6BAA6B;AAAA,EAC/C;AAAA;AAAA,EAEA,QAAQ,OAAyB;AAC/B,UAAM,IAAI,MAAM,8BAA8B;AAAA,EAChD;AAAA;AAAA,EAEA,SAAS,MAAc,IAAiC;AACtD,UAAM,IAAI,MAAM,kCAAkC;AAAA,EACpD;AAAA;AAAA,EAEA,QAAQ,OAAuB;AAC7B,UAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AAAA;AAAA,EAEA,SAAS,OAAuB;AAC9B,UAAM,IAAI,MAAM,kCAAkC;AAAA,EACpD;AAAA;AAAA,EAEA,WAAW,OAAuB;AAChC,UAAM,IAAI,MAAM,oCAAoC;AAAA,EACtD;AAAA;AAAA,EAEA,WAAW,OAAwB;AACjC,UAAM,IAAI,MAAM,oCAAoC;AAAA,EACtD;AACF;AAEA,IAAM,mBAAN,MAAgD;AAAA,EAC9C,MAAM;AACJ,WAAO;AAAA,EACT;AAAA,EACA,OAAiB;AACf,UAAM,IAAI,MAAM,8BAA8B;AAAA,EAChD;AAAA;AAAA,EAEA,OAAO,KAAyB;AAC9B,UAAM,IAAI,MAAM,gCAAgC;AAAA,EAClD;AAAA;AAAA,EAEA,KAAK,MAAoB;AACvB,UAAM,IAAI,MAAM,8BAA8B;AAAA,EAChD;AACF;AAEA,IAAI,KAAqC;AAClC,SAAS,kBAAkB,OAAqD;AACrF,MAAI,CAAC,IAAI;AACP,SAAK,IAAI,mBAAmB;AAAA,MAC1B,YAAY,IAAI,eAAe;AAAA,MAC/B,eAAe,IAAI,iBAAiB;AAAA,IACtC,CAAC;AAAA,EACH;AACA,SAAO,IAAI,sBAAsB,IAAI,KAAK;AAC5C;","names":[]}
|
@@ -22,6 +22,7 @@ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot
|
|
22
22
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
23
23
|
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);
|
24
24
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
25
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
25
26
|
var __await = function(promise, isYieldStar) {
|
26
27
|
this[0] = promise;
|
27
28
|
this[1] = isYieldStar;
|
@@ -60,6 +61,7 @@ export {
|
|
60
61
|
__privateGet,
|
61
62
|
__privateAdd,
|
62
63
|
__privateSet,
|
64
|
+
__privateMethod,
|
63
65
|
__yieldStar
|
64
66
|
};
|
65
|
-
//# sourceMappingURL=chunk-
|
67
|
+
//# sourceMappingURL=chunk-ZYFWDQGV.js.map
|
package/index.cjs
CHANGED
@@ -38,6 +38,7 @@ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot
|
|
38
38
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
39
39
|
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);
|
40
40
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
41
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
41
42
|
var __await = function(promise, isYieldStar) {
|
42
43
|
this[0] = promise;
|
43
44
|
this[1] = isYieldStar;
|
@@ -74,6 +75,7 @@ var __yieldStar = (value) => {
|
|
74
75
|
// src/index.ts
|
75
76
|
var src_exports = {};
|
76
77
|
__export(src_exports, {
|
78
|
+
EnvImpl: () => EnvImpl,
|
77
79
|
Future: () => Future,
|
78
80
|
IDMode: () => IDMode,
|
79
81
|
IsLogger: () => IsLogger,
|
@@ -98,7 +100,8 @@ __export(src_exports, {
|
|
98
100
|
String2TimeMode: () => String2TimeMode,
|
99
101
|
Time: () => Time,
|
100
102
|
TimeMode: () => TimeMode,
|
101
|
-
TimeUnits: () => TimeUnits
|
103
|
+
TimeUnits: () => TimeUnits,
|
104
|
+
envImpl: () => envImpl
|
102
105
|
});
|
103
106
|
module.exports = __toCommonJS(src_exports);
|
104
107
|
|
@@ -353,6 +356,171 @@ var WrapperSysAbstraction = class {
|
|
353
356
|
}
|
354
357
|
};
|
355
358
|
|
359
|
+
// src/sys_env.ts
|
360
|
+
var _node, _env;
|
361
|
+
var NodeEnvActions = class {
|
362
|
+
// eslint-disable-next-line @typescript-eslint/no-useless-constructor, @typescript-eslint/no-unused-vars
|
363
|
+
constructor(opts) {
|
364
|
+
__privateAdd(this, _node, globalThis);
|
365
|
+
__privateAdd(this, _env, this.use() ? process.env : {});
|
366
|
+
}
|
367
|
+
use() {
|
368
|
+
return typeof __privateGet(this, _node) === "object" && typeof __privateGet(this, _node).process === "object" && typeof __privateGet(this, _node).process.env === "object";
|
369
|
+
}
|
370
|
+
keys() {
|
371
|
+
return Object.keys(__privateGet(this, _env));
|
372
|
+
}
|
373
|
+
get(key) {
|
374
|
+
return __privateGet(this, _env)[key];
|
375
|
+
}
|
376
|
+
set(key, value) {
|
377
|
+
if (value) {
|
378
|
+
__privateGet(this, _env)[key] = value;
|
379
|
+
}
|
380
|
+
}
|
381
|
+
del(key) {
|
382
|
+
delete __privateGet(this, _env)[key];
|
383
|
+
}
|
384
|
+
};
|
385
|
+
_node = new WeakMap();
|
386
|
+
_env = new WeakMap();
|
387
|
+
var _deno, _env2;
|
388
|
+
var DenoEnvActions = class {
|
389
|
+
constructor(opts, env) {
|
390
|
+
__privateAdd(this, _deno, globalThis);
|
391
|
+
__privateAdd(this, _env2);
|
392
|
+
if (env) {
|
393
|
+
__privateSet(this, _env2, env);
|
394
|
+
} else {
|
395
|
+
__privateSet(this, _env2, this.use() ? __privateGet(this, _deno).Deno.env : /* @__PURE__ */ new Map());
|
396
|
+
}
|
397
|
+
}
|
398
|
+
use() {
|
399
|
+
return typeof __privateGet(this, _deno) === "object" && typeof __privateGet(this, _deno).Deno === "object" && typeof __privateGet(this, _deno).Deno.env === "object";
|
400
|
+
}
|
401
|
+
keys() {
|
402
|
+
return Array.from(__privateGet(this, _env2).keys());
|
403
|
+
}
|
404
|
+
get(key) {
|
405
|
+
return __privateGet(this, _env2).get(key);
|
406
|
+
}
|
407
|
+
set(key, value) {
|
408
|
+
if (value) {
|
409
|
+
__privateGet(this, _env2).set(key, value);
|
410
|
+
}
|
411
|
+
}
|
412
|
+
del(key) {
|
413
|
+
__privateGet(this, _env2).delete(key);
|
414
|
+
}
|
415
|
+
};
|
416
|
+
_deno = new WeakMap();
|
417
|
+
_env2 = new WeakMap();
|
418
|
+
var BrowserEnvActions = class _BrowserEnvActions extends DenoEnvActions {
|
419
|
+
static globalBEA(sym) {
|
420
|
+
const browser = globalThis;
|
421
|
+
if (typeof browser === "object" && typeof browser[sym] === "object") {
|
422
|
+
return { map: browser[sym]._map, finalize: () => browser[sym]._map };
|
423
|
+
}
|
424
|
+
const map = /* @__PURE__ */ new Map();
|
425
|
+
return {
|
426
|
+
map,
|
427
|
+
finalize: (bea) => {
|
428
|
+
browser[sym] = bea;
|
429
|
+
return map;
|
430
|
+
}
|
431
|
+
};
|
432
|
+
}
|
433
|
+
constructor(opts) {
|
434
|
+
const { map, finalize } = _BrowserEnvActions.globalBEA(Symbol.for(opts.symbol || "CP_ENV"));
|
435
|
+
super(opts, map);
|
436
|
+
this._map = finalize(this);
|
437
|
+
}
|
438
|
+
use() {
|
439
|
+
return true;
|
440
|
+
}
|
441
|
+
};
|
442
|
+
function envFactory(opts = {}) {
|
443
|
+
const found = [new NodeEnvActions(opts), new DenoEnvActions(opts), new BrowserEnvActions(opts)].find((env) => env.use());
|
444
|
+
if (!found) {
|
445
|
+
throw new Error("SysContainer:envFactory: no env available");
|
446
|
+
}
|
447
|
+
return found;
|
448
|
+
}
|
449
|
+
var _envImpl, _EnvImpl_instances, updatePresets_fn, applyOnSet_fn, _onSet;
|
450
|
+
var EnvImpl = class {
|
451
|
+
constructor(opts = {}) {
|
452
|
+
__privateAdd(this, _EnvImpl_instances);
|
453
|
+
__privateAdd(this, _envImpl);
|
454
|
+
__privateAdd(this, _onSet, []);
|
455
|
+
__privateSet(this, _envImpl, envFactory(opts));
|
456
|
+
__privateMethod(this, _EnvImpl_instances, updatePresets_fn).call(this, opts.presetEnv);
|
457
|
+
}
|
458
|
+
keys() {
|
459
|
+
return __privateGet(this, _envImpl).keys();
|
460
|
+
}
|
461
|
+
// filter is not set all sets passed
|
462
|
+
onSet(fn, ...filter) {
|
463
|
+
const item = { filter: new Set(filter), fn };
|
464
|
+
__privateGet(this, _onSet).push(item);
|
465
|
+
__privateMethod(this, _EnvImpl_instances, applyOnSet_fn).call(this, [item]);
|
466
|
+
}
|
467
|
+
get(key) {
|
468
|
+
return __privateGet(this, _envImpl).get(key);
|
469
|
+
}
|
470
|
+
set(key, value) {
|
471
|
+
if (!value) {
|
472
|
+
return;
|
473
|
+
}
|
474
|
+
__privateGet(this, _envImpl).set(key, value);
|
475
|
+
__privateMethod(this, _EnvImpl_instances, applyOnSet_fn).call(this, __privateGet(this, _onSet), key, value);
|
476
|
+
}
|
477
|
+
del(key) {
|
478
|
+
__privateGet(this, _envImpl).del(key);
|
479
|
+
__privateMethod(this, _EnvImpl_instances, applyOnSet_fn).call(this, __privateGet(this, _onSet), key);
|
480
|
+
}
|
481
|
+
};
|
482
|
+
_envImpl = new WeakMap();
|
483
|
+
_EnvImpl_instances = new WeakSet();
|
484
|
+
updatePresets_fn = function(presetEnv) {
|
485
|
+
if (!presetEnv) {
|
486
|
+
return;
|
487
|
+
}
|
488
|
+
for (const [key, value] of presetEnv) {
|
489
|
+
__privateGet(this, _envImpl).set(key, value);
|
490
|
+
}
|
491
|
+
};
|
492
|
+
applyOnSet_fn = function(onSet, key, value) {
|
493
|
+
onSet.forEach((item) => {
|
494
|
+
let keys = [];
|
495
|
+
if (key) {
|
496
|
+
keys = [key];
|
497
|
+
} else {
|
498
|
+
keys = __privateGet(this, _envImpl).keys();
|
499
|
+
}
|
500
|
+
keys.filter((k) => {
|
501
|
+
if (item.filter.size === 0) {
|
502
|
+
return true;
|
503
|
+
}
|
504
|
+
if (item.filter.has(k)) {
|
505
|
+
return true;
|
506
|
+
}
|
507
|
+
return false;
|
508
|
+
}).forEach((k) => {
|
509
|
+
let v;
|
510
|
+
if (!key && !value) {
|
511
|
+
v = __privateGet(this, _envImpl).get(k);
|
512
|
+
} else if (key && !value) {
|
513
|
+
v = void 0;
|
514
|
+
} else {
|
515
|
+
v = value;
|
516
|
+
}
|
517
|
+
item.fn(k, v);
|
518
|
+
});
|
519
|
+
});
|
520
|
+
};
|
521
|
+
_onSet = new WeakMap();
|
522
|
+
var envImpl = new EnvImpl();
|
523
|
+
|
356
524
|
// src/web/web_sys_abstraction.ts
|
357
525
|
var WebFileService = class {
|
358
526
|
get baseDir() {
|
@@ -401,7 +569,7 @@ var WebFileService = class {
|
|
401
569
|
};
|
402
570
|
var WebSystemService = class {
|
403
571
|
Env() {
|
404
|
-
|
572
|
+
return envImpl;
|
405
573
|
}
|
406
574
|
Args() {
|
407
575
|
throw new Error("Args-Method not implemented.");
|
@@ -1213,6 +1381,7 @@ var KeyedResolvSeq = class extends Keyed {
|
|
1213
1381
|
};
|
1214
1382
|
// Annotate the CommonJS export names for ESM import in node:
|
1215
1383
|
0 && (module.exports = {
|
1384
|
+
EnvImpl,
|
1216
1385
|
Future,
|
1217
1386
|
IDMode,
|
1218
1387
|
IsLogger,
|
@@ -1237,6 +1406,7 @@ var KeyedResolvSeq = class extends Keyed {
|
|
1237
1406
|
String2TimeMode,
|
1238
1407
|
Time,
|
1239
1408
|
TimeMode,
|
1240
|
-
TimeUnits
|
1409
|
+
TimeUnits,
|
1410
|
+
envImpl
|
1241
1411
|
});
|
1242
1412
|
//# sourceMappingURL=index.cjs.map
|