@adviser/cement 0.3.0 → 0.3.2
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-CR_Z-Ceg.d.ts +84 -0
- package/base-sys-abstraction-DWtPI7Kg.d.cts +84 -0
- package/cf/index.cjs +929 -0
- package/cf/index.cjs.map +1 -0
- package/cf/index.d.cts +26 -0
- package/cf/index.d.ts +26 -0
- package/cf/index.js +12 -0
- package/cf/index.js.map +1 -0
- package/{chunk-3RHIVQAA.js → chunk-A7OPSHUV.js} +6 -94
- package/chunk-A7OPSHUV.js.map +1 -0
- package/chunk-DZPKZQIT.js +1182 -0
- package/chunk-DZPKZQIT.js.map +1 -0
- package/chunk-HFP74WLI.js +96 -0
- package/chunk-HFP74WLI.js.map +1 -0
- package/chunk-R2EEZNZN.js +1742 -0
- package/chunk-R2EEZNZN.js.map +1 -0
- package/deno/index.cjs +940 -0
- package/deno/index.cjs.map +1 -0
- package/deno/index.d.cts +59 -0
- package/deno/index.d.ts +59 -0
- package/deno/index.js +16 -0
- package/deno/index.js.map +1 -0
- package/index-BfZxTAe_.d.cts +318 -0
- package/index-CfSl8Gmj.d.ts +318 -0
- package/index.cjs +407 -139
- package/index.cjs.map +1 -1
- package/index.d.cts +7 -317
- package/index.d.ts +7 -317
- package/index.js +36 -1729
- package/index.js.map +1 -1
- package/node/index.cjs +267 -214
- package/node/index.cjs.map +1 -1
- package/node/index.d.cts +16 -21
- package/node/index.d.ts +16 -21
- package/node/index.js +8 -352
- package/node/index.js.map +1 -1
- package/package.json +18 -11
- package/src/cf/cf-sys-abstraction.ts +78 -0
- package/src/cf/index.ts +1 -0
- package/src/{node → deno}/deno-file-service.ts +2 -2
- package/src/{node → deno}/deno-sys-abstraction.ts +64 -7
- package/src/deno/index.ts +2 -0
- package/src/index.ts +1 -2
- package/src/jsr.json +1 -1
- package/src/logger-impl.ts +2 -2
- package/src/logger.ts +10 -3
- package/src/node/index.ts +0 -1
- package/src/node/node-sys-abstraction.ts +45 -1
- package/src/runtime.ts +13 -3
- package/src/sys-env.ts +36 -109
- package/src/test/index.ts +2 -0
- package/src/uri.ts +2 -2
- package/src/web/web-sys-abstraction.ts +42 -2
- package/sys-abstraction-GNnBj2sz.d.cts +102 -0
- package/sys-abstraction-GNnBj2sz.d.ts +102 -0
- package/test/index.cjs +2681 -0
- package/test/index.cjs.map +1 -0
- package/test/index.d.cts +3 -0
- package/test/index.d.ts +3 -0
- package/test/index.js +14 -0
- package/test/index.js.map +1 -0
- package/ts/base-sys-abstraction.test.js +8 -2
- package/ts/base-sys-abstraction.test.js.map +1 -1
- package/ts/cf/cf-sys-abstraction.d.ts +24 -0
- package/ts/cf/cf-sys-abstraction.d.ts.map +1 -0
- package/ts/cf/cf-sys-abstraction.js +72 -0
- package/ts/cf/cf-sys-abstraction.js.map +1 -0
- package/ts/cf/index.d.ts +2 -0
- package/ts/cf/index.d.ts.map +1 -0
- package/ts/cf/index.js +2 -0
- package/ts/cf/index.js.map +1 -0
- package/ts/crypto.test.js +1 -1
- package/ts/crypto.test.js.map +1 -1
- package/ts/{node → deno}/deno-file-service.d.ts.map +1 -1
- package/ts/{node → deno}/deno-file-service.js +1 -1
- package/ts/{node → deno}/deno-file-service.js.map +1 -1
- package/ts/deno/deno-sys-abstraction.d.ts +43 -0
- package/ts/deno/deno-sys-abstraction.d.ts.map +1 -0
- package/ts/{node → deno}/deno-sys-abstraction.js +46 -2
- package/ts/deno/deno-sys-abstraction.js.map +1 -0
- package/ts/deno/index.d.ts +3 -0
- package/ts/deno/index.d.ts.map +1 -0
- package/ts/deno/index.js +3 -0
- package/ts/deno/index.js.map +1 -0
- package/ts/index.d.ts +1 -2
- package/ts/index.d.ts.map +1 -1
- package/ts/index.js +1 -2
- package/ts/index.js.map +1 -1
- package/ts/logger-impl.js +2 -2
- package/ts/logger-impl.js.map +1 -1
- package/ts/logger.d.ts.map +1 -1
- package/ts/logger.js +9 -3
- package/ts/logger.js.map +1 -1
- package/ts/logger.test.js +9 -9
- package/ts/logger.test.js.map +1 -1
- package/ts/node/index.d.ts +0 -1
- package/ts/node/index.d.ts.map +1 -1
- package/ts/node/index.js +0 -1
- package/ts/node/index.js.map +1 -1
- package/ts/node/node-sys-abstraction.d.ts +14 -1
- package/ts/node/node-sys-abstraction.d.ts.map +1 -1
- package/ts/node/node-sys-abstraction.js +43 -0
- package/ts/node/node-sys-abstraction.js.map +1 -1
- package/ts/runtime.d.ts +1 -0
- package/ts/runtime.d.ts.map +1 -1
- package/ts/runtime.js +10 -3
- package/ts/runtime.js.map +1 -1
- package/ts/sys-env.d.ts +2 -11
- package/ts/sys-env.d.ts.map +1 -1
- package/ts/sys-env.js +29 -98
- package/ts/sys-env.js.map +1 -1
- package/ts/sys-env.test.js +68 -3
- package/ts/sys-env.test.js.map +1 -1
- package/ts/test/index.d.ts +3 -0
- package/ts/test/index.d.ts.map +1 -0
- package/ts/test/index.js +3 -0
- package/ts/test/index.js.map +1 -0
- package/ts/test/test-exit-handler.js +1 -1
- package/ts/uri.d.ts +2 -2
- package/ts/uri.d.ts.map +1 -1
- package/ts/web/web-sys-abstraction.d.ts +27 -0
- package/ts/web/web-sys-abstraction.d.ts.map +1 -1
- package/ts/web/web-sys-abstraction.js +35 -1
- package/ts/web/web-sys-abstraction.js.map +1 -1
- package/utils/index.js +6 -4
- package/web/index.cjs +391 -64
- package/web/index.cjs.map +1 -1
- package/web/index.d.cts +28 -2
- package/web/index.d.ts +28 -2
- package/web/index.js +5 -2
- package/base-sys-abstraction-BkEiLHl0.d.ts +0 -193
- package/base-sys-abstraction-Qj7pkY1N.d.cts +0 -193
- package/chunk-3RHIVQAA.js.map +0 -1
- package/chunk-N3NUTN4B.js +0 -87
- package/chunk-N3NUTN4B.js.map +0 -1
- package/chunk-N5LQQXOU.js +0 -610
- package/chunk-N5LQQXOU.js.map +0 -1
- package/ts/node/deno-sys-abstraction.d.ts +0 -22
- package/ts/node/deno-sys-abstraction.d.ts.map +0 -1
- package/ts/node/deno-sys-abstraction.js.map +0 -1
- /package/ts/{node → deno}/deno-file-service.d.ts +0 -0
@@ -0,0 +1,1182 @@
|
|
1
|
+
import {
|
2
|
+
Utf8EnDecoderSingleton,
|
3
|
+
__privateAdd,
|
4
|
+
__privateGet,
|
5
|
+
__privateSet
|
6
|
+
} from "./chunk-PPS4L4VW.js";
|
7
|
+
|
8
|
+
// src/sys-abstraction.ts
|
9
|
+
var TimeMode = /* @__PURE__ */ ((TimeMode2) => {
|
10
|
+
TimeMode2["REAL"] = "real";
|
11
|
+
TimeMode2["CONST"] = "const";
|
12
|
+
TimeMode2["STEP"] = "step";
|
13
|
+
return TimeMode2;
|
14
|
+
})(TimeMode || {});
|
15
|
+
var RandomMode = /* @__PURE__ */ ((RandomMode2) => {
|
16
|
+
RandomMode2["CONST"] = "const";
|
17
|
+
RandomMode2["STEP"] = "step";
|
18
|
+
RandomMode2["RANDOM"] = "random";
|
19
|
+
return RandomMode2;
|
20
|
+
})(RandomMode || {});
|
21
|
+
var IDMode = /* @__PURE__ */ ((IDMode2) => {
|
22
|
+
IDMode2["UUID"] = "uuid";
|
23
|
+
IDMode2["CONST"] = "const";
|
24
|
+
IDMode2["STEP"] = "step";
|
25
|
+
return IDMode2;
|
26
|
+
})(IDMode || {});
|
27
|
+
function String2TimeMode(s) {
|
28
|
+
switch (s == null ? void 0 : s.toLowerCase()) {
|
29
|
+
case "real":
|
30
|
+
return "real" /* REAL */;
|
31
|
+
case "const":
|
32
|
+
return "const" /* CONST */;
|
33
|
+
case "step":
|
34
|
+
return "step" /* STEP */;
|
35
|
+
default:
|
36
|
+
return "real" /* REAL */;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
// src/time.ts
|
41
|
+
var Time = class {
|
42
|
+
TimeSince(start) {
|
43
|
+
const now = this.Now();
|
44
|
+
return now.getTime() - start.getTime();
|
45
|
+
}
|
46
|
+
};
|
47
|
+
var TimeUnits = /* @__PURE__ */ ((TimeUnits2) => {
|
48
|
+
TimeUnits2[TimeUnits2["Microsecond"] = 1] = "Microsecond";
|
49
|
+
TimeUnits2[TimeUnits2["Second"] = 1e3] = "Second";
|
50
|
+
TimeUnits2[TimeUnits2["Minute"] = 6e4] = "Minute";
|
51
|
+
TimeUnits2[TimeUnits2["Hour"] = 36e5] = "Hour";
|
52
|
+
return TimeUnits2;
|
53
|
+
})(TimeUnits || {});
|
54
|
+
|
55
|
+
// src/base-sys-abstraction.ts
|
56
|
+
var SysTime = class extends Time {
|
57
|
+
Now() {
|
58
|
+
return /* @__PURE__ */ new Date();
|
59
|
+
}
|
60
|
+
Sleep(duration) {
|
61
|
+
return new Promise((resolve2) => {
|
62
|
+
setTimeout(() => {
|
63
|
+
resolve2();
|
64
|
+
}, duration);
|
65
|
+
});
|
66
|
+
}
|
67
|
+
};
|
68
|
+
var ConstTime = class extends Time {
|
69
|
+
Now() {
|
70
|
+
return new Date(2021, 1, 1, 0, 0, 0, 0);
|
71
|
+
}
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
73
|
+
Sleep(duration) {
|
74
|
+
return Promise.resolve();
|
75
|
+
}
|
76
|
+
};
|
77
|
+
var StepTime = class extends Time {
|
78
|
+
constructor() {
|
79
|
+
super();
|
80
|
+
this._step = new ConstTime().Now();
|
81
|
+
this._start = this._step;
|
82
|
+
}
|
83
|
+
Now(steps = 1) {
|
84
|
+
for (let i = 0; steps > 0 && i < steps; i++) {
|
85
|
+
this._step = new Date(this._step.getTime() + 1e3);
|
86
|
+
}
|
87
|
+
if (steps < 1) {
|
88
|
+
this._step = new Date(this._start.getTime() + steps * -1e3);
|
89
|
+
}
|
90
|
+
return this._step;
|
91
|
+
}
|
92
|
+
Sleep(duration) {
|
93
|
+
this._step = new Date(this._step.getTime() + duration);
|
94
|
+
return Promise.resolve();
|
95
|
+
}
|
96
|
+
};
|
97
|
+
function TimeFactory(timeMode) {
|
98
|
+
switch (timeMode) {
|
99
|
+
case "real" /* REAL */:
|
100
|
+
return new SysTime();
|
101
|
+
case "const" /* CONST */:
|
102
|
+
return new ConstTime();
|
103
|
+
case "step" /* STEP */:
|
104
|
+
return new StepTime();
|
105
|
+
}
|
106
|
+
return new SysTime();
|
107
|
+
}
|
108
|
+
var RandomService = class {
|
109
|
+
constructor(mode) {
|
110
|
+
this._step = 0;
|
111
|
+
this._mode = mode;
|
112
|
+
}
|
113
|
+
Random0ToValue(value) {
|
114
|
+
switch (this._mode) {
|
115
|
+
case "const" /* CONST */:
|
116
|
+
return 0.5 * value;
|
117
|
+
case "step" /* STEP */:
|
118
|
+
this._step += 1e-4;
|
119
|
+
return this._step * value;
|
120
|
+
case "random" /* RANDOM */:
|
121
|
+
return Math.random() * value;
|
122
|
+
default:
|
123
|
+
throw new Error("Unknown RandomMode");
|
124
|
+
}
|
125
|
+
}
|
126
|
+
};
|
127
|
+
var IdService = class {
|
128
|
+
constructor(mode) {
|
129
|
+
this._step = 0;
|
130
|
+
if (!mode) {
|
131
|
+
mode = "uuid" /* UUID */;
|
132
|
+
}
|
133
|
+
this._mode = mode;
|
134
|
+
}
|
135
|
+
NextId() {
|
136
|
+
switch (this._mode) {
|
137
|
+
case "uuid" /* UUID */:
|
138
|
+
return crypto.randomUUID();
|
139
|
+
case "const" /* CONST */:
|
140
|
+
return "VeryUniqueID";
|
141
|
+
case "step" /* STEP */:
|
142
|
+
return `STEPId-${this._step++}`;
|
143
|
+
default:
|
144
|
+
throw new Error("Unknown IDMode");
|
145
|
+
}
|
146
|
+
}
|
147
|
+
};
|
148
|
+
function consumeReadableStream(reader, writeFn) {
|
149
|
+
reader.read().then(({ done, value }) => {
|
150
|
+
if (done) {
|
151
|
+
return;
|
152
|
+
}
|
153
|
+
writeFn(value).then(() => {
|
154
|
+
consumeReadableStream(reader, writeFn);
|
155
|
+
}).catch((e) => {
|
156
|
+
console.error("consumeReadableStream:writeFn", e);
|
157
|
+
});
|
158
|
+
}).catch((e) => {
|
159
|
+
console.error("consumeReadableStream:read", e);
|
160
|
+
});
|
161
|
+
}
|
162
|
+
function CFWriteableStream(writeFn) {
|
163
|
+
const ts = new TransformStream();
|
164
|
+
consumeReadableStream(ts.readable.getReader(), writeFn);
|
165
|
+
return ts.writable;
|
166
|
+
}
|
167
|
+
var BaseSysAbstraction = class {
|
168
|
+
constructor(params) {
|
169
|
+
this._time = new SysTime();
|
170
|
+
this._idService = new IdService();
|
171
|
+
this._randomService = new RandomService("random" /* RANDOM */);
|
172
|
+
this._fileSystem = params.FileSystem;
|
173
|
+
this._systemService = params.SystemService;
|
174
|
+
this._txtEnDe = params.TxtEnDecoder;
|
175
|
+
const decoder = this._txtEnDe;
|
176
|
+
this._stdout = CFWriteableStream(async (chunk) => {
|
177
|
+
const decoded = decoder.decode(chunk);
|
178
|
+
console.log(decoded.trimEnd());
|
179
|
+
});
|
180
|
+
this._stderr = CFWriteableStream(async (chunk) => {
|
181
|
+
const decoded = decoder.decode(chunk);
|
182
|
+
console.error(decoded.trimEnd());
|
183
|
+
});
|
184
|
+
}
|
185
|
+
};
|
186
|
+
var WrapperSysAbstraction = class {
|
187
|
+
constructor(base, params) {
|
188
|
+
this._time = base._time;
|
189
|
+
this._stdout = base._stdout;
|
190
|
+
this._stderr = base._stderr;
|
191
|
+
this._idService = base._idService;
|
192
|
+
this._randomService = base._randomService;
|
193
|
+
this._fileSystem = base._fileSystem;
|
194
|
+
this._systemService = base._systemService;
|
195
|
+
if (params) {
|
196
|
+
if (params.TimeMode) {
|
197
|
+
this._time = TimeFactory(params.TimeMode);
|
198
|
+
}
|
199
|
+
if (params.Stdout) {
|
200
|
+
this._stdout = params.Stdout;
|
201
|
+
}
|
202
|
+
if (params.Stderr) {
|
203
|
+
this._stderr = params.Stderr;
|
204
|
+
}
|
205
|
+
if (params.IdMode) {
|
206
|
+
this._idService = new IdService(params.IdMode);
|
207
|
+
}
|
208
|
+
if (params.RandomMode) {
|
209
|
+
this._randomService = new RandomService(params.RandomMode);
|
210
|
+
}
|
211
|
+
if (params.FileSystem) {
|
212
|
+
this._fileSystem = params.FileSystem;
|
213
|
+
}
|
214
|
+
if (params.SystemService) {
|
215
|
+
this._systemService = params.SystemService;
|
216
|
+
}
|
217
|
+
}
|
218
|
+
}
|
219
|
+
Time() {
|
220
|
+
return this._time;
|
221
|
+
}
|
222
|
+
NextId() {
|
223
|
+
return this._idService.NextId();
|
224
|
+
}
|
225
|
+
Random0ToValue(value) {
|
226
|
+
return this._randomService.Random0ToValue(value);
|
227
|
+
}
|
228
|
+
Stdout() {
|
229
|
+
return this._stdout;
|
230
|
+
}
|
231
|
+
Stderr() {
|
232
|
+
return this._stderr;
|
233
|
+
}
|
234
|
+
System() {
|
235
|
+
return this._systemService;
|
236
|
+
}
|
237
|
+
FileSystem() {
|
238
|
+
return this._fileSystem;
|
239
|
+
}
|
240
|
+
};
|
241
|
+
|
242
|
+
// src/future.ts
|
243
|
+
var _promise, _resolveFn, _rejectFn;
|
244
|
+
var Future = class {
|
245
|
+
constructor() {
|
246
|
+
__privateAdd(this, _promise);
|
247
|
+
__privateAdd(this, _resolveFn, () => {
|
248
|
+
throw new Error("This Promise is not working as expected.");
|
249
|
+
});
|
250
|
+
__privateAdd(this, _rejectFn, () => {
|
251
|
+
throw new Error("This Promise is not working as expected.");
|
252
|
+
});
|
253
|
+
__privateSet(this, _promise, new Promise((resolve2, reject) => {
|
254
|
+
__privateSet(this, _resolveFn, resolve2);
|
255
|
+
__privateSet(this, _rejectFn, reject);
|
256
|
+
}));
|
257
|
+
}
|
258
|
+
async asPromise() {
|
259
|
+
return __privateGet(this, _promise);
|
260
|
+
}
|
261
|
+
resolve(value) {
|
262
|
+
__privateGet(this, _resolveFn).call(this, value);
|
263
|
+
}
|
264
|
+
reject(reason) {
|
265
|
+
__privateGet(this, _rejectFn).call(this, reason);
|
266
|
+
}
|
267
|
+
};
|
268
|
+
_promise = new WeakMap();
|
269
|
+
_resolveFn = new WeakMap();
|
270
|
+
_rejectFn = new WeakMap();
|
271
|
+
|
272
|
+
// src/resolve-once.ts
|
273
|
+
var ResolveSeq = class {
|
274
|
+
constructor(ctx) {
|
275
|
+
this._seqFutures = [];
|
276
|
+
this.ctx = ctx;
|
277
|
+
}
|
278
|
+
reset() {
|
279
|
+
}
|
280
|
+
async _step(item) {
|
281
|
+
if (!item) {
|
282
|
+
return;
|
283
|
+
}
|
284
|
+
item.fn(this.ctx).then((value) => item.future.resolve(value)).catch((e) => item.future.reject(e)).finally(() => {
|
285
|
+
this._seqFutures.shift();
|
286
|
+
this._step(this._seqFutures[0]);
|
287
|
+
});
|
288
|
+
}
|
289
|
+
async add(fn, id) {
|
290
|
+
const future = new Future();
|
291
|
+
this._seqFutures.push({ future, fn, id });
|
292
|
+
if (this._seqFutures.length === 1) {
|
293
|
+
this._step(this._seqFutures[0]);
|
294
|
+
}
|
295
|
+
return future.asPromise();
|
296
|
+
}
|
297
|
+
};
|
298
|
+
var ResolveOnce = class {
|
299
|
+
constructor(ctx) {
|
300
|
+
this._onceDone = false;
|
301
|
+
this._onceFutures = [];
|
302
|
+
this._onceOk = false;
|
303
|
+
this._isPromise = false;
|
304
|
+
this.ctx = ctx;
|
305
|
+
}
|
306
|
+
get ready() {
|
307
|
+
return this._onceDone;
|
308
|
+
}
|
309
|
+
reset() {
|
310
|
+
this._onceDone = false;
|
311
|
+
this._onceOk = false;
|
312
|
+
this._onceValue = void 0;
|
313
|
+
this._onceError = void 0;
|
314
|
+
this._onceFutures.length = 0;
|
315
|
+
}
|
316
|
+
// T extends Option<infer U> ? U : T
|
317
|
+
once(fn) {
|
318
|
+
if (this._onceDone) {
|
319
|
+
if (this._onceError) {
|
320
|
+
if (this._isPromise) {
|
321
|
+
return Promise.reject(this._onceError);
|
322
|
+
} else {
|
323
|
+
throw this._onceError;
|
324
|
+
}
|
325
|
+
}
|
326
|
+
if (this._onceOk) {
|
327
|
+
if (this._isPromise) {
|
328
|
+
return Promise.resolve(this._onceValue);
|
329
|
+
} else {
|
330
|
+
return this._onceValue;
|
331
|
+
}
|
332
|
+
}
|
333
|
+
throw new Error("ResolveOnce.once impossible");
|
334
|
+
}
|
335
|
+
const future = new Future();
|
336
|
+
this._onceFutures.push(future);
|
337
|
+
if (this._onceFutures.length === 1) {
|
338
|
+
const okFn = (value) => {
|
339
|
+
this._onceValue = value;
|
340
|
+
this._onceOk = true;
|
341
|
+
this._onceDone = true;
|
342
|
+
if (this._isPromise) {
|
343
|
+
this._onceFutures.forEach((f) => f.resolve(this._onceValue));
|
344
|
+
}
|
345
|
+
this._onceFutures.length = 0;
|
346
|
+
};
|
347
|
+
const catchFn = (e) => {
|
348
|
+
this._onceError = e;
|
349
|
+
this._onceOk = false;
|
350
|
+
this._onceValue = void 0;
|
351
|
+
this._onceDone = true;
|
352
|
+
if (this._isPromise) {
|
353
|
+
this._onceFutures.forEach((f) => f.reject(this._onceError));
|
354
|
+
}
|
355
|
+
this._onceFutures.length = 0;
|
356
|
+
};
|
357
|
+
try {
|
358
|
+
const ret = fn(this.ctx);
|
359
|
+
if (typeof ret.then === "function") {
|
360
|
+
this._isPromise = true;
|
361
|
+
ret.then(okFn).catch(catchFn);
|
362
|
+
} else {
|
363
|
+
okFn(ret);
|
364
|
+
}
|
365
|
+
} catch (e) {
|
366
|
+
catchFn(e);
|
367
|
+
}
|
368
|
+
}
|
369
|
+
if (this._isPromise) {
|
370
|
+
return future.asPromise();
|
371
|
+
} else {
|
372
|
+
return this.once(fn);
|
373
|
+
}
|
374
|
+
}
|
375
|
+
};
|
376
|
+
var Keyed = class {
|
377
|
+
constructor(factory) {
|
378
|
+
this._map = /* @__PURE__ */ new Map();
|
379
|
+
this.factory = factory;
|
380
|
+
}
|
381
|
+
async asyncGet(key) {
|
382
|
+
return this.get(await key());
|
383
|
+
}
|
384
|
+
get(key) {
|
385
|
+
if (typeof key === "function") {
|
386
|
+
key = key();
|
387
|
+
}
|
388
|
+
let keyed = this._map.get(key);
|
389
|
+
if (!keyed) {
|
390
|
+
keyed = this.factory(key);
|
391
|
+
this._map.set(key, keyed);
|
392
|
+
}
|
393
|
+
return keyed;
|
394
|
+
}
|
395
|
+
unget(key) {
|
396
|
+
const keyed = this._map.get(key);
|
397
|
+
keyed == null ? void 0 : keyed.reset();
|
398
|
+
this._map.delete(key);
|
399
|
+
}
|
400
|
+
reset() {
|
401
|
+
this._map.forEach((keyed) => keyed.reset());
|
402
|
+
this._map.clear();
|
403
|
+
}
|
404
|
+
};
|
405
|
+
var KeyedResolvOnce = class extends Keyed {
|
406
|
+
constructor() {
|
407
|
+
super((key) => new ResolveOnce(key));
|
408
|
+
}
|
409
|
+
};
|
410
|
+
var KeyedResolvSeq = class extends Keyed {
|
411
|
+
constructor() {
|
412
|
+
super((key) => new ResolveSeq(key));
|
413
|
+
}
|
414
|
+
};
|
415
|
+
|
416
|
+
// src/runtime.ts
|
417
|
+
function isSet(value, ref = globalThis) {
|
418
|
+
const [head, ...tail] = value.split(".");
|
419
|
+
if (["object", "function"].includes(typeof ref) && ref && ["object", "function"].includes(typeof ref[head]) && ref[head]) {
|
420
|
+
if (tail.length <= 1) {
|
421
|
+
return true;
|
422
|
+
}
|
423
|
+
return isSet(tail.join("."), ref[head]);
|
424
|
+
}
|
425
|
+
return false;
|
426
|
+
}
|
427
|
+
function runtimeFn() {
|
428
|
+
const gt = globalThis;
|
429
|
+
let isReactNative = isSet("navigator.product") && typeof gt["navigator"] === "object" && gt["navigator"]["product"] === "ReactNative";
|
430
|
+
let isNodeIsh = false;
|
431
|
+
if (!isSet("Deno")) {
|
432
|
+
isNodeIsh = isSet("process.versions.node") && !isReactNative;
|
433
|
+
}
|
434
|
+
let isDeno = isSet("Deno");
|
435
|
+
const isCFWorker = isSet("caches.default") && isSet("WebSocketPair");
|
436
|
+
if (isCFWorker) {
|
437
|
+
isDeno = false;
|
438
|
+
isNodeIsh = false;
|
439
|
+
isReactNative = false;
|
440
|
+
}
|
441
|
+
return {
|
442
|
+
isNodeIsh,
|
443
|
+
isBrowser: !(isNodeIsh || isDeno || isCFWorker || isReactNative),
|
444
|
+
isDeno,
|
445
|
+
isReactNative,
|
446
|
+
isCFWorker
|
447
|
+
};
|
448
|
+
}
|
449
|
+
|
450
|
+
// src/deno/deno-file-service.ts
|
451
|
+
import * as path from "node:path";
|
452
|
+
var Deno = globalThis.Deno;
|
453
|
+
var DenoFileService = class {
|
454
|
+
constructor(baseDir = Deno.cwd(), txtEnde = Utf8EnDecoderSingleton()) {
|
455
|
+
this.baseDir = this.abs(baseDir);
|
456
|
+
this.txtEnde = txtEnde;
|
457
|
+
}
|
458
|
+
// nodeImport(fname: string): string {
|
459
|
+
// // console.log('nodeImport:'+ fname);
|
460
|
+
// if (path.isAbsolute(fname)) {
|
461
|
+
// return fname;
|
462
|
+
// } else {
|
463
|
+
// return "./" + path.normalize(fname);
|
464
|
+
// }
|
465
|
+
// }
|
466
|
+
async readFileString(fname) {
|
467
|
+
return this.txtEnde.decode(await Deno.readFile(fname));
|
468
|
+
}
|
469
|
+
dirname(fname) {
|
470
|
+
return path.dirname(fname);
|
471
|
+
}
|
472
|
+
basename(fname) {
|
473
|
+
return path.basename(fname);
|
474
|
+
}
|
475
|
+
join(...paths) {
|
476
|
+
return path.join(...paths);
|
477
|
+
}
|
478
|
+
relative(from, to) {
|
479
|
+
if (to === void 0) {
|
480
|
+
to = from;
|
481
|
+
from = Deno.cwd();
|
482
|
+
}
|
483
|
+
const ret = path.relative(from, to);
|
484
|
+
return ret;
|
485
|
+
}
|
486
|
+
abs(fname) {
|
487
|
+
if (path.isAbsolute(fname)) {
|
488
|
+
return fname;
|
489
|
+
} else {
|
490
|
+
const cwd = Deno.cwd();
|
491
|
+
return path.resolve(cwd, fname);
|
492
|
+
}
|
493
|
+
}
|
494
|
+
isAbsolute(fname) {
|
495
|
+
return path.isAbsolute(fname);
|
496
|
+
}
|
497
|
+
async writeFileString(fname, content, ende = Utf8EnDecoderSingleton()) {
|
498
|
+
const o = await this.create(fname);
|
499
|
+
const wr = o.stream.getWriter();
|
500
|
+
await wr.write(ende.encode(content));
|
501
|
+
await wr.close();
|
502
|
+
}
|
503
|
+
async create(fname) {
|
504
|
+
let oName = fname;
|
505
|
+
if (!path.isAbsolute(fname)) {
|
506
|
+
oName = this.abs(fname);
|
507
|
+
}
|
508
|
+
const base = path.dirname(oName);
|
509
|
+
await Deno.mkdir(base, { recursive: true });
|
510
|
+
const out = await Deno.open(oName, {
|
511
|
+
write: true,
|
512
|
+
create: true,
|
513
|
+
truncate: true
|
514
|
+
});
|
515
|
+
return {
|
516
|
+
name: oName,
|
517
|
+
stream: out
|
518
|
+
};
|
519
|
+
}
|
520
|
+
};
|
521
|
+
|
522
|
+
// src/node/node-file-service.ts
|
523
|
+
import path2 from "node:path";
|
524
|
+
import fs from "node:fs";
|
525
|
+
import process from "node:process";
|
526
|
+
var NodeFileService = class {
|
527
|
+
constructor(baseDir = process.cwd()) {
|
528
|
+
this.baseDir = this.abs(baseDir);
|
529
|
+
}
|
530
|
+
// nodeImport(fname: string): string {
|
531
|
+
// // console.log('nodeImport:'+ fname);
|
532
|
+
// if (path.isAbsolute(fname)) {
|
533
|
+
// return fname;
|
534
|
+
// } else {
|
535
|
+
// return "./" + path.normalize(fname);
|
536
|
+
// }
|
537
|
+
// }
|
538
|
+
readFileString(fname) {
|
539
|
+
return fs.promises.readFile(fname, { encoding: "utf-8" });
|
540
|
+
}
|
541
|
+
dirname(fname) {
|
542
|
+
return path2.dirname(fname);
|
543
|
+
}
|
544
|
+
basename(fname) {
|
545
|
+
return path2.basename(fname);
|
546
|
+
}
|
547
|
+
join(...paths) {
|
548
|
+
return path2.join(...paths);
|
549
|
+
}
|
550
|
+
relative(from, to) {
|
551
|
+
if (to === void 0) {
|
552
|
+
to = from;
|
553
|
+
from = process.cwd();
|
554
|
+
}
|
555
|
+
const ret = path2.relative(from, to);
|
556
|
+
return ret;
|
557
|
+
}
|
558
|
+
abs(fname) {
|
559
|
+
if (path2.isAbsolute(fname)) {
|
560
|
+
return fname;
|
561
|
+
} else {
|
562
|
+
const cwd = process.cwd();
|
563
|
+
return path2.resolve(cwd, fname);
|
564
|
+
}
|
565
|
+
}
|
566
|
+
isAbsolute(fname) {
|
567
|
+
return path2.isAbsolute(fname);
|
568
|
+
}
|
569
|
+
async writeFileString(fname, content, ende = Utf8EnDecoderSingleton()) {
|
570
|
+
const o = await this.create(fname);
|
571
|
+
const wr = o.stream.getWriter();
|
572
|
+
await wr.write(ende.encode(content));
|
573
|
+
await wr.close();
|
574
|
+
}
|
575
|
+
async create(fname) {
|
576
|
+
let oName = fname;
|
577
|
+
if (!path2.isAbsolute(fname)) {
|
578
|
+
oName = this.abs(fname);
|
579
|
+
}
|
580
|
+
const base = path2.dirname(oName);
|
581
|
+
await fs.promises.mkdir(base, { recursive: true });
|
582
|
+
const out = fs.createWriteStream(oName);
|
583
|
+
return {
|
584
|
+
name: oName,
|
585
|
+
stream: new WritableStream({
|
586
|
+
write(chunk) {
|
587
|
+
out.write(chunk);
|
588
|
+
},
|
589
|
+
close() {
|
590
|
+
out.close();
|
591
|
+
},
|
592
|
+
abort() {
|
593
|
+
throw new Error("not implemented");
|
594
|
+
}
|
595
|
+
})
|
596
|
+
};
|
597
|
+
}
|
598
|
+
};
|
599
|
+
|
600
|
+
// src/node/node-sys-abstraction.ts
|
601
|
+
import process2 from "node:process";
|
602
|
+
var once = new ResolveOnce();
|
603
|
+
var _node;
|
604
|
+
var _NodeEnvActions = class _NodeEnvActions {
|
605
|
+
constructor(opts) {
|
606
|
+
__privateAdd(this, _node, globalThis);
|
607
|
+
this._env = this.active() ? __privateGet(this, _node).process.env : {};
|
608
|
+
this.opts = opts;
|
609
|
+
}
|
610
|
+
static new(opts) {
|
611
|
+
return once.once(() => new _NodeEnvActions(opts));
|
612
|
+
}
|
613
|
+
register(env) {
|
614
|
+
for (const key of env.keys()) {
|
615
|
+
this._env[key] = env.get(key) || "";
|
616
|
+
}
|
617
|
+
return env;
|
618
|
+
}
|
619
|
+
active() {
|
620
|
+
return runtimeFn().isNodeIsh;
|
621
|
+
}
|
622
|
+
keys() {
|
623
|
+
return Object.keys(this._env);
|
624
|
+
}
|
625
|
+
get(key) {
|
626
|
+
return this._env[key];
|
627
|
+
}
|
628
|
+
set(key, value) {
|
629
|
+
if (value) {
|
630
|
+
this._env[key] = value;
|
631
|
+
}
|
632
|
+
}
|
633
|
+
delete(key) {
|
634
|
+
delete this._env[key];
|
635
|
+
}
|
636
|
+
};
|
637
|
+
_node = new WeakMap();
|
638
|
+
var NodeEnvActions = _NodeEnvActions;
|
639
|
+
var NodeExitServiceImpl = class {
|
640
|
+
constructor() {
|
641
|
+
this._exitHandlers = [];
|
642
|
+
this.invoked = false;
|
643
|
+
this._handleExit = async () => {
|
644
|
+
if (this.invoked) {
|
645
|
+
return;
|
646
|
+
}
|
647
|
+
this.invoked = true;
|
648
|
+
for (const h of this._exitHandlers) {
|
649
|
+
try {
|
650
|
+
const ret = h.hdl();
|
651
|
+
if (typeof ret.then === "function") {
|
652
|
+
await ret;
|
653
|
+
}
|
654
|
+
} finally {
|
655
|
+
}
|
656
|
+
}
|
657
|
+
};
|
658
|
+
process2.on("unhandledRejection", (reason, p) => {
|
659
|
+
this.exit(19);
|
660
|
+
});
|
661
|
+
process2.on("uncaughtException", (error) => {
|
662
|
+
this.exit(18);
|
663
|
+
});
|
664
|
+
process2.on("close", () => {
|
665
|
+
this.exit(0);
|
666
|
+
});
|
667
|
+
process2.on("exit", () => {
|
668
|
+
this.exit(0);
|
669
|
+
});
|
670
|
+
process2.on("SIGQUIT", () => {
|
671
|
+
this.exit(3);
|
672
|
+
});
|
673
|
+
process2.on("SIGINT", () => {
|
674
|
+
this.exit(2);
|
675
|
+
});
|
676
|
+
process2.on("SIGTERM", () => {
|
677
|
+
this.exit(9);
|
678
|
+
});
|
679
|
+
}
|
680
|
+
injectExitHandlers(hdls) {
|
681
|
+
this._exitHandlers = hdls;
|
682
|
+
}
|
683
|
+
exit(code) {
|
684
|
+
this._handleExit().then(() => {
|
685
|
+
process2.exit(code);
|
686
|
+
}).catch((err) => {
|
687
|
+
console.error("ExitService: failed to handle exit", err);
|
688
|
+
process2.exit(code);
|
689
|
+
});
|
690
|
+
}
|
691
|
+
};
|
692
|
+
var _NodeSystemService = class _NodeSystemService {
|
693
|
+
constructor() {
|
694
|
+
this._exitService = new NodeExitServiceImpl();
|
695
|
+
this._exitService.injectExitHandlers(_NodeSystemService._exitHandlers);
|
696
|
+
}
|
697
|
+
Env() {
|
698
|
+
return envFactory();
|
699
|
+
}
|
700
|
+
Args() {
|
701
|
+
return process2.argv;
|
702
|
+
}
|
703
|
+
OnExit(hdl) {
|
704
|
+
const id = crypto.randomUUID();
|
705
|
+
_NodeSystemService._exitHandlers.push({ hdl, id });
|
706
|
+
return () => {
|
707
|
+
const idx = _NodeSystemService._exitHandlers.findIndex((h) => h.id === id);
|
708
|
+
if (idx >= 0) {
|
709
|
+
_NodeSystemService._exitHandlers.splice(idx, 1);
|
710
|
+
}
|
711
|
+
};
|
712
|
+
}
|
713
|
+
Exit(code) {
|
714
|
+
this._exitService.exit(code);
|
715
|
+
}
|
716
|
+
};
|
717
|
+
_NodeSystemService._exitHandlers = [];
|
718
|
+
var NodeSystemService = _NodeSystemService;
|
719
|
+
var my = void 0;
|
720
|
+
function NodeSysAbstraction(param) {
|
721
|
+
if (!my) {
|
722
|
+
my = new BaseSysAbstraction({
|
723
|
+
TxtEnDecoder: (param == null ? void 0 : param.TxtEnDecoder) || Utf8EnDecoderSingleton(),
|
724
|
+
FileSystem: new NodeFileService(),
|
725
|
+
SystemService: new NodeSystemService()
|
726
|
+
});
|
727
|
+
}
|
728
|
+
return new WrapperSysAbstraction(my, param);
|
729
|
+
}
|
730
|
+
|
731
|
+
// src/web/web-sys-abstraction.ts
|
732
|
+
var once2 = new ResolveOnce();
|
733
|
+
var BrowserEnvActions = class _BrowserEnvActions {
|
734
|
+
constructor(opts) {
|
735
|
+
this.env = /* @__PURE__ */ new Map();
|
736
|
+
this.opts = opts;
|
737
|
+
}
|
738
|
+
static new(opts) {
|
739
|
+
return once2.once(() => new _BrowserEnvActions(opts));
|
740
|
+
}
|
741
|
+
get(key) {
|
742
|
+
return this.env.get(key);
|
743
|
+
}
|
744
|
+
set(key, value) {
|
745
|
+
if (value) {
|
746
|
+
this.env.set(key, value);
|
747
|
+
}
|
748
|
+
}
|
749
|
+
delete(key) {
|
750
|
+
this.env.delete(key);
|
751
|
+
}
|
752
|
+
keys() {
|
753
|
+
return Array.from(this.env.keys());
|
754
|
+
}
|
755
|
+
active() {
|
756
|
+
return true;
|
757
|
+
}
|
758
|
+
register(env) {
|
759
|
+
const sym = Symbol.for(this.opts.symbol || "CP_ENV");
|
760
|
+
const browser = globalThis;
|
761
|
+
browser[sym] = env;
|
762
|
+
return env;
|
763
|
+
}
|
764
|
+
};
|
765
|
+
var WebFileService = class {
|
766
|
+
get baseDir() {
|
767
|
+
throw new Error("basedir-Method not implemented.");
|
768
|
+
}
|
769
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
770
|
+
create(fname) {
|
771
|
+
throw new Error("create-Method not implemented.");
|
772
|
+
}
|
773
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
774
|
+
readFileString(fname) {
|
775
|
+
throw new Error("readFileString-Method not implemented.");
|
776
|
+
}
|
777
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
778
|
+
writeFileString(fname, content) {
|
779
|
+
throw new Error("writeFileString-Method not implemented.");
|
780
|
+
}
|
781
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
782
|
+
abs(fname) {
|
783
|
+
throw new Error("abs-Method not implemented.");
|
784
|
+
}
|
785
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
786
|
+
join(...paths) {
|
787
|
+
throw new Error("join-Method not implemented.");
|
788
|
+
}
|
789
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
790
|
+
relative(from, to) {
|
791
|
+
throw new Error("relative-Method not implemented.");
|
792
|
+
}
|
793
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
794
|
+
dirname(fname) {
|
795
|
+
throw new Error("dirname-Method not implemented.");
|
796
|
+
}
|
797
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
798
|
+
basename(fname) {
|
799
|
+
throw new Error("basename-Method not implemented.");
|
800
|
+
}
|
801
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
802
|
+
nodeImport(fname) {
|
803
|
+
throw new Error("nodeImport-Method not implemented.");
|
804
|
+
}
|
805
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
806
|
+
isAbsolute(fname) {
|
807
|
+
throw new Error("isAbsolute-Method not implemented.");
|
808
|
+
}
|
809
|
+
};
|
810
|
+
var WebSystemService = class {
|
811
|
+
Env() {
|
812
|
+
return envFactory();
|
813
|
+
}
|
814
|
+
Args() {
|
815
|
+
throw new Error("Args-Method not implemented.");
|
816
|
+
}
|
817
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
818
|
+
OnExit(hdl) {
|
819
|
+
throw new Error("OnExit-Method not implemented.");
|
820
|
+
}
|
821
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
822
|
+
Exit(code) {
|
823
|
+
throw new Error("Exit-Method not implemented.");
|
824
|
+
}
|
825
|
+
};
|
826
|
+
var my2 = void 0;
|
827
|
+
function WebSysAbstraction(param) {
|
828
|
+
if (!my2) {
|
829
|
+
my2 = new BaseSysAbstraction({
|
830
|
+
TxtEnDecoder: (param == null ? void 0 : param.TxtEnDecoder) || Utf8EnDecoderSingleton(),
|
831
|
+
FileSystem: new WebFileService(),
|
832
|
+
SystemService: new WebSystemService()
|
833
|
+
});
|
834
|
+
}
|
835
|
+
return new WrapperSysAbstraction(my2, param);
|
836
|
+
}
|
837
|
+
|
838
|
+
// src/cf/cf-sys-abstraction.ts
|
839
|
+
var once3 = new ResolveOnce();
|
840
|
+
var CFEnvActions = class _CFEnvActions {
|
841
|
+
static new(opts) {
|
842
|
+
return once3.once(() => new _CFEnvActions(opts));
|
843
|
+
}
|
844
|
+
static inject(o) {
|
845
|
+
var _a;
|
846
|
+
const env = _CFEnvActions.new({});
|
847
|
+
for (const key in o) {
|
848
|
+
const value = o[key];
|
849
|
+
if (typeof value === "string") {
|
850
|
+
(_a = env.env) == null ? void 0 : _a.set(key, value);
|
851
|
+
}
|
852
|
+
}
|
853
|
+
}
|
854
|
+
constructor(env) {
|
855
|
+
this.cfEnv = new Map(Object.entries(env.presetEnv || {}));
|
856
|
+
}
|
857
|
+
active() {
|
858
|
+
return runtimeFn().isCFWorker;
|
859
|
+
}
|
860
|
+
register(env) {
|
861
|
+
this.env = env;
|
862
|
+
return env;
|
863
|
+
}
|
864
|
+
get(key) {
|
865
|
+
return this.cfEnv.get(key);
|
866
|
+
}
|
867
|
+
set(key, value) {
|
868
|
+
if (value) {
|
869
|
+
this.cfEnv.set(key, value);
|
870
|
+
}
|
871
|
+
}
|
872
|
+
delete(key) {
|
873
|
+
this.cfEnv.delete(key);
|
874
|
+
}
|
875
|
+
keys() {
|
876
|
+
return Array.from(this.cfEnv.keys());
|
877
|
+
}
|
878
|
+
};
|
879
|
+
var CFSystemService = class {
|
880
|
+
Env() {
|
881
|
+
return envFactory();
|
882
|
+
}
|
883
|
+
Args() {
|
884
|
+
throw new Error("Args-Method not implemented.");
|
885
|
+
}
|
886
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
887
|
+
OnExit(hdl) {
|
888
|
+
throw new Error("OnExit-Method not implemented.");
|
889
|
+
}
|
890
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
891
|
+
Exit(code) {
|
892
|
+
throw new Error("Exit-Method not implemented.");
|
893
|
+
}
|
894
|
+
};
|
895
|
+
var my3 = void 0;
|
896
|
+
function CFSysAbstraction(param) {
|
897
|
+
if (!my3) {
|
898
|
+
my3 = new BaseSysAbstraction({
|
899
|
+
TxtEnDecoder: (param == null ? void 0 : param.TxtEnDecoder) || Utf8EnDecoderSingleton(),
|
900
|
+
FileSystem: new WebFileService(),
|
901
|
+
SystemService: new CFSystemService()
|
902
|
+
});
|
903
|
+
}
|
904
|
+
return new WrapperSysAbstraction(my3, param);
|
905
|
+
}
|
906
|
+
|
907
|
+
// src/sys-env.ts
|
908
|
+
var envActions = [
|
909
|
+
{ id: "cf", fn: (opts) => CFEnvActions.new(opts) },
|
910
|
+
{ id: "node", fn: (opts) => NodeEnvActions.new(opts) },
|
911
|
+
{ id: "deno", fn: (opts) => DenoEnvActions.new(opts) },
|
912
|
+
{ id: "browser", fn: (opts) => BrowserEnvActions.new(opts) }
|
913
|
+
];
|
914
|
+
function registerEnvAction(fn) {
|
915
|
+
const id = `id-${Math.random()}`;
|
916
|
+
envActions.unshift({ id, fn });
|
917
|
+
_envFactories.unget(id);
|
918
|
+
return () => {
|
919
|
+
const index = envActions.findIndex((i) => i.id === id);
|
920
|
+
if (index >= 0) {
|
921
|
+
envActions.splice(index, 1);
|
922
|
+
}
|
923
|
+
};
|
924
|
+
}
|
925
|
+
var _envFactories = new KeyedResolvOnce();
|
926
|
+
function envFactory(opts = {}) {
|
927
|
+
const found = envActions.find((fi) => fi.fn(opts).active());
|
928
|
+
if (!found) {
|
929
|
+
throw new Error("SysContainer:envFactory: no env available");
|
930
|
+
}
|
931
|
+
return _envFactories.get(found.id).once(() => {
|
932
|
+
const action = found.fn(opts);
|
933
|
+
const ret = new EnvImpl2(action, opts);
|
934
|
+
action.register(ret);
|
935
|
+
return ret;
|
936
|
+
});
|
937
|
+
}
|
938
|
+
var EnvImpl2 = class {
|
939
|
+
constructor(map, opts = {}) {
|
940
|
+
this._onSet = [];
|
941
|
+
this._map = map;
|
942
|
+
this._updatePresets(opts.presetEnv);
|
943
|
+
}
|
944
|
+
_updatePresets(presetEnv) {
|
945
|
+
if (!presetEnv) {
|
946
|
+
return;
|
947
|
+
}
|
948
|
+
for (const [key, value] of presetEnv) {
|
949
|
+
this._map.set(key, value);
|
950
|
+
}
|
951
|
+
}
|
952
|
+
_applyOnSet(onSet, key, value) {
|
953
|
+
onSet.forEach((item) => {
|
954
|
+
let keys = [];
|
955
|
+
if (key) {
|
956
|
+
keys = [key];
|
957
|
+
} else {
|
958
|
+
keys = this._map.keys();
|
959
|
+
}
|
960
|
+
keys.filter((k) => {
|
961
|
+
if (item.filter.size === 0) {
|
962
|
+
return true;
|
963
|
+
}
|
964
|
+
if (item.filter.has(k)) {
|
965
|
+
return true;
|
966
|
+
}
|
967
|
+
return false;
|
968
|
+
}).forEach((k) => {
|
969
|
+
let v;
|
970
|
+
if (!key && !value) {
|
971
|
+
v = this._map.get(k);
|
972
|
+
} else if (key && !value) {
|
973
|
+
v = void 0;
|
974
|
+
} else {
|
975
|
+
v = value;
|
976
|
+
}
|
977
|
+
item.fn(k, v);
|
978
|
+
});
|
979
|
+
});
|
980
|
+
}
|
981
|
+
keys() {
|
982
|
+
return this._map.keys();
|
983
|
+
}
|
984
|
+
// filter is not set all sets passed
|
985
|
+
onSet(fn, ...filter) {
|
986
|
+
const item = { filter: new Set(filter), fn };
|
987
|
+
this._onSet.push(item);
|
988
|
+
this._applyOnSet([item]);
|
989
|
+
}
|
990
|
+
get(key) {
|
991
|
+
return this._map.get(key);
|
992
|
+
}
|
993
|
+
set(key, value) {
|
994
|
+
if (!value) {
|
995
|
+
return;
|
996
|
+
}
|
997
|
+
this._map.set(key, value);
|
998
|
+
this._applyOnSet(this._onSet, key, value);
|
999
|
+
}
|
1000
|
+
delete(key) {
|
1001
|
+
this._map.delete(key);
|
1002
|
+
this._applyOnSet(this._onSet, key);
|
1003
|
+
}
|
1004
|
+
};
|
1005
|
+
|
1006
|
+
// src/deno/deno-sys-abstraction.ts
|
1007
|
+
var Deno2 = globalThis.Deno;
|
1008
|
+
var once4 = new ResolveOnce();
|
1009
|
+
var _deno;
|
1010
|
+
var _DenoEnvActions = class _DenoEnvActions {
|
1011
|
+
constructor(opts) {
|
1012
|
+
__privateAdd(this, _deno, globalThis);
|
1013
|
+
this.opts = opts;
|
1014
|
+
}
|
1015
|
+
static new(opts) {
|
1016
|
+
return once4.once(() => new _DenoEnvActions(opts));
|
1017
|
+
}
|
1018
|
+
get _env() {
|
1019
|
+
return __privateGet(this, _deno).Deno.env;
|
1020
|
+
}
|
1021
|
+
register(env) {
|
1022
|
+
for (const key of env.keys()) {
|
1023
|
+
this._env.set(key, env.get(key) || "");
|
1024
|
+
}
|
1025
|
+
return env;
|
1026
|
+
}
|
1027
|
+
active() {
|
1028
|
+
return runtimeFn().isDeno;
|
1029
|
+
}
|
1030
|
+
keys() {
|
1031
|
+
return Object.keys(this._env.toObject());
|
1032
|
+
}
|
1033
|
+
get(key) {
|
1034
|
+
return this._env.get(key);
|
1035
|
+
}
|
1036
|
+
set(key, value) {
|
1037
|
+
if (value) {
|
1038
|
+
this._env.set(key, value);
|
1039
|
+
}
|
1040
|
+
}
|
1041
|
+
delete(key) {
|
1042
|
+
this._env.delete(key);
|
1043
|
+
}
|
1044
|
+
};
|
1045
|
+
_deno = new WeakMap();
|
1046
|
+
var DenoEnvActions = _DenoEnvActions;
|
1047
|
+
var DenoExitServiceImpl = class {
|
1048
|
+
constructor() {
|
1049
|
+
this._exitHandlers = [];
|
1050
|
+
this.invoked = false;
|
1051
|
+
this._handleExit = async () => {
|
1052
|
+
if (this.invoked) {
|
1053
|
+
return;
|
1054
|
+
}
|
1055
|
+
this.invoked = true;
|
1056
|
+
for (const h of this._exitHandlers) {
|
1057
|
+
try {
|
1058
|
+
const ret = h.hdl();
|
1059
|
+
if (typeof ret.then === "function") {
|
1060
|
+
await ret;
|
1061
|
+
}
|
1062
|
+
} finally {
|
1063
|
+
}
|
1064
|
+
}
|
1065
|
+
};
|
1066
|
+
globalThis.addEventListener("unhandledrejection", (e) => {
|
1067
|
+
e.preventDefault();
|
1068
|
+
this.exit(19);
|
1069
|
+
});
|
1070
|
+
globalThis.addEventListener("error", () => {
|
1071
|
+
this.exit(19);
|
1072
|
+
});
|
1073
|
+
globalThis.addEventListener("uncaughtException", () => {
|
1074
|
+
this.exit(19);
|
1075
|
+
});
|
1076
|
+
globalThis.addEventListener("unload", () => {
|
1077
|
+
this.exit(0);
|
1078
|
+
});
|
1079
|
+
Deno2.addSignalListener("SIGQUIT", () => {
|
1080
|
+
this.exit(3);
|
1081
|
+
});
|
1082
|
+
Deno2.addSignalListener("SIGINT", () => {
|
1083
|
+
this.exit(2);
|
1084
|
+
});
|
1085
|
+
Deno2.addSignalListener("SIGTERM", () => {
|
1086
|
+
this.exit(9);
|
1087
|
+
});
|
1088
|
+
}
|
1089
|
+
injectExitHandlers(hdls) {
|
1090
|
+
this._exitHandlers = hdls;
|
1091
|
+
}
|
1092
|
+
exit(code) {
|
1093
|
+
this._handleExit().then(() => {
|
1094
|
+
Deno2.exit(code);
|
1095
|
+
}).catch((err) => {
|
1096
|
+
console.error("ExitService: failed to handle exit", err);
|
1097
|
+
Deno2.exit(code);
|
1098
|
+
});
|
1099
|
+
}
|
1100
|
+
};
|
1101
|
+
var _DenoSystemService = class _DenoSystemService {
|
1102
|
+
constructor() {
|
1103
|
+
this._exitService = new DenoExitServiceImpl();
|
1104
|
+
this._exitService.injectExitHandlers(_DenoSystemService._exitHandlers);
|
1105
|
+
}
|
1106
|
+
Env() {
|
1107
|
+
return envFactory();
|
1108
|
+
}
|
1109
|
+
Args() {
|
1110
|
+
return Deno2.args;
|
1111
|
+
}
|
1112
|
+
OnExit(hdl) {
|
1113
|
+
const id = crypto.randomUUID();
|
1114
|
+
_DenoSystemService._exitHandlers.push({ hdl, id });
|
1115
|
+
return () => {
|
1116
|
+
const idx = _DenoSystemService._exitHandlers.findIndex((h) => h.id === id);
|
1117
|
+
if (idx >= 0) {
|
1118
|
+
_DenoSystemService._exitHandlers.splice(idx, 1);
|
1119
|
+
}
|
1120
|
+
};
|
1121
|
+
}
|
1122
|
+
Exit(code) {
|
1123
|
+
this._exitService.exit(code);
|
1124
|
+
}
|
1125
|
+
};
|
1126
|
+
_DenoSystemService._exitHandlers = [];
|
1127
|
+
var DenoSystemService = _DenoSystemService;
|
1128
|
+
var my4 = void 0;
|
1129
|
+
function DenoSysAbstraction(param) {
|
1130
|
+
if (!my4) {
|
1131
|
+
my4 = new BaseSysAbstraction({
|
1132
|
+
TxtEnDecoder: (param == null ? void 0 : param.TxtEnDecoder) || Utf8EnDecoderSingleton(),
|
1133
|
+
FileSystem: new DenoFileService(),
|
1134
|
+
SystemService: new DenoSystemService()
|
1135
|
+
});
|
1136
|
+
}
|
1137
|
+
return new WrapperSysAbstraction(my4, param);
|
1138
|
+
}
|
1139
|
+
|
1140
|
+
export {
|
1141
|
+
TimeMode,
|
1142
|
+
RandomMode,
|
1143
|
+
IDMode,
|
1144
|
+
String2TimeMode,
|
1145
|
+
Time,
|
1146
|
+
TimeUnits,
|
1147
|
+
SysTime,
|
1148
|
+
ConstTime,
|
1149
|
+
StepTime,
|
1150
|
+
TimeFactory,
|
1151
|
+
RandomService,
|
1152
|
+
IdService,
|
1153
|
+
BaseSysAbstraction,
|
1154
|
+
WrapperSysAbstraction,
|
1155
|
+
Future,
|
1156
|
+
ResolveSeq,
|
1157
|
+
ResolveOnce,
|
1158
|
+
Keyed,
|
1159
|
+
KeyedResolvOnce,
|
1160
|
+
KeyedResolvSeq,
|
1161
|
+
runtimeFn,
|
1162
|
+
DenoFileService,
|
1163
|
+
DenoEnvActions,
|
1164
|
+
DenoExitServiceImpl,
|
1165
|
+
DenoSystemService,
|
1166
|
+
DenoSysAbstraction,
|
1167
|
+
NodeFileService,
|
1168
|
+
NodeEnvActions,
|
1169
|
+
NodeExitServiceImpl,
|
1170
|
+
NodeSystemService,
|
1171
|
+
NodeSysAbstraction,
|
1172
|
+
CFEnvActions,
|
1173
|
+
CFSystemService,
|
1174
|
+
CFSysAbstraction,
|
1175
|
+
registerEnvAction,
|
1176
|
+
envFactory,
|
1177
|
+
EnvImpl2 as EnvImpl,
|
1178
|
+
BrowserEnvActions,
|
1179
|
+
WebFileService,
|
1180
|
+
WebSysAbstraction
|
1181
|
+
};
|
1182
|
+
//# sourceMappingURL=chunk-DZPKZQIT.js.map
|