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