@adviser/cement 0.3.19 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/base-sys-abstraction-DgTynXGV.d.cts +95 -0
- package/base-sys-abstraction-h0dB3nZ5.d.ts +95 -0
- package/cf/index.cjs +232 -283
- package/cf/index.cjs.map +1 -1
- package/cf/index.d.cts +10 -8
- package/cf/index.d.ts +10 -8
- package/cf/index.js +6 -41
- package/cf/index.js.map +1 -1
- package/{chunk-GDTTUMIL.js → chunk-6F3ACVHD.js} +62 -22
- package/chunk-6F3ACVHD.js.map +1 -0
- package/{chunk-PHS255C5.js → chunk-FOALXQST.js} +1 -68
- package/chunk-FOALXQST.js.map +1 -0
- package/{chunk-23MCJYE6.js → chunk-X3IV2RYT.js} +422 -602
- package/chunk-X3IV2RYT.js.map +1 -0
- package/chunk-YKGCONBX.js +677 -0
- package/chunk-YKGCONBX.js.map +1 -0
- package/{chunk-55W4AK2Z.js → chunk-YVACAIUX.js} +5 -5
- package/deno/index.cjs +257 -241
- package/deno/index.cjs.map +1 -1
- package/deno/index.d.cts +3 -5
- package/deno/index.d.ts +3 -5
- package/deno/index.js +14 -16
- package/deno/index.js.map +1 -1
- package/{index-D1j1fPYg.d.ts → index-N0bkrgSt.d.ts} +15 -3
- package/{index-Cp1NspHH.d.cts → index-TtYD7HhB.d.cts} +15 -3
- package/index.cjs +1851 -1709
- package/index.cjs.map +1 -1
- package/index.d.cts +9 -8
- package/index.d.ts +9 -8
- package/index.js +21 -16
- package/index.js.map +1 -1
- package/metafile-cjs.json +1 -1
- package/metafile-esm.json +1 -1
- package/node/index.cjs +499 -474
- package/node/index.cjs.map +1 -1
- package/node/index.d.cts +3 -5
- package/node/index.d.ts +3 -5
- package/node/index.js +14 -16
- package/node/index.js.map +1 -1
- package/package.json +6 -6
- package/src/base-sys-abstraction.ts +106 -116
- package/src/cf/cf-basic-sys-abstraction.ts +79 -0
- package/src/cf/index.ts +1 -1
- package/src/cf-test-main.ts +10 -1
- package/src/deno/deno-basic-sys-abstraction.ts +39 -0
- package/src/deno/deno-file-service.ts +1 -1
- package/src/deno/deno-sys-abstraction.ts +19 -22
- package/src/jsr.json +1 -1
- package/src/log-writer-impl.ts +6 -0
- package/src/logger-impl.ts +17 -19
- package/src/node/node-basic-sys-abstraction.ts +59 -0
- package/src/node/node-sys-abstraction.ts +19 -22
- package/src/sys-abstraction.ts +12 -6
- package/src/test/mock-logger.ts +2 -2
- package/src/txt-en-decoder.ts +3 -3
- package/src/uri.ts +71 -0
- package/src/web/index.ts +1 -1
- package/src/web/web-basic-sys-abstraction.ts +105 -0
- package/{sys-abstraction-B0x6IE7r.d.ts → sys-abstraction-CeAxxg9H.d.ts} +11 -7
- package/{sys-abstraction-BTs3Vzy4.d.cts → sys-abstraction-DDAwGTnk.d.cts} +11 -7
- package/test/index.cjs +1534 -1419
- package/test/index.cjs.map +1 -1
- package/test/index.d.cts +2 -2
- package/test/index.d.ts +2 -2
- package/test/index.js +4 -5
- package/ts/smoke/smoke.js +7 -8
- package/ts/smoke/smoke.js.map +1 -1
- package/ts/src/base-basic-sys-abstraction.test.d.ts +2 -0
- package/ts/src/base-basic-sys-abstraction.test.d.ts.map +1 -0
- package/ts/src/{base-sys-abstraction.test.js → base-basic-sys-abstraction.test.js} +9 -9
- package/ts/src/base-basic-sys-abstraction.test.js.map +1 -0
- package/ts/src/base-sys-abstraction.d.ts +33 -21
- package/ts/src/base-sys-abstraction.d.ts.map +1 -1
- package/ts/src/base-sys-abstraction.js +54 -67
- package/ts/src/base-sys-abstraction.js.map +1 -1
- package/ts/src/cf/cf-basic-sys-abstraction.d.ts +14 -0
- package/ts/src/cf/cf-basic-sys-abstraction.d.ts.map +1 -0
- package/ts/src/cf/cf-basic-sys-abstraction.js +67 -0
- package/ts/src/cf/cf-basic-sys-abstraction.js.map +1 -0
- package/ts/src/cf/index.d.ts +1 -1
- package/ts/src/cf/index.d.ts.map +1 -1
- package/ts/src/cf/index.js +1 -1
- package/ts/src/cf/index.js.map +1 -1
- package/ts/src/cf-test-main.d.ts.map +1 -1
- package/ts/src/cf-test-main.js +7 -1
- package/ts/src/cf-test-main.js.map +1 -1
- package/ts/src/deno/deno-basic-sys-abstraction.d.ts +14 -0
- package/ts/src/deno/deno-basic-sys-abstraction.d.ts.map +1 -0
- package/ts/src/deno/deno-basic-sys-abstraction.js +35 -0
- package/ts/src/deno/deno-basic-sys-abstraction.js.map +1 -0
- package/ts/src/deno/deno-file-service.d.ts +1 -1
- package/ts/src/deno/deno-file-service.d.ts.map +1 -1
- package/ts/src/deno/deno-sys-abstraction.d.ts +3 -6
- package/ts/src/deno/deno-sys-abstraction.d.ts.map +1 -1
- package/ts/src/deno/deno-sys-abstraction.js +13 -17
- package/ts/src/deno/deno-sys-abstraction.js.map +1 -1
- package/ts/src/log-writer-impl.d.ts +1 -0
- package/ts/src/log-writer-impl.d.ts.map +1 -1
- package/ts/src/log-writer-impl.js +1 -0
- package/ts/src/log-writer-impl.js.map +1 -1
- package/ts/src/logger-impl.d.ts +3 -3
- package/ts/src/logger-impl.d.ts.map +1 -1
- package/ts/src/logger-impl.js +3 -18
- package/ts/src/logger-impl.js.map +1 -1
- package/ts/src/logger.test.js +3 -4
- package/ts/src/logger.test.js.map +1 -1
- package/ts/src/node/node-basic-sys-abstraction.d.ts +25 -0
- package/ts/src/node/node-basic-sys-abstraction.d.ts.map +1 -0
- package/ts/src/node/node-basic-sys-abstraction.js +44 -0
- package/ts/src/node/node-basic-sys-abstraction.js.map +1 -0
- package/ts/src/node/node-sys-abstraction.d.ts +3 -6
- package/ts/src/node/node-sys-abstraction.d.ts.map +1 -1
- package/ts/src/node/node-sys-abstraction.js +13 -17
- package/ts/src/node/node-sys-abstraction.js.map +1 -1
- package/ts/src/node/node-sys-abstraction.test.js +1 -1
- package/ts/src/node/node-sys-abstraction.test.js.map +1 -1
- package/ts/src/resolve-once.test.js +1 -1
- package/ts/src/sys-abstraction.d.ts +10 -6
- package/ts/src/sys-abstraction.d.ts.map +1 -1
- package/ts/src/test/mock-logger.d.ts +2 -2
- package/ts/src/test/mock-logger.d.ts.map +1 -1
- package/ts/src/test/mock-logger.js.map +1 -1
- package/ts/src/tracer.test.js +5 -8
- package/ts/src/tracer.test.js.map +1 -1
- package/ts/src/txt-en-decoder.d.ts.map +1 -1
- package/ts/src/txt-en-decoder.js +3 -3
- package/ts/src/txt-en-decoder.js.map +1 -1
- package/ts/src/uri.d.ts +12 -0
- package/ts/src/uri.d.ts.map +1 -1
- package/ts/src/uri.js +55 -0
- package/ts/src/uri.js.map +1 -1
- package/ts/src/uri.test.js +48 -0
- package/ts/src/uri.test.js.map +1 -1
- package/ts/src/web/index.d.ts +1 -1
- package/ts/src/web/index.d.ts.map +1 -1
- package/ts/src/web/index.js +1 -1
- package/ts/src/web/index.js.map +1 -1
- package/ts/src/web/web-basic-sys-abstraction.d.ts +4 -0
- package/ts/src/web/web-basic-sys-abstraction.d.ts.map +1 -0
- package/ts/src/web/web-basic-sys-abstraction.js +45 -0
- package/ts/src/web/web-basic-sys-abstraction.js.map +1 -0
- package/ts/vitest.workspace.d.ts +1 -1
- package/utils/index.cjs +132 -3
- package/utils/index.cjs.map +1 -1
- package/utils/index.js +5 -5
- package/web/index.cjs +277 -281
- package/web/index.cjs.map +1 -1
- package/web/index.d.cts +4 -17
- package/web/index.d.ts +4 -17
- package/web/index.js +4 -7
- package/base-sys-abstraction-BnBZ6zd0.d.ts +0 -84
- package/base-sys-abstraction-DAZ8tx5F.d.cts +0 -84
- package/chunk-23MCJYE6.js.map +0 -1
- package/chunk-GDTTUMIL.js.map +0 -1
- package/chunk-H6MLKWIZ.js +0 -88
- package/chunk-H6MLKWIZ.js.map +0 -1
- package/chunk-LXTKPZ6M.js +0 -255
- package/chunk-LXTKPZ6M.js.map +0 -1
- package/chunk-PHS255C5.js.map +0 -1
- package/src/cf/cf-sys-abstraction.ts +0 -34
- package/src/web/web-sys-abstraction.ts +0 -80
- package/ts/src/base-sys-abstraction.test.d.ts +0 -2
- package/ts/src/base-sys-abstraction.test.d.ts.map +0 -1
- package/ts/src/base-sys-abstraction.test.js.map +0 -1
- package/ts/src/cf/cf-sys-abstraction.d.ts +0 -11
- package/ts/src/cf/cf-sys-abstraction.d.ts.map +0 -1
- package/ts/src/cf/cf-sys-abstraction.js +0 -30
- package/ts/src/cf/cf-sys-abstraction.js.map +0 -1
- package/ts/src/web/web-sys-abstraction.d.ts +0 -18
- package/ts/src/web/web-sys-abstraction.d.ts.map +0 -1
- package/ts/src/web/web-sys-abstraction.js +0 -64
- package/ts/src/web/web-sys-abstraction.js.map +0 -1
- /package/{chunk-55W4AK2Z.js.map → chunk-YVACAIUX.js.map} +0 -0
package/index.cjs
CHANGED
@@ -38,7 +38,9 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
38
38
|
// src/index.ts
|
39
39
|
var index_exports = {};
|
40
40
|
__export(index_exports, {
|
41
|
+
BaseBasicSysAbstraction: () => BaseBasicSysAbstraction,
|
41
42
|
BaseSysAbstraction: () => BaseSysAbstraction,
|
43
|
+
BasicSysAbstractionFactory: () => BasicSysAbstractionFactory,
|
42
44
|
BuildURI: () => BuildURI,
|
43
45
|
ConstTime: () => ConstTime,
|
44
46
|
EnvImpl: () => EnvImpl,
|
@@ -87,7 +89,8 @@ __export(index_exports, {
|
|
87
89
|
TxtEnDecoderSingleton: () => TxtEnDecoderSingleton,
|
88
90
|
URI: () => URI,
|
89
91
|
VERSION: () => VERSION,
|
90
|
-
|
92
|
+
WrapperBasicSysAbstraction: () => WrapperBasicSysAbstraction,
|
93
|
+
WrapperRuntimeSysAbstraction: () => WrapperRuntimeSysAbstraction,
|
91
94
|
YAMLFormatter: () => YAMLFormatter,
|
92
95
|
asyncLogValue: () => asyncLogValue,
|
93
96
|
bin2string: () => bin2string,
|
@@ -299,1845 +302,1821 @@ function IsLogger(obj) {
|
|
299
302
|
].map((fn) => typeof obj[fn] === "function").reduce((a, b) => a && b, true);
|
300
303
|
}
|
301
304
|
|
302
|
-
// src/
|
303
|
-
var
|
304
|
-
|
305
|
-
|
306
|
-
STEP: "step"
|
307
|
-
};
|
308
|
-
var RandomMode = {
|
309
|
-
CONST: "const",
|
310
|
-
STEP: "step",
|
311
|
-
RANDOM: "random"
|
312
|
-
};
|
313
|
-
var IDMode = {
|
314
|
-
UUID: "uuid",
|
315
|
-
CONST: "const",
|
316
|
-
STEP: "step"
|
317
|
-
};
|
318
|
-
function String2TimeMode(s) {
|
319
|
-
switch (s == null ? void 0 : s.toLowerCase()) {
|
320
|
-
case "real":
|
321
|
-
return TimeMode.REAL;
|
322
|
-
case "const":
|
323
|
-
return TimeMode.CONST;
|
324
|
-
case "step":
|
325
|
-
return TimeMode.STEP;
|
326
|
-
default:
|
327
|
-
return TimeMode.REAL;
|
305
|
+
// src/result.ts
|
306
|
+
var Result = class _Result {
|
307
|
+
static Ok(t) {
|
308
|
+
return new ResultOK(t);
|
328
309
|
}
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
310
|
+
static Err(t) {
|
311
|
+
if (typeof t === "string") {
|
312
|
+
return new ResultError(new Error(t));
|
313
|
+
}
|
314
|
+
if (_Result.Is(t)) {
|
315
|
+
if (t.is_ok()) {
|
316
|
+
return new ResultError(new Error("Result Error is Ok"));
|
317
|
+
}
|
318
|
+
return t;
|
319
|
+
}
|
320
|
+
return new ResultError(t);
|
336
321
|
}
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
var SysTime = class extends Time {
|
350
|
-
Now() {
|
351
|
-
return /* @__PURE__ */ new Date();
|
322
|
+
static Is(t) {
|
323
|
+
if (!t) {
|
324
|
+
return false;
|
325
|
+
}
|
326
|
+
if (t instanceof _Result) {
|
327
|
+
return true;
|
328
|
+
}
|
329
|
+
const rt = t;
|
330
|
+
if ([typeof rt.is_ok, typeof rt.is_err, typeof rt.unwrap, typeof rt.unwrap_err].every((x) => x === "function")) {
|
331
|
+
return true;
|
332
|
+
}
|
333
|
+
return false;
|
352
334
|
}
|
353
|
-
|
354
|
-
return
|
355
|
-
setTimeout(() => {
|
356
|
-
resolve();
|
357
|
-
}, duration);
|
358
|
-
});
|
335
|
+
isOk() {
|
336
|
+
return this.is_ok();
|
359
337
|
}
|
360
|
-
|
361
|
-
|
362
|
-
Now() {
|
363
|
-
return new Date(2021, 1, 1, 0, 0, 0, 0);
|
338
|
+
isErr() {
|
339
|
+
return this.is_err();
|
364
340
|
}
|
365
|
-
|
366
|
-
|
367
|
-
|
341
|
+
Ok() {
|
342
|
+
return this.unwrap();
|
343
|
+
}
|
344
|
+
Err() {
|
345
|
+
return this.unwrap_err();
|
368
346
|
}
|
369
347
|
};
|
370
|
-
var
|
371
|
-
constructor() {
|
348
|
+
var ResultOK = class extends Result {
|
349
|
+
constructor(t) {
|
372
350
|
super();
|
373
|
-
this.
|
374
|
-
this._start = this._step;
|
351
|
+
this._t = t;
|
375
352
|
}
|
376
|
-
|
377
|
-
|
378
|
-
this._step = new Date(this._step.getTime() + 1e3);
|
379
|
-
}
|
380
|
-
if (steps < 1) {
|
381
|
-
this._step = new Date(this._start.getTime() + steps * -1e3);
|
382
|
-
}
|
383
|
-
return this._step;
|
353
|
+
is_ok() {
|
354
|
+
return true;
|
384
355
|
}
|
385
|
-
|
386
|
-
|
387
|
-
|
356
|
+
is_err() {
|
357
|
+
return false;
|
358
|
+
}
|
359
|
+
unwrap_err() {
|
360
|
+
throw new Error("Result is Ok");
|
361
|
+
}
|
362
|
+
unwrap() {
|
363
|
+
return this._t;
|
388
364
|
}
|
389
365
|
};
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
case TimeMode.CONST:
|
395
|
-
return new ConstTime();
|
396
|
-
case TimeMode.STEP:
|
397
|
-
return new StepTime();
|
366
|
+
var ResultError = class extends Result {
|
367
|
+
constructor(t) {
|
368
|
+
super();
|
369
|
+
this._error = t;
|
398
370
|
}
|
399
|
-
|
400
|
-
|
401
|
-
var RandomService = class {
|
402
|
-
constructor(mode) {
|
403
|
-
this._step = 0;
|
404
|
-
this._mode = mode;
|
371
|
+
is_ok() {
|
372
|
+
return false;
|
405
373
|
}
|
406
|
-
|
407
|
-
|
408
|
-
case RandomMode.CONST:
|
409
|
-
return 0.5 * value;
|
410
|
-
case RandomMode.STEP:
|
411
|
-
this._step += 1e-4;
|
412
|
-
return this._step * value;
|
413
|
-
case RandomMode.RANDOM:
|
414
|
-
return Math.random() * value;
|
415
|
-
default:
|
416
|
-
throw new Error("Unknown RandomMode");
|
417
|
-
}
|
374
|
+
is_err() {
|
375
|
+
return true;
|
418
376
|
}
|
419
|
-
|
420
|
-
|
421
|
-
constructor(mode) {
|
422
|
-
this._step = 0;
|
423
|
-
if (!mode) {
|
424
|
-
mode = IDMode.UUID;
|
425
|
-
}
|
426
|
-
this._mode = mode;
|
377
|
+
unwrap() {
|
378
|
+
throw new Error(`Result is Err: ${this._error}`);
|
427
379
|
}
|
428
|
-
|
429
|
-
|
430
|
-
case IDMode.UUID:
|
431
|
-
return crypto.randomUUID();
|
432
|
-
case IDMode.CONST:
|
433
|
-
return "VeryUniqueID";
|
434
|
-
case IDMode.STEP:
|
435
|
-
return `STEPId-${this._step++}`;
|
436
|
-
default:
|
437
|
-
throw new Error("Unknown IDMode");
|
438
|
-
}
|
380
|
+
unwrap_err() {
|
381
|
+
return this._error;
|
439
382
|
}
|
440
383
|
};
|
441
|
-
function
|
442
|
-
|
443
|
-
|
444
|
-
|
384
|
+
function exception2Result(fn) {
|
385
|
+
try {
|
386
|
+
const res = fn();
|
387
|
+
if (res instanceof Promise) {
|
388
|
+
return res.then((value) => Result.Ok(value)).catch((e) => Result.Err(e));
|
445
389
|
}
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
});
|
451
|
-
}).catch((e) => {
|
452
|
-
console.error("consumeReadableStream:read", e);
|
453
|
-
});
|
454
|
-
}
|
455
|
-
function CFWriteableStream(writeFn) {
|
456
|
-
const ts = new TransformStream();
|
457
|
-
consumeReadableStream(ts.readable.getReader(), writeFn);
|
458
|
-
return ts.writable;
|
390
|
+
return Result.Ok(res);
|
391
|
+
} catch (e) {
|
392
|
+
return Result.Err(e);
|
393
|
+
}
|
459
394
|
}
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
this.
|
465
|
-
this._fileSystem = params.FileSystem;
|
466
|
-
this._systemService = params.SystemService;
|
467
|
-
this._txtEnDe = params.TxtEnDecoder;
|
468
|
-
const decoder = this._txtEnDe;
|
469
|
-
this._stdout = CFWriteableStream((chunk) => {
|
470
|
-
const decoded = decoder.decode(chunk);
|
471
|
-
console.log(decoded.trimEnd());
|
472
|
-
return Promise.resolve();
|
473
|
-
});
|
474
|
-
this._stderr = CFWriteableStream((chunk) => {
|
475
|
-
const decoded = decoder.decode(chunk);
|
476
|
-
console.error(decoded.trimEnd());
|
477
|
-
return Promise.resolve();
|
478
|
-
});
|
395
|
+
|
396
|
+
// src/types.ts
|
397
|
+
var _Required = class {
|
398
|
+
constructor() {
|
399
|
+
this.type = "REQUIRED";
|
479
400
|
}
|
480
401
|
};
|
481
|
-
var
|
482
|
-
constructor(
|
483
|
-
this.
|
484
|
-
this._stdout = base._stdout;
|
485
|
-
this._stderr = base._stderr;
|
486
|
-
this._idService = base._idService;
|
487
|
-
this._randomService = base._randomService;
|
488
|
-
this._fileSystem = base._fileSystem;
|
489
|
-
this._systemService = base._systemService;
|
490
|
-
if (params) {
|
491
|
-
if (params.TimeMode) {
|
492
|
-
this._time = TimeFactory(params.TimeMode);
|
493
|
-
}
|
494
|
-
if (params.Stdout) {
|
495
|
-
this._stdout = params.Stdout;
|
496
|
-
}
|
497
|
-
if (params.Stderr) {
|
498
|
-
this._stderr = params.Stderr;
|
499
|
-
}
|
500
|
-
if (params.IdMode) {
|
501
|
-
this._idService = new IdService(params.IdMode);
|
502
|
-
}
|
503
|
-
if (params.RandomMode) {
|
504
|
-
this._randomService = new RandomService(params.RandomMode);
|
505
|
-
}
|
506
|
-
if (params.FileSystem) {
|
507
|
-
this._fileSystem = params.FileSystem;
|
508
|
-
}
|
509
|
-
if (params.SystemService) {
|
510
|
-
this._systemService = params.SystemService;
|
511
|
-
}
|
512
|
-
}
|
513
|
-
}
|
514
|
-
Time() {
|
515
|
-
return this._time;
|
516
|
-
}
|
517
|
-
NextId() {
|
518
|
-
return this._idService.NextId();
|
519
|
-
}
|
520
|
-
Random0ToValue(value) {
|
521
|
-
return this._randomService.Random0ToValue(value);
|
522
|
-
}
|
523
|
-
Stdout() {
|
524
|
-
return this._stdout;
|
525
|
-
}
|
526
|
-
Stderr() {
|
527
|
-
return this._stderr;
|
528
|
-
}
|
529
|
-
System() {
|
530
|
-
return this._systemService;
|
531
|
-
}
|
532
|
-
FileSystem() {
|
533
|
-
return this._fileSystem;
|
402
|
+
var _Optional = class {
|
403
|
+
constructor() {
|
404
|
+
this.type = "OPTIONAL";
|
534
405
|
}
|
535
406
|
};
|
407
|
+
var param = {
|
408
|
+
REQUIRED: new _Required(),
|
409
|
+
OPTIONAL: new _Optional()
|
410
|
+
};
|
536
411
|
|
537
|
-
// src/
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
412
|
+
// src/utils/get-params-result.ts
|
413
|
+
function getParamsResult(keys, getParam) {
|
414
|
+
const keyDef = keys.flat().reduce(
|
415
|
+
(acc, i) => {
|
416
|
+
if (typeof i === "string") {
|
417
|
+
acc.push({ key: i, def: void 0, isOptional: false });
|
418
|
+
} else if (typeof i === "object") {
|
419
|
+
acc.push(
|
420
|
+
...Object.keys(i).map((k) => ({
|
421
|
+
key: k,
|
422
|
+
def: typeof i[k] === "string" ? i[k] : void 0,
|
423
|
+
isOptional: i[k] === param.OPTIONAL
|
424
|
+
}))
|
425
|
+
);
|
426
|
+
}
|
427
|
+
return acc;
|
428
|
+
},
|
429
|
+
[]
|
430
|
+
);
|
431
|
+
const msgFn = keys.find((k) => typeof k === "function") || ((...keys2) => {
|
432
|
+
const msg = keys2.join(",");
|
433
|
+
return `missing parameters: ${msg}`;
|
434
|
+
});
|
435
|
+
const errors = [];
|
436
|
+
const result = {};
|
437
|
+
for (const kd of keyDef) {
|
438
|
+
const val = getParam.getParam(kd.key);
|
439
|
+
if (val === void 0) {
|
440
|
+
if (typeof kd.def === "string") {
|
441
|
+
result[kd.key] = kd.def;
|
442
|
+
} else {
|
443
|
+
if (!kd.isOptional) {
|
444
|
+
errors.push(kd.key);
|
445
|
+
}
|
446
|
+
}
|
447
|
+
} else {
|
448
|
+
result[kd.key] = val;
|
449
|
+
}
|
558
450
|
}
|
559
|
-
|
560
|
-
|
451
|
+
if (errors.length) {
|
452
|
+
return Result.Err(msgFn(...errors));
|
561
453
|
}
|
562
|
-
|
563
|
-
|
564
|
-
_resolveFn = new WeakMap();
|
565
|
-
_rejectFn = new WeakMap();
|
454
|
+
return Result.Ok(result);
|
455
|
+
}
|
566
456
|
|
567
|
-
// src/
|
568
|
-
var
|
569
|
-
|
570
|
-
|
457
|
+
// src/utils/relative-path.ts
|
458
|
+
var PartType = {
|
459
|
+
Slash: 1,
|
460
|
+
Root: 3,
|
461
|
+
Up: 4,
|
462
|
+
Noop: 8
|
463
|
+
// RootUp = 0x8 /* ../ */,
|
464
|
+
};
|
465
|
+
var Path = class {
|
466
|
+
constructor(parts = []) {
|
467
|
+
this.parts = parts;
|
571
468
|
}
|
572
|
-
|
573
|
-
this.
|
469
|
+
toString() {
|
470
|
+
return this.parts.map((part) => {
|
471
|
+
if (typeof part === "string") {
|
472
|
+
return part;
|
473
|
+
} else {
|
474
|
+
switch (part) {
|
475
|
+
case PartType.Slash:
|
476
|
+
case PartType.Root:
|
477
|
+
return "/";
|
478
|
+
case PartType.Up:
|
479
|
+
return "..";
|
480
|
+
default:
|
481
|
+
return part;
|
482
|
+
}
|
483
|
+
}
|
484
|
+
}).join("");
|
574
485
|
}
|
575
|
-
|
576
|
-
|
486
|
+
add(part) {
|
487
|
+
if (this.parts.includes(PartType.Root) && part === PartType.Root) {
|
488
|
+
throw new Error("Cannot add absolute part to absolute path");
|
489
|
+
}
|
490
|
+
const last = this.parts[this.parts.length - 1];
|
491
|
+
if (last & PartType.Slash && part === PartType.Slash) {
|
492
|
+
return;
|
493
|
+
}
|
494
|
+
switch (part) {
|
495
|
+
case ".":
|
496
|
+
this.parts.push(PartType.Noop);
|
497
|
+
return;
|
498
|
+
case "..":
|
499
|
+
part = PartType.Up;
|
500
|
+
}
|
501
|
+
if (last === PartType.Noop && part === PartType.Slash) {
|
502
|
+
if (last === PartType.Noop) {
|
503
|
+
this.parts.pop();
|
504
|
+
}
|
505
|
+
return;
|
506
|
+
}
|
507
|
+
this.parts.push(part);
|
577
508
|
}
|
578
|
-
|
579
|
-
|
509
|
+
};
|
510
|
+
function splitPath(path) {
|
511
|
+
const p = new Path();
|
512
|
+
if (path === "") {
|
513
|
+
return p;
|
580
514
|
}
|
581
|
-
|
582
|
-
|
515
|
+
for (let count = 0; path.length; count++) {
|
516
|
+
if (path.match(/^\/+/)) {
|
517
|
+
if (count === 0) {
|
518
|
+
p.add(PartType.Root);
|
519
|
+
} else {
|
520
|
+
p.add(PartType.Slash);
|
521
|
+
}
|
522
|
+
path = path.replace(/^\/+/, "");
|
523
|
+
} else {
|
524
|
+
const part = path.replace(/\/.*$/, "");
|
525
|
+
p.add(part);
|
526
|
+
path = path.replace(/^[^/]+/, "");
|
527
|
+
}
|
583
528
|
}
|
584
|
-
|
585
|
-
|
529
|
+
return p;
|
530
|
+
}
|
531
|
+
function pathJoin(...paths) {
|
532
|
+
let prev = "";
|
533
|
+
const res = [];
|
534
|
+
for (let i = 0; i < paths.length; i++) {
|
535
|
+
const path = paths[i];
|
536
|
+
if (path === "") {
|
537
|
+
continue;
|
538
|
+
}
|
539
|
+
if (!(prev.endsWith("/") || path.startsWith("/"))) {
|
540
|
+
if (prev !== "") {
|
541
|
+
res.push("/");
|
542
|
+
}
|
543
|
+
res.push(path);
|
544
|
+
} else {
|
545
|
+
res.push(path);
|
546
|
+
}
|
547
|
+
prev = path;
|
586
548
|
}
|
587
|
-
|
588
|
-
|
549
|
+
return res.join("");
|
550
|
+
}
|
551
|
+
function relativePath(path, relative) {
|
552
|
+
const relativeParts = splitPath(relative);
|
553
|
+
let result;
|
554
|
+
if (relativeParts.parts[0] === PartType.Root) {
|
555
|
+
result = relative;
|
556
|
+
} else {
|
557
|
+
result = pathJoin(path, relative);
|
589
558
|
}
|
590
|
-
|
591
|
-
|
559
|
+
const unoptPath = splitPath(result);
|
560
|
+
const out = [];
|
561
|
+
let topUp = false;
|
562
|
+
for (const part of unoptPath.parts) {
|
563
|
+
switch (part) {
|
564
|
+
case PartType.Root:
|
565
|
+
out.push(PartType.Root);
|
566
|
+
break;
|
567
|
+
case PartType.Up:
|
568
|
+
if (out.length && !topUp) {
|
569
|
+
const last = out.length - 1;
|
570
|
+
if (typeof out[last] === "string" && out[last - 1] == PartType.Root) {
|
571
|
+
out.pop();
|
572
|
+
} else {
|
573
|
+
out.pop();
|
574
|
+
out.pop();
|
575
|
+
}
|
576
|
+
if (out.length === 0) {
|
577
|
+
topUp = !topUp ? true : topUp;
|
578
|
+
out.push(PartType.Up);
|
579
|
+
}
|
580
|
+
} else {
|
581
|
+
out.push(PartType.Up);
|
582
|
+
}
|
583
|
+
break;
|
584
|
+
case PartType.Slash:
|
585
|
+
if (!(out[out.length - 1] & PartType.Slash)) {
|
586
|
+
out.push(PartType.Slash);
|
587
|
+
}
|
588
|
+
break;
|
589
|
+
default:
|
590
|
+
out.push(part);
|
591
|
+
break;
|
592
|
+
}
|
592
593
|
}
|
593
|
-
|
594
|
-
|
594
|
+
return new Path(out).toString();
|
595
|
+
}
|
596
|
+
|
597
|
+
// src/utils/stripper.ts
|
598
|
+
function stripper(strip, obj) {
|
599
|
+
const strips = Array.isArray(strip) ? strip : [strip];
|
600
|
+
const restrips = strips.map((s) => {
|
601
|
+
if (typeof s === "string") {
|
602
|
+
const escaped = s.replace(/[-\\[\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\^\\$\\|]/g, "\\$&");
|
603
|
+
return new RegExp(`^${escaped}$`);
|
604
|
+
}
|
605
|
+
return s;
|
606
|
+
});
|
607
|
+
return localStripper(void 0, restrips, obj);
|
608
|
+
}
|
609
|
+
function localStripper(path, restrips, obj) {
|
610
|
+
if (typeof obj !== "object" || obj === null) {
|
611
|
+
return obj;
|
595
612
|
}
|
596
|
-
|
597
|
-
|
598
|
-
constructor(c = {}) {
|
599
|
-
this._map = /* @__PURE__ */ new Map();
|
600
|
-
this.param = {
|
601
|
-
maxEntries: c.maxEntries || 100,
|
602
|
-
maxAge: c.maxAge || 0
|
603
|
-
};
|
613
|
+
if (Array.isArray(obj)) {
|
614
|
+
return obj.map((i) => localStripper(path, restrips, i));
|
604
615
|
}
|
605
|
-
|
606
|
-
|
607
|
-
|
616
|
+
const ret = { ...obj };
|
617
|
+
const matcher = (key, nextPath) => {
|
618
|
+
for (const re of restrips) {
|
619
|
+
if (re.test(key) || re.test(nextPath)) {
|
620
|
+
return true;
|
621
|
+
}
|
608
622
|
}
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
623
|
+
return false;
|
624
|
+
};
|
625
|
+
for (const key in ret) {
|
626
|
+
if (Object.prototype.hasOwnProperty.call(ret, key)) {
|
627
|
+
let nextPath;
|
628
|
+
if (path) {
|
629
|
+
nextPath = [path, key].join(".");
|
630
|
+
} else {
|
631
|
+
nextPath = key;
|
632
|
+
}
|
633
|
+
if (matcher(key, nextPath)) {
|
634
|
+
delete ret[key];
|
635
|
+
continue;
|
636
|
+
}
|
637
|
+
if (typeof ret[key] === "object") {
|
638
|
+
if (Array.isArray(ret[key])) {
|
639
|
+
ret[key] = ret[key].reduce((acc, v, i) => {
|
640
|
+
const toDelete = matcher(key, `${nextPath}[${i}]`);
|
641
|
+
if (!toDelete) {
|
642
|
+
acc.push(localStripper(`${nextPath}[${i}]`, restrips, v));
|
643
|
+
}
|
644
|
+
return acc;
|
645
|
+
}, []);
|
646
|
+
} else {
|
647
|
+
ret[key] = localStripper(nextPath, restrips, ret[key]);
|
630
648
|
}
|
631
649
|
}
|
632
650
|
}
|
633
651
|
}
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
652
|
+
return ret;
|
653
|
+
}
|
654
|
+
|
655
|
+
// src/uri.ts
|
656
|
+
function match(iref, ioth) {
|
657
|
+
const mr = {
|
658
|
+
score: 0,
|
659
|
+
protocol: false,
|
660
|
+
hostname: false,
|
661
|
+
port: false,
|
662
|
+
pathname: false,
|
663
|
+
pathParts: [],
|
664
|
+
params: {}
|
665
|
+
};
|
666
|
+
const ref = URI.from(iref);
|
667
|
+
const oth = URI.from(ioth);
|
668
|
+
if (ref.protocol === oth.protocol) {
|
669
|
+
mr.score += 1;
|
670
|
+
mr.protocol = true;
|
639
671
|
}
|
640
|
-
|
641
|
-
const
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
672
|
+
try {
|
673
|
+
const refH = ref.hostname;
|
674
|
+
const refP = ref.port;
|
675
|
+
if (refH === oth.hostname) {
|
676
|
+
mr.score += 1;
|
677
|
+
mr.hostname = true;
|
678
|
+
}
|
679
|
+
if (refP.length && refP === oth.port) {
|
680
|
+
mr.score += 1;
|
681
|
+
mr.port = true;
|
648
682
|
}
|
683
|
+
} catch (e) {
|
649
684
|
}
|
650
|
-
|
651
|
-
|
652
|
-
|
685
|
+
if (ref.pathname.length && ref.pathname !== "/") {
|
686
|
+
const pref = ref.pathname.split("/").filter((p) => p.length);
|
687
|
+
const poth = oth.pathname.split("/").filter((p) => p.length);
|
688
|
+
for (let i = 0; i < pref.length && i < poth.length; i++) {
|
689
|
+
if (poth[i] === pref[i]) {
|
690
|
+
mr.score += 1;
|
691
|
+
mr.pathname = true;
|
692
|
+
mr.pathParts.push(pref[i]);
|
693
|
+
}
|
653
694
|
}
|
654
|
-
return this._map.get(key);
|
655
695
|
}
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
this._map.set(key, value);
|
661
|
-
} else {
|
662
|
-
this._map.set(key, value);
|
696
|
+
for (const [key, value] of ref.getParams) {
|
697
|
+
if (oth.getParam(key) === value) {
|
698
|
+
mr.score += 1;
|
699
|
+
mr.params[key] = value;
|
663
700
|
}
|
664
701
|
}
|
665
|
-
|
666
|
-
|
702
|
+
return mr;
|
703
|
+
}
|
704
|
+
function coerceKey(key, def) {
|
705
|
+
if (typeof key === "object") {
|
706
|
+
const keys = Object.keys(key);
|
707
|
+
if (keys.length !== 1) {
|
708
|
+
throw new Error(`Invalid key: ${JSON.stringify(key)}`);
|
709
|
+
}
|
710
|
+
return { key: keys[0], def: key[keys[0]] };
|
667
711
|
}
|
668
|
-
|
669
|
-
|
712
|
+
return { key, def };
|
713
|
+
}
|
714
|
+
function falsy2undef(value) {
|
715
|
+
return value === void 0 || value === null ? void 0 : value;
|
716
|
+
}
|
717
|
+
function ensureURLWithDefaultProto(url, defaultProtocol) {
|
718
|
+
if (!url) {
|
719
|
+
return new MutableURL(`${defaultProtocol}//`);
|
670
720
|
}
|
671
|
-
|
672
|
-
|
721
|
+
if (typeof url === "string") {
|
722
|
+
try {
|
723
|
+
return new MutableURL(url);
|
724
|
+
} catch (e) {
|
725
|
+
return new MutableURL(`${defaultProtocol}//${url}`);
|
726
|
+
}
|
727
|
+
} else {
|
728
|
+
return new MutableURL(url.toString());
|
673
729
|
}
|
674
|
-
|
675
|
-
|
730
|
+
}
|
731
|
+
function isURL(value) {
|
732
|
+
return value instanceof URL || !!value && typeof value.searchParams === "object" && typeof value.searchParams.sort === "function" && typeof value.hash === "string";
|
733
|
+
}
|
734
|
+
var MutableURL = class _MutableURL extends URL {
|
735
|
+
constructor(urlStr) {
|
736
|
+
super("defect://does.not.exist");
|
737
|
+
const partedURL = urlStr.split(":");
|
738
|
+
this._hasHostpart = hasHostPartProtocols.has(partedURL[0]);
|
739
|
+
let hostPartUrl = ["http", ...partedURL.slice(1)].join(":");
|
740
|
+
if (!this._hasHostpart) {
|
741
|
+
const pathname = hostPartUrl.replace(/http:\/\/[/]*/, "").replace(/[#?].*$/, "");
|
742
|
+
hostPartUrl = hostPartUrl.replace(/http:\/\//, `http://localhost/${pathname}`);
|
743
|
+
}
|
744
|
+
try {
|
745
|
+
this._sysURL = new URL(hostPartUrl);
|
746
|
+
} catch (ie) {
|
747
|
+
const e = ie;
|
748
|
+
e.message = `${e.message} for URL: ${urlStr}`;
|
749
|
+
throw e;
|
750
|
+
}
|
751
|
+
this._protocol = `${partedURL[0]}:`;
|
752
|
+
if (this._hasHostpart) {
|
753
|
+
this._pathname = this._sysURL.pathname;
|
754
|
+
} else {
|
755
|
+
this._pathname = urlStr.replace(new RegExp(`^${this._protocol}//`), "").replace(/[#?].*$/, "");
|
756
|
+
}
|
757
|
+
this.hash = this._sysURL.hash;
|
676
758
|
}
|
677
|
-
|
678
|
-
|
679
|
-
// yield x;
|
680
|
-
// }
|
681
|
-
// }
|
682
|
-
// getLeastRecent(): K {
|
683
|
-
// return Array.from(this.cache)[0];
|
684
|
-
// }
|
685
|
-
// getMostRecent(): K {
|
686
|
-
// return Array.from(this.cache)[this.cache.size - 1];
|
687
|
-
// }
|
688
|
-
};
|
689
|
-
|
690
|
-
// src/result.ts
|
691
|
-
var Result = class _Result {
|
692
|
-
static Ok(t) {
|
693
|
-
return new ResultOK(t);
|
759
|
+
clone() {
|
760
|
+
return new _MutableURL(this.toString());
|
694
761
|
}
|
695
|
-
|
696
|
-
if (
|
697
|
-
|
762
|
+
get host() {
|
763
|
+
if (!this._hasHostpart) {
|
764
|
+
throw new Error(
|
765
|
+
`you can use hostname only if protocol is ${this.toString()} ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`
|
766
|
+
);
|
698
767
|
}
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
768
|
+
return this._sysURL.host;
|
769
|
+
}
|
770
|
+
get port() {
|
771
|
+
if (!this._hasHostpart) {
|
772
|
+
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);
|
704
773
|
}
|
705
|
-
return
|
774
|
+
return this._sysURL.port;
|
706
775
|
}
|
707
|
-
|
708
|
-
if (!
|
709
|
-
|
776
|
+
set port(p) {
|
777
|
+
if (!this._hasHostpart) {
|
778
|
+
throw new Error(`you can use port only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);
|
710
779
|
}
|
711
|
-
|
712
|
-
|
780
|
+
this._sysURL.port = p;
|
781
|
+
}
|
782
|
+
get hostname() {
|
783
|
+
if (!this._hasHostpart) {
|
784
|
+
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);
|
713
785
|
}
|
714
|
-
|
715
|
-
|
716
|
-
|
786
|
+
return this._sysURL.hostname;
|
787
|
+
}
|
788
|
+
set hostname(h) {
|
789
|
+
if (!this._hasHostpart) {
|
790
|
+
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);
|
717
791
|
}
|
718
|
-
|
792
|
+
this._sysURL.hostname = h;
|
719
793
|
}
|
720
|
-
|
721
|
-
|
794
|
+
set pathname(p) {
|
795
|
+
this._pathname = p;
|
722
796
|
}
|
723
|
-
|
724
|
-
return this.
|
797
|
+
get pathname() {
|
798
|
+
return this._pathname;
|
725
799
|
}
|
726
|
-
|
727
|
-
return this.
|
800
|
+
get protocol() {
|
801
|
+
return this._protocol;
|
728
802
|
}
|
729
|
-
|
730
|
-
|
803
|
+
set protocol(p) {
|
804
|
+
if (!p.endsWith(":")) {
|
805
|
+
p = `${p}:`;
|
806
|
+
}
|
807
|
+
this._protocol = p;
|
808
|
+
}
|
809
|
+
get searchParams() {
|
810
|
+
return this._sysURL.searchParams;
|
811
|
+
}
|
812
|
+
toString() {
|
813
|
+
let search = "";
|
814
|
+
if (this._sysURL.searchParams.size) {
|
815
|
+
for (const [key, value] of Array.from(this._sysURL.searchParams.entries()).sort((a, b) => a[0].localeCompare(b[0]))) {
|
816
|
+
search += `${!search.length ? "?" : "&"}${key}=${encodeURIComponent(value)}`;
|
817
|
+
}
|
818
|
+
}
|
819
|
+
let hostpart = "";
|
820
|
+
if (this._hasHostpart) {
|
821
|
+
hostpart = this._sysURL.hostname;
|
822
|
+
if (this._sysURL.port) {
|
823
|
+
hostpart += `:${this._sysURL.port}`;
|
824
|
+
}
|
825
|
+
if (!this._pathname.startsWith("/")) {
|
826
|
+
hostpart += "/";
|
827
|
+
}
|
828
|
+
}
|
829
|
+
return `${this._protocol}//${hostpart}${this._pathname}${search}`;
|
731
830
|
}
|
732
831
|
};
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
832
|
+
function from(fac, strURLUri, defaultProtocol) {
|
833
|
+
switch (typeof falsy2undef(strURLUri)) {
|
834
|
+
case "undefined":
|
835
|
+
return fac(new MutableURL(`${defaultProtocol}///`));
|
836
|
+
case "string":
|
837
|
+
return fac(ensureURLWithDefaultProto(strURLUri, defaultProtocol));
|
838
|
+
case "object":
|
839
|
+
if (BuildURI.is(strURLUri)) {
|
840
|
+
return fac(new MutableURL(strURLUri._url.toString()));
|
841
|
+
} else if (URI.is(strURLUri)) {
|
842
|
+
return fac(new MutableURL(strURLUri._url.toString()));
|
843
|
+
} else if (isURL(strURLUri)) {
|
844
|
+
return fac(new MutableURL(strURLUri.toString()));
|
845
|
+
}
|
846
|
+
throw new Error(`unknown object type: ${strURLUri}`);
|
847
|
+
default:
|
848
|
+
throw new Error(`Invalid argument: ${typeof strURLUri}`);
|
743
849
|
}
|
744
|
-
|
745
|
-
|
850
|
+
}
|
851
|
+
function getParamResult(key, val, msgFn = (key2) => {
|
852
|
+
return `missing parameter: ${key2}`;
|
853
|
+
}) {
|
854
|
+
if (val === void 0) {
|
855
|
+
return Result.Err(msgFn(key));
|
746
856
|
}
|
747
|
-
|
748
|
-
|
857
|
+
return Result.Ok(val);
|
858
|
+
}
|
859
|
+
var BuildURI = class _BuildURI {
|
860
|
+
// pathname needs this
|
861
|
+
constructor(url) {
|
862
|
+
this._url = url;
|
749
863
|
}
|
750
|
-
|
751
|
-
|
752
|
-
constructor(t) {
|
753
|
-
super();
|
754
|
-
this._error = t;
|
864
|
+
static is(value) {
|
865
|
+
return value instanceof _BuildURI || !!value && typeof value.delParam === "function" && typeof value.setParam === "function";
|
755
866
|
}
|
756
|
-
|
757
|
-
return
|
867
|
+
static from(strURLUri, defaultProtocol = "file:") {
|
868
|
+
return from((url) => new _BuildURI(url), strURLUri, defaultProtocol);
|
758
869
|
}
|
759
|
-
|
760
|
-
return
|
870
|
+
match(other) {
|
871
|
+
return match(this.URI(), URI.from(other));
|
761
872
|
}
|
762
|
-
|
763
|
-
|
873
|
+
port(p) {
|
874
|
+
this._url.port = p;
|
875
|
+
return this;
|
764
876
|
}
|
765
|
-
|
766
|
-
|
877
|
+
hostname(h) {
|
878
|
+
this._url.hostname = h;
|
879
|
+
return this;
|
767
880
|
}
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
const res = fn();
|
772
|
-
if (res instanceof Promise) {
|
773
|
-
return res.then((value) => Result.Ok(value)).catch((e) => Result.Err(e));
|
881
|
+
protocol(p) {
|
882
|
+
if (!p.endsWith(":")) {
|
883
|
+
p = `${p}:`;
|
774
884
|
}
|
775
|
-
|
776
|
-
|
777
|
-
return Result.Err(e);
|
885
|
+
this._url.protocol = p;
|
886
|
+
return this;
|
778
887
|
}
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
var ResolveSeq = class {
|
783
|
-
constructor(ctx) {
|
784
|
-
this._flushWaiting = [];
|
785
|
-
this._seqFutures = [];
|
786
|
-
this.ctx = ctx;
|
888
|
+
pathname(p) {
|
889
|
+
this._url.pathname = p;
|
890
|
+
return this;
|
787
891
|
}
|
788
|
-
|
892
|
+
// could pass a relative path or a full URL
|
893
|
+
// if relative path, it will be appended to the current path
|
894
|
+
resolve(p) {
|
895
|
+
if (!p) {
|
896
|
+
return this;
|
897
|
+
}
|
898
|
+
if (typeof p === "string") {
|
899
|
+
if (!p.match(/^[a-zA-Z0-9]+:/)) {
|
900
|
+
if (p.startsWith("/")) {
|
901
|
+
this.pathname(p);
|
902
|
+
return this;
|
903
|
+
}
|
904
|
+
return this.appendRelative(p);
|
905
|
+
}
|
906
|
+
}
|
907
|
+
this._url = new MutableURL(p.toString());
|
908
|
+
return this;
|
789
909
|
}
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
910
|
+
appendRelative(p) {
|
911
|
+
const appendUrl = URI.from(p);
|
912
|
+
const pathname = "./" + appendUrl.pathname;
|
913
|
+
const basePath = this._url.pathname;
|
914
|
+
this.pathname(relativePath(basePath, pathname));
|
915
|
+
for (const [key, value] of appendUrl.getParams) {
|
916
|
+
this.setParam(key, value);
|
796
917
|
}
|
797
|
-
return
|
918
|
+
return this;
|
798
919
|
}
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
this._flushWaiting.forEach((f) => f.resolve());
|
803
|
-
(_a = this._flushWaiting) == null ? void 0 : _a.splice(0, this._flushWaiting.length);
|
804
|
-
return Promise.resolve();
|
920
|
+
cleanParams() {
|
921
|
+
for (const key of Array.from(this._url.searchParams.keys())) {
|
922
|
+
this._url.searchParams.delete(key);
|
805
923
|
}
|
806
|
-
|
807
|
-
this._seqFutures.shift();
|
808
|
-
void this._step(this._seqFutures[0]);
|
809
|
-
});
|
810
|
-
return Promise.resolve();
|
924
|
+
return this;
|
811
925
|
}
|
812
|
-
|
813
|
-
|
814
|
-
this
|
815
|
-
|
816
|
-
|
926
|
+
delParam(key) {
|
927
|
+
this._url.searchParams.delete(key);
|
928
|
+
return this;
|
929
|
+
}
|
930
|
+
defParam(key, str) {
|
931
|
+
if (!this._url.searchParams.has(key)) {
|
932
|
+
this._url.searchParams.set(key, str);
|
817
933
|
}
|
818
|
-
return
|
934
|
+
return this;
|
819
935
|
}
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
this._onceDone = false;
|
824
|
-
this._onceFutures = [];
|
825
|
-
this._onceOk = false;
|
826
|
-
this._isPromise = false;
|
827
|
-
this.ctx = ctx;
|
936
|
+
setParam(key, str) {
|
937
|
+
this._url.searchParams.set(key, str);
|
938
|
+
return this;
|
828
939
|
}
|
829
|
-
|
830
|
-
return this.
|
940
|
+
hasParam(key) {
|
941
|
+
return this._url.searchParams.has(key);
|
831
942
|
}
|
832
|
-
|
833
|
-
this.
|
834
|
-
this._onceOk = false;
|
835
|
-
this._onceValue = void 0;
|
836
|
-
this._onceError = void 0;
|
837
|
-
if (this._inProgress) {
|
838
|
-
const idx = this._onceFutures.findIndex((f) => f === this._inProgress);
|
839
|
-
if (idx >= 0) {
|
840
|
-
this._onceFutures.push(...this._onceFutures.splice(2).slice(1));
|
841
|
-
}
|
842
|
-
} else {
|
843
|
-
this._onceFutures.length = 0;
|
844
|
-
}
|
943
|
+
get getParams() {
|
944
|
+
return this._url.searchParams.entries();
|
845
945
|
}
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
return Promise.reject(this._onceError);
|
852
|
-
} else {
|
853
|
-
throw this._onceError;
|
854
|
-
}
|
855
|
-
}
|
856
|
-
if (this._onceOk) {
|
857
|
-
if (this._isPromise) {
|
858
|
-
return Promise.resolve(this._onceValue);
|
859
|
-
} else {
|
860
|
-
return this._onceValue;
|
861
|
-
}
|
862
|
-
}
|
863
|
-
throw new Error("ResolveOnce.once impossible");
|
864
|
-
}
|
865
|
-
const future = new Future();
|
866
|
-
this._onceFutures.push(future);
|
867
|
-
if (this._onceFutures.length === 1) {
|
868
|
-
const okFn = (value) => {
|
869
|
-
this._onceValue = value;
|
870
|
-
this._onceOk = true;
|
871
|
-
this._onceDone = true;
|
872
|
-
if (this._isPromise) {
|
873
|
-
this._onceFutures.forEach((f) => f.resolve(this._onceValue));
|
874
|
-
}
|
875
|
-
this._onceFutures.length = 0;
|
876
|
-
};
|
877
|
-
const catchFn = (e) => {
|
878
|
-
this._onceError = e;
|
879
|
-
this._onceOk = false;
|
880
|
-
this._onceValue = void 0;
|
881
|
-
this._onceDone = true;
|
882
|
-
if (this._isPromise) {
|
883
|
-
this._onceFutures.forEach((f) => f.reject(this._onceError));
|
884
|
-
}
|
885
|
-
this._onceFutures.length = 0;
|
886
|
-
};
|
887
|
-
this._inProgress = future;
|
888
|
-
try {
|
889
|
-
const ret = fn(this.ctx);
|
890
|
-
if (typeof ret.then === "function") {
|
891
|
-
this._isPromise = true;
|
892
|
-
ret.then(okFn).catch(catchFn).finally(() => {
|
893
|
-
this._inProgress = void 0;
|
894
|
-
});
|
895
|
-
} else {
|
896
|
-
okFn(ret);
|
897
|
-
}
|
898
|
-
} catch (e) {
|
899
|
-
catchFn(e);
|
900
|
-
}
|
901
|
-
if (!this._isPromise) {
|
902
|
-
this._inProgress = void 0;
|
903
|
-
}
|
904
|
-
}
|
905
|
-
if (this._isPromise) {
|
906
|
-
return future.asPromise();
|
907
|
-
} else {
|
908
|
-
return this.once(fn);
|
946
|
+
getParam(key, def) {
|
947
|
+
const { key: k, def: d } = coerceKey(key, def);
|
948
|
+
let val = this._url.searchParams.get(k);
|
949
|
+
if (!falsy2undef(val) && d) {
|
950
|
+
val = d;
|
909
951
|
}
|
952
|
+
return falsy2undef(val);
|
910
953
|
}
|
911
|
-
|
912
|
-
|
913
|
-
constructor(factory, params) {
|
914
|
-
var _a;
|
915
|
-
this.factory = factory;
|
916
|
-
this._map = new LRUMap((_a = params == null ? void 0 : params.lru) != null ? _a : { maxEntries: -1 });
|
954
|
+
getParamResult(key, msgFn) {
|
955
|
+
return getParamResult(key, this.getParam(key), msgFn);
|
917
956
|
}
|
918
|
-
|
919
|
-
this
|
957
|
+
getParamsResult(...keys) {
|
958
|
+
return getParamsResult(keys, this);
|
920
959
|
}
|
921
|
-
|
922
|
-
|
960
|
+
toString() {
|
961
|
+
this._url.searchParams.sort();
|
962
|
+
return this._url.toString();
|
923
963
|
}
|
924
|
-
|
925
|
-
|
926
|
-
key = key();
|
927
|
-
}
|
928
|
-
let keyed = this._map.get(key);
|
929
|
-
if (!keyed) {
|
930
|
-
keyed = this.factory(key);
|
931
|
-
this._map.set(key, keyed);
|
932
|
-
}
|
933
|
-
return keyed;
|
964
|
+
toJSON() {
|
965
|
+
return this.toString();
|
934
966
|
}
|
935
|
-
|
936
|
-
|
937
|
-
keyed == null ? void 0 : keyed.reset();
|
938
|
-
this._map.delete(key);
|
967
|
+
asURL() {
|
968
|
+
return this.URI().asURL();
|
939
969
|
}
|
940
|
-
|
941
|
-
this.
|
942
|
-
this._map.clear();
|
970
|
+
asObj(...strips) {
|
971
|
+
return this.URI().asObj(...strips);
|
943
972
|
}
|
944
|
-
|
945
|
-
|
946
|
-
constructor(kp = {}) {
|
947
|
-
super((key) => new ResolveOnce(key), kp);
|
973
|
+
clone() {
|
974
|
+
return _BuildURI.from(this.toString());
|
948
975
|
}
|
949
|
-
|
950
|
-
|
951
|
-
* @returns The values of the resolved keys
|
952
|
-
*/
|
953
|
-
values() {
|
954
|
-
return Array.from(this._map.entries()).filter(([_, v]) => v._onceDone).map(([k, v]) => {
|
955
|
-
if (v._onceDone) {
|
956
|
-
if (v._onceError) {
|
957
|
-
return {
|
958
|
-
key: k,
|
959
|
-
value: Result.Err(v._onceError)
|
960
|
-
};
|
961
|
-
}
|
962
|
-
return {
|
963
|
-
key: k,
|
964
|
-
value: Result.Ok(v._onceValue)
|
965
|
-
};
|
966
|
-
}
|
967
|
-
throw new Error("KeyedResolvOnce.values impossible");
|
968
|
-
});
|
976
|
+
URI() {
|
977
|
+
return URI.from(this._url);
|
969
978
|
}
|
970
979
|
};
|
971
|
-
|
972
|
-
|
973
|
-
|
980
|
+
function isCoerceURI(value) {
|
981
|
+
if (!value) {
|
982
|
+
return false;
|
974
983
|
}
|
975
|
-
|
976
|
-
|
977
|
-
// src/runtime.ts
|
978
|
-
function isSet(value, ref = globalThis) {
|
979
|
-
const [head, ...tail] = value.split(".");
|
980
|
-
if (["object", "function"].includes(typeof ref) && ref && ["object", "function"].includes(typeof ref[head]) && ref[head]) {
|
981
|
-
if (tail.length <= 1) {
|
982
|
-
return true;
|
983
|
-
}
|
984
|
-
return isSet(tail.join("."), ref[head]);
|
984
|
+
if (isURL(value)) {
|
985
|
+
return true;
|
985
986
|
}
|
986
|
-
|
987
|
-
|
988
|
-
function runtimeFn() {
|
989
|
-
const gt = globalThis;
|
990
|
-
let isReactNative = (
|
991
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
992
|
-
isSet("navigator.product") && typeof gt["navigator"] === "object" && gt["navigator"]["product"] === "ReactNative"
|
993
|
-
);
|
994
|
-
let isNodeIsh = false;
|
995
|
-
if (!isSet("Deno")) {
|
996
|
-
isNodeIsh = isSet("process.versions.node") && !isReactNative;
|
987
|
+
if (URI.is(value)) {
|
988
|
+
return true;
|
997
989
|
}
|
998
|
-
|
999
|
-
|
1000
|
-
if (isCFWorker) {
|
1001
|
-
isDeno = false;
|
1002
|
-
isNodeIsh = false;
|
1003
|
-
isReactNative = false;
|
990
|
+
if (BuildURI.is(value)) {
|
991
|
+
return true;
|
1004
992
|
}
|
1005
|
-
|
1006
|
-
|
1007
|
-
isBrowser: !(isNodeIsh || isDeno || isCFWorker || isReactNative),
|
1008
|
-
isDeno,
|
1009
|
-
isReactNative,
|
1010
|
-
isCFWorker
|
1011
|
-
};
|
1012
|
-
}
|
1013
|
-
|
1014
|
-
// src/deno/deno-env-actions.ts
|
1015
|
-
var once = new ResolveOnce();
|
1016
|
-
var _deno;
|
1017
|
-
var _DenoEnvActions = class _DenoEnvActions {
|
1018
|
-
constructor(opts) {
|
1019
|
-
__privateAdd(this, _deno, globalThis);
|
1020
|
-
this.opts = opts;
|
993
|
+
if (typeof value === "string") {
|
994
|
+
return true;
|
1021
995
|
}
|
1022
|
-
|
1023
|
-
|
996
|
+
return false;
|
997
|
+
}
|
998
|
+
var hasHostPartProtocols = /* @__PURE__ */ new Set(["http", "https", "ws", "wss"]);
|
999
|
+
var URI = class _URI {
|
1000
|
+
static protocolHasHostpart(protocol) {
|
1001
|
+
protocol = protocol.replace(/:$/, "");
|
1002
|
+
hasHostPartProtocols.add(protocol);
|
1003
|
+
return () => {
|
1004
|
+
hasHostPartProtocols.delete(protocol);
|
1005
|
+
};
|
1024
1006
|
}
|
1025
|
-
|
1026
|
-
return
|
1007
|
+
match(other) {
|
1008
|
+
return match(this, other);
|
1027
1009
|
}
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1010
|
+
// if no protocol is provided, default to file:
|
1011
|
+
static merge(into, from2, defaultProtocol = "file:") {
|
1012
|
+
const intoUrl = BuildURI.from(into, defaultProtocol);
|
1013
|
+
const fromUrl = _URI.from(from2, defaultProtocol);
|
1014
|
+
intoUrl.protocol(fromUrl.protocol);
|
1015
|
+
const fPath = fromUrl.pathname;
|
1016
|
+
if (!(fPath.length === 0 || fPath === "/" || fPath === "./")) {
|
1017
|
+
intoUrl.pathname(fromUrl.pathname);
|
1031
1018
|
}
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
return
|
1019
|
+
for (const [key, value] of fromUrl.getParams) {
|
1020
|
+
intoUrl.setParam(key, value);
|
1021
|
+
}
|
1022
|
+
return intoUrl.URI();
|
1036
1023
|
}
|
1037
|
-
|
1038
|
-
return
|
1024
|
+
static is(value) {
|
1025
|
+
return value instanceof _URI || !!value && typeof value.asURL === "function" && typeof value.getParam === "function" && typeof value.hasParam === "function";
|
1039
1026
|
}
|
1040
|
-
|
1041
|
-
|
1027
|
+
// if no protocol is provided, default to file:
|
1028
|
+
static from(strURLUri, defaultProtocol = "file:") {
|
1029
|
+
return from((url) => new _URI(url), strURLUri, defaultProtocol);
|
1042
1030
|
}
|
1043
|
-
|
1044
|
-
|
1045
|
-
this._env.set(key, value);
|
1046
|
-
}
|
1031
|
+
static fromResult(strURLUri, defaultProtocol = "file:") {
|
1032
|
+
return exception2Result(() => from((url) => new _URI(url), strURLUri, defaultProtocol));
|
1047
1033
|
}
|
1048
|
-
|
1049
|
-
this.
|
1034
|
+
constructor(url) {
|
1035
|
+
this._url = url.clone();
|
1050
1036
|
}
|
1051
|
-
|
1052
|
-
|
1053
|
-
var DenoEnvActions = _DenoEnvActions;
|
1054
|
-
|
1055
|
-
// src/node/node-env-actions.ts
|
1056
|
-
var once2 = new ResolveOnce();
|
1057
|
-
var _node;
|
1058
|
-
var _NodeEnvActions = class _NodeEnvActions {
|
1059
|
-
constructor(opts) {
|
1060
|
-
__privateAdd(this, _node, globalThis);
|
1061
|
-
this._env = this.active() ? __privateGet(this, _node).process.env : {};
|
1062
|
-
this.opts = opts;
|
1037
|
+
build() {
|
1038
|
+
return BuildURI.from(this._url);
|
1063
1039
|
}
|
1064
|
-
|
1065
|
-
return
|
1040
|
+
get hostname() {
|
1041
|
+
return this._url.hostname;
|
1066
1042
|
}
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
return
|
1043
|
+
// get password(): string {
|
1044
|
+
// return this._url.password;
|
1045
|
+
// }
|
1046
|
+
get port() {
|
1047
|
+
return this._url.port;
|
1072
1048
|
}
|
1073
|
-
|
1074
|
-
return
|
1049
|
+
get host() {
|
1050
|
+
return this._url.host;
|
1075
1051
|
}
|
1076
|
-
|
1077
|
-
|
1052
|
+
// get username(): string {
|
1053
|
+
// return this._url.username;
|
1054
|
+
// }
|
1055
|
+
// get search(): string {
|
1056
|
+
// return this._url.search;
|
1057
|
+
// }
|
1058
|
+
get protocol() {
|
1059
|
+
return this._url.protocol;
|
1078
1060
|
}
|
1079
|
-
get(
|
1080
|
-
return this.
|
1061
|
+
get pathname() {
|
1062
|
+
return this._url.pathname;
|
1081
1063
|
}
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1064
|
+
// get hash(): string {
|
1065
|
+
// return this._url.hash;
|
1066
|
+
// }
|
1067
|
+
// get host(): string {
|
1068
|
+
// return this._url.host;
|
1069
|
+
// }
|
1070
|
+
get getParams() {
|
1071
|
+
return this._url.searchParams.entries();
|
1086
1072
|
}
|
1087
|
-
|
1088
|
-
|
1073
|
+
hasParam(key) {
|
1074
|
+
return this._url.searchParams.has(key);
|
1089
1075
|
}
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
constructor(opts) {
|
1098
|
-
this.env = /* @__PURE__ */ new Map();
|
1099
|
-
this.opts = opts;
|
1076
|
+
getParam(key, def) {
|
1077
|
+
const { key: k, def: d } = coerceKey(key, def);
|
1078
|
+
let val = this._url.searchParams.get(k);
|
1079
|
+
if (!falsy2undef(val) && d) {
|
1080
|
+
val = d;
|
1081
|
+
}
|
1082
|
+
return falsy2undef(val);
|
1100
1083
|
}
|
1101
|
-
|
1102
|
-
return
|
1084
|
+
getParamResult(key, msgFn) {
|
1085
|
+
return getParamResult(key, this.getParam(key), msgFn);
|
1103
1086
|
}
|
1104
|
-
|
1105
|
-
return this
|
1087
|
+
getParamsResult(...keys) {
|
1088
|
+
return getParamsResult(keys, this);
|
1106
1089
|
}
|
1107
|
-
|
1108
|
-
|
1109
|
-
this.env.set(key, value);
|
1110
|
-
}
|
1090
|
+
clone() {
|
1091
|
+
return new _URI(this._url);
|
1111
1092
|
}
|
1112
|
-
|
1113
|
-
this.
|
1093
|
+
asURL() {
|
1094
|
+
return this._url.clone();
|
1114
1095
|
}
|
1115
|
-
|
1116
|
-
return
|
1096
|
+
toString() {
|
1097
|
+
return this._url.toString();
|
1117
1098
|
}
|
1118
|
-
|
1119
|
-
return
|
1099
|
+
toJSON() {
|
1100
|
+
return this.toString();
|
1120
1101
|
}
|
1121
|
-
|
1122
|
-
const
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1102
|
+
asObj(...strips) {
|
1103
|
+
const pathURI = {
|
1104
|
+
style: "path",
|
1105
|
+
protocol: this.protocol,
|
1106
|
+
pathname: this.pathname,
|
1107
|
+
searchParams: Object.fromEntries(this.getParams)
|
1108
|
+
};
|
1109
|
+
if (hasHostPartProtocols.has(this.protocol.replace(/:$/, ""))) {
|
1110
|
+
return stripper(strips, {
|
1111
|
+
...pathURI,
|
1112
|
+
style: "host",
|
1113
|
+
hostname: this.hostname,
|
1114
|
+
port: this.port
|
1115
|
+
});
|
1116
|
+
}
|
1117
|
+
return stripper(strips, pathURI);
|
1126
1118
|
}
|
1127
1119
|
};
|
1128
1120
|
|
1129
|
-
// src/
|
1130
|
-
var
|
1131
|
-
|
1132
|
-
|
1133
|
-
this.
|
1134
|
-
this.
|
1135
|
-
|
1136
|
-
|
1137
|
-
return once4.once(() => new _CFEnvActions(opts));
|
1121
|
+
// src/log-writer-impl.ts
|
1122
|
+
var LogWriterStream = class {
|
1123
|
+
constructor(out) {
|
1124
|
+
this._toFlush = [];
|
1125
|
+
this._flushIsRunning = false;
|
1126
|
+
this._flushDoneFns = [];
|
1127
|
+
this._out = out;
|
1128
|
+
this._id = Math.random();
|
1138
1129
|
}
|
1139
|
-
|
1140
|
-
const
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
}
|
1130
|
+
write(encoded) {
|
1131
|
+
const my = async () => {
|
1132
|
+
try {
|
1133
|
+
const writer = this._out.getWriter();
|
1134
|
+
await writer.ready;
|
1135
|
+
await writer.write(encoded);
|
1136
|
+
writer.releaseLock();
|
1137
|
+
} catch (err) {
|
1138
|
+
console.error("Chunk error:", err);
|
1149
1139
|
}
|
1150
|
-
}
|
1151
|
-
|
1152
|
-
|
1153
|
-
return runtimeFn().isCFWorker;
|
1140
|
+
};
|
1141
|
+
this._toFlush.push(my);
|
1142
|
+
this._flush();
|
1154
1143
|
}
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
env.set(key, this.injectOnRegister[key]);
|
1144
|
+
_flush(toFlush = void 0, done) {
|
1145
|
+
if (done) {
|
1146
|
+
this._flushDoneFns.push(done);
|
1159
1147
|
}
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
set(key, value) {
|
1166
|
-
if (value) {
|
1167
|
-
this.cfEnv.set(key, value);
|
1148
|
+
if (this._toFlush.length == 0) {
|
1149
|
+
this._flushIsRunning = false;
|
1150
|
+
this._flushDoneFns.forEach((fn) => fn());
|
1151
|
+
this._flushDoneFns = [];
|
1152
|
+
return;
|
1168
1153
|
}
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1154
|
+
if (!toFlush && this._toFlush.length == 1 && !this._flushIsRunning) {
|
1155
|
+
this._flushIsRunning = true;
|
1156
|
+
} else if (!toFlush) {
|
1157
|
+
return;
|
1158
|
+
}
|
1159
|
+
const my = this._toFlush.shift();
|
1160
|
+
my == null ? void 0 : my().catch((e) => {
|
1161
|
+
console.error("Flush error:", e);
|
1162
|
+
}).finally(() => {
|
1163
|
+
this._flush(this._toFlush);
|
1164
|
+
});
|
1175
1165
|
}
|
1176
1166
|
};
|
1177
1167
|
|
1178
|
-
// src/
|
1179
|
-
var
|
1168
|
+
// src/future.ts
|
1169
|
+
var _promise, _resolveFn, _rejectFn;
|
1170
|
+
var Future = class {
|
1180
1171
|
constructor() {
|
1181
|
-
this
|
1172
|
+
__privateAdd(this, _promise);
|
1173
|
+
__privateAdd(this, _resolveFn, () => {
|
1174
|
+
throw new Error("This Promise is not working as expected.");
|
1175
|
+
});
|
1176
|
+
__privateAdd(this, _rejectFn, () => {
|
1177
|
+
throw new Error("This Promise is not working as expected.");
|
1178
|
+
});
|
1179
|
+
__privateSet(this, _promise, new Promise((resolve, reject) => {
|
1180
|
+
__privateSet(this, _resolveFn, resolve);
|
1181
|
+
__privateSet(this, _rejectFn, reject);
|
1182
|
+
}));
|
1182
1183
|
}
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1184
|
+
async asPromise() {
|
1185
|
+
return __privateGet(this, _promise);
|
1186
|
+
}
|
1187
|
+
resolve(value) {
|
1188
|
+
__privateGet(this, _resolveFn).call(this, value);
|
1189
|
+
}
|
1190
|
+
reject(reason) {
|
1191
|
+
__privateGet(this, _rejectFn).call(this, reason);
|
1187
1192
|
}
|
1188
1193
|
};
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
};
|
1194
|
+
_promise = new WeakMap();
|
1195
|
+
_resolveFn = new WeakMap();
|
1196
|
+
_rejectFn = new WeakMap();
|
1193
1197
|
|
1194
|
-
// src/
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
if (typeof i === "string") {
|
1199
|
-
acc.push({ key: i, def: void 0, isOptional: false });
|
1200
|
-
} else if (typeof i === "object") {
|
1201
|
-
acc.push(
|
1202
|
-
...Object.keys(i).map((k) => ({
|
1203
|
-
key: k,
|
1204
|
-
def: typeof i[k] === "string" ? i[k] : void 0,
|
1205
|
-
isOptional: i[k] === param.OPTIONAL
|
1206
|
-
}))
|
1207
|
-
);
|
1208
|
-
}
|
1209
|
-
return acc;
|
1210
|
-
},
|
1211
|
-
[]
|
1212
|
-
);
|
1213
|
-
const msgFn = keys.find((k) => typeof k === "function") || ((...keys2) => {
|
1214
|
-
const msg = keys2.join(",");
|
1215
|
-
return `missing parameters: ${msg}`;
|
1216
|
-
});
|
1217
|
-
const errors = [];
|
1218
|
-
const result = {};
|
1219
|
-
for (const kd of keyDef) {
|
1220
|
-
const val = getParam.getParam(kd.key);
|
1221
|
-
if (val === void 0) {
|
1222
|
-
if (typeof kd.def === "string") {
|
1223
|
-
result[kd.key] = kd.def;
|
1224
|
-
} else {
|
1225
|
-
if (!kd.isOptional) {
|
1226
|
-
errors.push(kd.key);
|
1227
|
-
}
|
1228
|
-
}
|
1229
|
-
} else {
|
1230
|
-
result[kd.key] = val;
|
1231
|
-
}
|
1198
|
+
// src/lru-map-set.ts
|
1199
|
+
var LRUSet = class {
|
1200
|
+
constructor(param2 = {}) {
|
1201
|
+
this._lruMap = new LRUMap(param2);
|
1232
1202
|
}
|
1233
|
-
|
1234
|
-
|
1203
|
+
setParam(param2 = {}) {
|
1204
|
+
this._lruMap.setParam(param2);
|
1235
1205
|
}
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
// src/sys-env.ts
|
1240
|
-
var envActions = [
|
1241
|
-
{ id: "cf", fn: (opts) => CFEnvActions.new(opts) },
|
1242
|
-
{ id: "node", fn: (opts) => NodeEnvActions.new(opts) },
|
1243
|
-
{ id: "deno", fn: (opts) => DenoEnvActions.new(opts) },
|
1244
|
-
{ id: "browser", fn: (opts) => BrowserEnvActions.new(opts) }
|
1245
|
-
];
|
1246
|
-
function registerEnvAction(fn) {
|
1247
|
-
const id = `id-${Math.random()}`;
|
1248
|
-
envActions.unshift({ id, fn });
|
1249
|
-
_envFactories.unget(id);
|
1250
|
-
return () => {
|
1251
|
-
const index = envActions.findIndex((i) => i.id === id);
|
1252
|
-
if (index >= 0) {
|
1253
|
-
envActions.splice(index, 1);
|
1254
|
-
}
|
1255
|
-
};
|
1256
|
-
}
|
1257
|
-
var _envFactories = new KeyedResolvOnce();
|
1258
|
-
function envFactory(opts = {}) {
|
1259
|
-
const found = envActions.find((fi) => fi.fn(opts).active());
|
1260
|
-
if (!found) {
|
1261
|
-
throw new Error("SysContainer:envFactory: no env available");
|
1206
|
+
get size() {
|
1207
|
+
return this._lruMap.size;
|
1262
1208
|
}
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
}
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1209
|
+
has(key) {
|
1210
|
+
return this._lruMap.has(key);
|
1211
|
+
}
|
1212
|
+
add(key) {
|
1213
|
+
this._lruMap.set(key, key);
|
1214
|
+
}
|
1215
|
+
delete(key) {
|
1216
|
+
this._lruMap.delete(key);
|
1217
|
+
}
|
1218
|
+
clear() {
|
1219
|
+
this._lruMap.clear();
|
1273
1220
|
}
|
1274
|
-
|
1275
|
-
|
1276
|
-
var EnvImpl = class {
|
1277
|
-
constructor(map, opts = {}) {
|
1278
|
-
this._onSet = [];
|
1279
|
-
this._map = map;
|
1280
|
-
this._updatePresets(opts.presetEnv);
|
1221
|
+
forEach(callbackfn) {
|
1222
|
+
this._lruMap.forEach((value) => callbackfn(value, value));
|
1281
1223
|
}
|
1282
|
-
|
1283
|
-
return
|
1284
|
-
getParam: (k) => this.get(k)
|
1285
|
-
});
|
1224
|
+
entries() {
|
1225
|
+
return this._lruMap.entries();
|
1286
1226
|
}
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
|
1227
|
+
};
|
1228
|
+
var LRUMap = class {
|
1229
|
+
constructor(c = {}) {
|
1230
|
+
this._map = /* @__PURE__ */ new Map();
|
1231
|
+
this.param = {
|
1232
|
+
maxEntries: c.maxEntries || 100,
|
1233
|
+
maxAge: c.maxAge || 0
|
1234
|
+
};
|
1235
|
+
}
|
1236
|
+
touch(key) {
|
1237
|
+
if (!this._map.has(key)) {
|
1238
|
+
throw new Error(`key not found in cache: ${key}`);
|
1239
|
+
}
|
1240
|
+
const value = this._map.get(key);
|
1241
|
+
this._map.delete(key);
|
1242
|
+
this._map.set(key, value);
|
1243
|
+
return value;
|
1244
|
+
}
|
1245
|
+
setParam(param2 = {}) {
|
1246
|
+
if (typeof param2.maxEntries === "number") {
|
1247
|
+
this.param.maxEntries = param2.maxEntries;
|
1248
|
+
if (param2.maxEntries > 0 && this._map.size > param2.maxEntries) {
|
1249
|
+
const toDelete = [];
|
1250
|
+
let cacheSize = this._map.size;
|
1251
|
+
for (const key of this._map.keys()) {
|
1252
|
+
if (cacheSize > param2.maxEntries) {
|
1253
|
+
toDelete.push(key);
|
1254
|
+
cacheSize--;
|
1255
|
+
} else {
|
1256
|
+
break;
|
1305
1257
|
}
|
1306
1258
|
}
|
1307
|
-
|
1308
|
-
|
1309
|
-
for (const [k, v] of key) {
|
1310
|
-
if (typeof k === "string" && typeof v === "string") {
|
1311
|
-
this.set(k, v);
|
1312
|
-
}
|
1313
|
-
}
|
1314
|
-
} else {
|
1315
|
-
const rKey = key;
|
1316
|
-
for (const k in rKey) {
|
1317
|
-
const v = rKey[k];
|
1318
|
-
if (typeof k === "string" && typeof v === "string") {
|
1319
|
-
this.set(k, v);
|
1320
|
-
}
|
1321
|
-
}
|
1259
|
+
for (const key of toDelete) {
|
1260
|
+
this._map.delete(key);
|
1322
1261
|
}
|
1323
1262
|
}
|
1324
|
-
});
|
1325
|
-
}
|
1326
|
-
_updatePresets(presetEnv) {
|
1327
|
-
if (!presetEnv) {
|
1328
|
-
return;
|
1329
|
-
}
|
1330
|
-
for (const [key, value] of presetEnv) {
|
1331
|
-
this._map.set(key, value);
|
1332
1263
|
}
|
1333
1264
|
}
|
1334
|
-
|
1335
|
-
|
1336
|
-
let keys = [];
|
1337
|
-
if (key) {
|
1338
|
-
keys = [key];
|
1339
|
-
} else {
|
1340
|
-
keys = this._map.keys();
|
1341
|
-
}
|
1342
|
-
keys.filter((k) => {
|
1343
|
-
if (item.filter.size === 0) {
|
1344
|
-
return true;
|
1345
|
-
}
|
1346
|
-
if (item.filter.has(k)) {
|
1347
|
-
return true;
|
1348
|
-
}
|
1349
|
-
return false;
|
1350
|
-
}).forEach((k) => {
|
1351
|
-
let v;
|
1352
|
-
if (!key && !value) {
|
1353
|
-
v = this._map.get(k);
|
1354
|
-
} else if (key && !value) {
|
1355
|
-
v = void 0;
|
1356
|
-
} else {
|
1357
|
-
v = value;
|
1358
|
-
}
|
1359
|
-
item.fn(k, v);
|
1360
|
-
});
|
1361
|
-
});
|
1265
|
+
has(key) {
|
1266
|
+
return this._map.has(key);
|
1362
1267
|
}
|
1363
|
-
|
1364
|
-
return this._map.
|
1268
|
+
get size() {
|
1269
|
+
return this._map.size;
|
1365
1270
|
}
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1271
|
+
async getSet(key, createFN) {
|
1272
|
+
const val = this.get(key);
|
1273
|
+
if (val) {
|
1274
|
+
return val;
|
1275
|
+
} else {
|
1276
|
+
const val2 = await createFN(key);
|
1277
|
+
this.set(key, val2);
|
1278
|
+
return val2;
|
1279
|
+
}
|
1371
1280
|
}
|
1372
1281
|
get(key) {
|
1282
|
+
if (this._map.has(key)) {
|
1283
|
+
return this.touch(key);
|
1284
|
+
}
|
1373
1285
|
return this._map.get(key);
|
1374
1286
|
}
|
1375
1287
|
set(key, value) {
|
1376
|
-
|
1377
|
-
|
1288
|
+
this._map.delete(key);
|
1289
|
+
if (this.param.maxEntries > 0 && this._map.size >= this.param.maxEntries) {
|
1290
|
+
this._map.delete(this._map.keys().next().value);
|
1291
|
+
this._map.set(key, value);
|
1292
|
+
} else {
|
1293
|
+
this._map.set(key, value);
|
1378
1294
|
}
|
1379
|
-
this._map.set(key, value);
|
1380
|
-
this._applyOnSet(this._onSet, key, value);
|
1381
1295
|
}
|
1382
1296
|
delete(key) {
|
1383
1297
|
this._map.delete(key);
|
1384
|
-
this._applyOnSet(this._onSet, key);
|
1385
1298
|
}
|
1299
|
+
clear() {
|
1300
|
+
this._map.clear();
|
1301
|
+
}
|
1302
|
+
forEach(callbackfn) {
|
1303
|
+
this._map.forEach(callbackfn);
|
1304
|
+
}
|
1305
|
+
entries() {
|
1306
|
+
return this._map.entries();
|
1307
|
+
}
|
1308
|
+
// *entries(): IterableIterator<[T, K]> {
|
1309
|
+
// for (const x of this._cache.entries()) {
|
1310
|
+
// yield x;
|
1311
|
+
// }
|
1312
|
+
// }
|
1313
|
+
// getLeastRecent(): K {
|
1314
|
+
// return Array.from(this.cache)[0];
|
1315
|
+
// }
|
1316
|
+
// getMostRecent(): K {
|
1317
|
+
// return Array.from(this.cache)[this.cache.size - 1];
|
1318
|
+
// }
|
1386
1319
|
};
|
1387
1320
|
|
1388
|
-
// src/
|
1389
|
-
var
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
if (ArrayBuffer.isView(raw)) {
|
1395
|
-
return Result.Ok(new Uint8Array(raw.buffer, raw.byteOffset, raw.byteLength));
|
1321
|
+
// src/resolve-once.ts
|
1322
|
+
var ResolveSeq = class {
|
1323
|
+
constructor(ctx) {
|
1324
|
+
this._flushWaiting = [];
|
1325
|
+
this._seqFutures = [];
|
1326
|
+
this.ctx = ctx;
|
1396
1327
|
}
|
1397
|
-
|
1398
|
-
return Result.Err("Blob not supported");
|
1328
|
+
reset() {
|
1399
1329
|
}
|
1400
|
-
|
1401
|
-
|
1330
|
+
flush() {
|
1331
|
+
var _a;
|
1332
|
+
if (this._seqFutures.length > 0) {
|
1333
|
+
const waitForFlush = new Future();
|
1334
|
+
(_a = this._flushWaiting) == null ? void 0 : _a.push(waitForFlush);
|
1335
|
+
return waitForFlush.asPromise();
|
1336
|
+
}
|
1337
|
+
return Promise.resolve();
|
1402
1338
|
}
|
1403
|
-
|
1404
|
-
|
1339
|
+
_step(item) {
|
1340
|
+
var _a;
|
1341
|
+
if (!item) {
|
1342
|
+
this._flushWaiting.forEach((f) => f.resolve());
|
1343
|
+
(_a = this._flushWaiting) == null ? void 0 : _a.splice(0, this._flushWaiting.length);
|
1344
|
+
return Promise.resolve();
|
1345
|
+
}
|
1346
|
+
item.fn(this.ctx).then((value) => item.future.resolve(value)).catch((e) => item.future.reject(e)).finally(() => {
|
1347
|
+
this._seqFutures.shift();
|
1348
|
+
void this._step(this._seqFutures[0]);
|
1349
|
+
});
|
1350
|
+
return Promise.resolve();
|
1405
1351
|
}
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1352
|
+
async add(fn, id) {
|
1353
|
+
const future = new Future();
|
1354
|
+
this._seqFutures.push({ future, fn, id });
|
1355
|
+
if (this._seqFutures.length === 1) {
|
1356
|
+
void this._step(this._seqFutures[0]);
|
1409
1357
|
}
|
1410
|
-
return
|
1358
|
+
return future.asPromise();
|
1411
1359
|
}
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1360
|
+
};
|
1361
|
+
var ResolveOnce = class {
|
1362
|
+
constructor(ctx) {
|
1363
|
+
this._onceDone = false;
|
1364
|
+
this._onceFutures = [];
|
1365
|
+
this._onceOk = false;
|
1366
|
+
this._isPromise = false;
|
1367
|
+
this.ctx = ctx;
|
1418
1368
|
}
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
// src/txt-en-decoder.ts
|
1423
|
-
var TxtOps = class {
|
1424
|
-
constructor() {
|
1425
|
-
this.encoder = new TextEncoder();
|
1426
|
-
this.decoder = new TextDecoder();
|
1369
|
+
get ready() {
|
1370
|
+
return this._onceDone;
|
1427
1371
|
}
|
1428
|
-
|
1429
|
-
|
1372
|
+
reset() {
|
1373
|
+
this._onceDone = false;
|
1374
|
+
this._onceOk = false;
|
1375
|
+
this._onceValue = void 0;
|
1376
|
+
this._onceError = void 0;
|
1377
|
+
if (this._inProgress) {
|
1378
|
+
const idx = this._onceFutures.findIndex((f) => f === this._inProgress);
|
1379
|
+
if (idx >= 0) {
|
1380
|
+
this._onceFutures.push(...this._onceFutures.splice(2).slice(1));
|
1381
|
+
}
|
1382
|
+
} else {
|
1383
|
+
this._onceFutures.length = 0;
|
1384
|
+
}
|
1430
1385
|
}
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
1386
|
+
// T extends Option<infer U> ? U : T
|
1387
|
+
once(fn) {
|
1388
|
+
if (this._onceDone) {
|
1389
|
+
if (this._onceError) {
|
1390
|
+
if (this._isPromise) {
|
1391
|
+
return Promise.reject(this._onceError);
|
1392
|
+
} else {
|
1393
|
+
throw this._onceError;
|
1394
|
+
}
|
1435
1395
|
}
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1396
|
+
if (this._onceOk) {
|
1397
|
+
if (this._isPromise) {
|
1398
|
+
return Promise.resolve(this._onceValue);
|
1399
|
+
} else {
|
1400
|
+
return this._onceValue;
|
1401
|
+
}
|
1439
1402
|
}
|
1403
|
+
throw new Error("ResolveOnce.once impossible");
|
1440
1404
|
}
|
1441
|
-
|
1442
|
-
|
1405
|
+
const future = new Future();
|
1406
|
+
this._onceFutures.push(future);
|
1407
|
+
if (this._onceFutures.length === 1) {
|
1408
|
+
const okFn = (value) => {
|
1409
|
+
this._onceValue = value;
|
1410
|
+
this._onceOk = true;
|
1411
|
+
this._onceDone = true;
|
1412
|
+
if (this._isPromise) {
|
1413
|
+
this._onceFutures.forEach((f) => f.resolve(this._onceValue));
|
1414
|
+
}
|
1415
|
+
this._onceFutures.length = 0;
|
1416
|
+
};
|
1417
|
+
const catchFn = (e) => {
|
1418
|
+
this._onceError = e;
|
1419
|
+
this._onceOk = false;
|
1420
|
+
this._onceValue = void 0;
|
1421
|
+
this._onceDone = true;
|
1422
|
+
if (this._isPromise) {
|
1423
|
+
this._onceFutures.forEach((f) => f.reject(this._onceError));
|
1424
|
+
}
|
1425
|
+
this._onceFutures.length = 0;
|
1426
|
+
};
|
1427
|
+
this._inProgress = future;
|
1428
|
+
try {
|
1429
|
+
const ret = fn(this.ctx);
|
1430
|
+
if (typeof ret.then === "function") {
|
1431
|
+
this._isPromise = true;
|
1432
|
+
ret.then(okFn).catch(catchFn).finally(() => {
|
1433
|
+
this._inProgress = void 0;
|
1434
|
+
});
|
1435
|
+
} else {
|
1436
|
+
okFn(ret);
|
1437
|
+
}
|
1438
|
+
} catch (e) {
|
1439
|
+
catchFn(e);
|
1440
|
+
}
|
1441
|
+
if (!this._isPromise) {
|
1442
|
+
this._inProgress = void 0;
|
1443
|
+
}
|
1443
1444
|
}
|
1444
|
-
|
1445
|
-
|
1446
|
-
|
1447
|
-
|
1448
|
-
if (resolved instanceof Blob) {
|
1449
|
-
resolved = await resolved.arrayBuffer();
|
1445
|
+
if (this._isPromise) {
|
1446
|
+
return future.asPromise();
|
1447
|
+
} else {
|
1448
|
+
return this.once(fn);
|
1450
1449
|
}
|
1451
|
-
return this.decode(resolved);
|
1452
1450
|
}
|
1453
1451
|
};
|
1454
|
-
var
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
}
|
1459
|
-
|
1460
|
-
// src/web/web-sys-abstraction.ts
|
1461
|
-
var WebFileService = class {
|
1462
|
-
get baseDir() {
|
1463
|
-
throw new Error("basedir-Method not implemented.");
|
1464
|
-
}
|
1465
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
1466
|
-
create(fname) {
|
1467
|
-
throw new Error("create-Method not implemented.");
|
1468
|
-
}
|
1469
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
1470
|
-
readFileString(fname) {
|
1471
|
-
throw new Error("readFileString-Method not implemented.");
|
1472
|
-
}
|
1473
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
1474
|
-
writeFileString(fname, content) {
|
1475
|
-
throw new Error("writeFileString-Method not implemented.");
|
1476
|
-
}
|
1477
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
1478
|
-
abs(fname) {
|
1479
|
-
throw new Error("abs-Method not implemented.");
|
1480
|
-
}
|
1481
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
1482
|
-
join(...paths) {
|
1483
|
-
throw new Error("join-Method not implemented.");
|
1484
|
-
}
|
1485
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
1486
|
-
relative(from2, to) {
|
1487
|
-
throw new Error("relative-Method not implemented.");
|
1488
|
-
}
|
1489
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
1490
|
-
dirname(fname) {
|
1491
|
-
throw new Error("dirname-Method not implemented.");
|
1492
|
-
}
|
1493
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
1494
|
-
basename(fname) {
|
1495
|
-
throw new Error("basename-Method not implemented.");
|
1496
|
-
}
|
1497
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
1498
|
-
nodeImport(fname) {
|
1499
|
-
throw new Error("nodeImport-Method not implemented.");
|
1500
|
-
}
|
1501
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
1502
|
-
isAbsolute(fname) {
|
1503
|
-
throw new Error("isAbsolute-Method not implemented.");
|
1452
|
+
var Keyed = class {
|
1453
|
+
constructor(factory, params) {
|
1454
|
+
var _a;
|
1455
|
+
this.factory = factory;
|
1456
|
+
this._map = new LRUMap((_a = params == null ? void 0 : params.lru) != null ? _a : { maxEntries: -1 });
|
1504
1457
|
}
|
1505
|
-
|
1506
|
-
|
1507
|
-
Env() {
|
1508
|
-
return envFactory();
|
1458
|
+
setParam(params) {
|
1459
|
+
this._map.setParam(params.lru);
|
1509
1460
|
}
|
1510
|
-
|
1511
|
-
|
1461
|
+
async asyncGet(key) {
|
1462
|
+
return this.get(await key());
|
1512
1463
|
}
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1464
|
+
get(key) {
|
1465
|
+
if (typeof key === "function") {
|
1466
|
+
key = key();
|
1467
|
+
}
|
1468
|
+
let keyed = this._map.get(key);
|
1469
|
+
if (!keyed) {
|
1470
|
+
keyed = this.factory(key);
|
1471
|
+
this._map.set(key, keyed);
|
1472
|
+
}
|
1473
|
+
return keyed;
|
1516
1474
|
}
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1475
|
+
unget(key) {
|
1476
|
+
const keyed = this._map.get(key);
|
1477
|
+
keyed == null ? void 0 : keyed.reset();
|
1478
|
+
this._map.delete(key);
|
1520
1479
|
}
|
1521
|
-
|
1522
|
-
|
1523
|
-
|
1524
|
-
if (!my) {
|
1525
|
-
my = new BaseSysAbstraction({
|
1526
|
-
TxtEnDecoder: (param2 == null ? void 0 : param2.TxtEnDecoder) || TxtEnDecoderSingleton(),
|
1527
|
-
FileSystem: new WebFileService(),
|
1528
|
-
SystemService: new WebSystemService()
|
1529
|
-
});
|
1480
|
+
reset() {
|
1481
|
+
this._map.forEach((keyed) => keyed.reset());
|
1482
|
+
this._map.clear();
|
1530
1483
|
}
|
1531
|
-
return new WrapperSysAbstraction(my, param2);
|
1532
|
-
}
|
1533
|
-
|
1534
|
-
// src/utils/relative-path.ts
|
1535
|
-
var PartType = {
|
1536
|
-
Slash: 1,
|
1537
|
-
Root: 3,
|
1538
|
-
Up: 4,
|
1539
|
-
Noop: 8
|
1540
|
-
// RootUp = 0x8 /* ../ */,
|
1541
1484
|
};
|
1542
|
-
var
|
1543
|
-
constructor(
|
1544
|
-
|
1485
|
+
var KeyedResolvOnce = class extends Keyed {
|
1486
|
+
constructor(kp = {}) {
|
1487
|
+
super((key) => new ResolveOnce(key), kp);
|
1545
1488
|
}
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
return part;
|
1489
|
+
/**
|
1490
|
+
*
|
1491
|
+
* @returns The values of the resolved keys
|
1492
|
+
*/
|
1493
|
+
values() {
|
1494
|
+
return Array.from(this._map.entries()).filter(([_, v]) => v._onceDone).map(([k, v]) => {
|
1495
|
+
if (v._onceDone) {
|
1496
|
+
if (v._onceError) {
|
1497
|
+
return {
|
1498
|
+
key: k,
|
1499
|
+
value: Result.Err(v._onceError)
|
1500
|
+
};
|
1559
1501
|
}
|
1502
|
+
return {
|
1503
|
+
key: k,
|
1504
|
+
value: Result.Ok(v._onceValue)
|
1505
|
+
};
|
1560
1506
|
}
|
1561
|
-
|
1562
|
-
|
1563
|
-
add(part) {
|
1564
|
-
if (this.parts.includes(PartType.Root) && part === PartType.Root) {
|
1565
|
-
throw new Error("Cannot add absolute part to absolute path");
|
1566
|
-
}
|
1567
|
-
const last = this.parts[this.parts.length - 1];
|
1568
|
-
if (last & PartType.Slash && part === PartType.Slash) {
|
1569
|
-
return;
|
1570
|
-
}
|
1571
|
-
switch (part) {
|
1572
|
-
case ".":
|
1573
|
-
this.parts.push(PartType.Noop);
|
1574
|
-
return;
|
1575
|
-
case "..":
|
1576
|
-
part = PartType.Up;
|
1577
|
-
}
|
1578
|
-
if (last === PartType.Noop && part === PartType.Slash) {
|
1579
|
-
if (last === PartType.Noop) {
|
1580
|
-
this.parts.pop();
|
1581
|
-
}
|
1582
|
-
return;
|
1583
|
-
}
|
1584
|
-
this.parts.push(part);
|
1507
|
+
throw new Error("KeyedResolvOnce.values impossible");
|
1508
|
+
});
|
1585
1509
|
}
|
1586
1510
|
};
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
return p;
|
1511
|
+
var KeyedResolvSeq = class extends Keyed {
|
1512
|
+
constructor(kp = {}) {
|
1513
|
+
super((key) => new ResolveSeq(key), kp);
|
1591
1514
|
}
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
path = path.replace(/^\/+/, "");
|
1600
|
-
} else {
|
1601
|
-
const part = path.replace(/\/.*$/, "");
|
1602
|
-
p.add(part);
|
1603
|
-
path = path.replace(/^[^/]+/, "");
|
1604
|
-
}
|
1515
|
+
};
|
1516
|
+
|
1517
|
+
// src/utils/coerce-uint8.ts
|
1518
|
+
var globalBuffer = globalThis;
|
1519
|
+
function coerceIntoUint8(raw) {
|
1520
|
+
if (raw instanceof ArrayBuffer) {
|
1521
|
+
return Result.Ok(new Uint8Array(raw));
|
1605
1522
|
}
|
1606
|
-
|
1607
|
-
|
1608
|
-
function pathJoin(...paths) {
|
1609
|
-
let prev = "";
|
1610
|
-
const res = [];
|
1611
|
-
for (let i = 0; i < paths.length; i++) {
|
1612
|
-
const path = paths[i];
|
1613
|
-
if (path === "") {
|
1614
|
-
continue;
|
1615
|
-
}
|
1616
|
-
if (!(prev.endsWith("/") || path.startsWith("/"))) {
|
1617
|
-
if (prev !== "") {
|
1618
|
-
res.push("/");
|
1619
|
-
}
|
1620
|
-
res.push(path);
|
1621
|
-
} else {
|
1622
|
-
res.push(path);
|
1623
|
-
}
|
1624
|
-
prev = path;
|
1523
|
+
if (ArrayBuffer.isView(raw)) {
|
1524
|
+
return Result.Ok(new Uint8Array(raw.buffer, raw.byteOffset, raw.byteLength));
|
1625
1525
|
}
|
1626
|
-
|
1627
|
-
|
1628
|
-
function relativePath(path, relative) {
|
1629
|
-
const relativeParts = splitPath(relative);
|
1630
|
-
let result;
|
1631
|
-
if (relativeParts.parts[0] === PartType.Root) {
|
1632
|
-
result = relative;
|
1633
|
-
} else {
|
1634
|
-
result = pathJoin(path, relative);
|
1526
|
+
if (raw instanceof Blob) {
|
1527
|
+
return Result.Err("Blob not supported");
|
1635
1528
|
}
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
if (out.length && !topUp) {
|
1646
|
-
const last = out.length - 1;
|
1647
|
-
if (typeof out[last] === "string" && out[last - 1] == PartType.Root) {
|
1648
|
-
out.pop();
|
1649
|
-
} else {
|
1650
|
-
out.pop();
|
1651
|
-
out.pop();
|
1652
|
-
}
|
1653
|
-
if (out.length === 0) {
|
1654
|
-
topUp = !topUp ? true : topUp;
|
1655
|
-
out.push(PartType.Up);
|
1656
|
-
}
|
1657
|
-
} else {
|
1658
|
-
out.push(PartType.Up);
|
1659
|
-
}
|
1660
|
-
break;
|
1661
|
-
case PartType.Slash:
|
1662
|
-
if (!(out[out.length - 1] & PartType.Slash)) {
|
1663
|
-
out.push(PartType.Slash);
|
1664
|
-
}
|
1665
|
-
break;
|
1666
|
-
default:
|
1667
|
-
out.push(part);
|
1668
|
-
break;
|
1529
|
+
if (globalBuffer.Buffer && globalBuffer.Buffer.isBuffer(raw)) {
|
1530
|
+
return Result.Ok(new Uint8Array(raw.buffer, raw.byteOffset, raw.byteLength));
|
1531
|
+
}
|
1532
|
+
if (raw instanceof Uint8Array) {
|
1533
|
+
return Result.Ok(raw);
|
1534
|
+
}
|
1535
|
+
if (Result.Is(raw)) {
|
1536
|
+
if (raw.isErr()) {
|
1537
|
+
return Result.Err(raw);
|
1669
1538
|
}
|
1539
|
+
return coerceIntoUint8(raw.unwrap());
|
1670
1540
|
}
|
1671
|
-
return
|
1541
|
+
return Result.Err("Not a Uint8Array");
|
1672
1542
|
}
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
const escaped = s.replace(/[-\\[\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\^\\$\\|]/g, "\\$&");
|
1680
|
-
return new RegExp(`^${escaped}$`);
|
1681
|
-
}
|
1682
|
-
return s;
|
1683
|
-
});
|
1684
|
-
return localStripper(void 0, restrips, obj);
|
1543
|
+
async function asyncCoerceIntoUint8(raw) {
|
1544
|
+
let resolved = await raw;
|
1545
|
+
if (resolved instanceof Blob) {
|
1546
|
+
resolved = await resolved.arrayBuffer();
|
1547
|
+
}
|
1548
|
+
return coerceIntoUint8(resolved);
|
1685
1549
|
}
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1550
|
+
|
1551
|
+
// src/txt-en-decoder.ts
|
1552
|
+
var TxtOps = class {
|
1553
|
+
constructor() {
|
1554
|
+
this.encoder = new TextEncoder();
|
1555
|
+
this.decoder = new TextDecoder();
|
1689
1556
|
}
|
1690
|
-
|
1691
|
-
return
|
1557
|
+
encode(str) {
|
1558
|
+
return this.encoder.encode(str);
|
1692
1559
|
}
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1696
|
-
|
1697
|
-
return true;
|
1698
|
-
}
|
1699
|
-
}
|
1700
|
-
return false;
|
1701
|
-
};
|
1702
|
-
for (const key in ret) {
|
1703
|
-
if (Object.prototype.hasOwnProperty.call(ret, key)) {
|
1704
|
-
let nextPath;
|
1705
|
-
if (path) {
|
1706
|
-
nextPath = [path, key].join(".");
|
1707
|
-
} else {
|
1708
|
-
nextPath = key;
|
1709
|
-
}
|
1710
|
-
if (matcher(key, nextPath)) {
|
1711
|
-
delete ret[key];
|
1712
|
-
continue;
|
1560
|
+
decode(data) {
|
1561
|
+
if (Result.Is(data)) {
|
1562
|
+
if (data.isErr()) {
|
1563
|
+
throw data.Err();
|
1713
1564
|
}
|
1714
|
-
|
1715
|
-
|
1716
|
-
|
1717
|
-
const toDelete = matcher(key, `${nextPath}[${i}]`);
|
1718
|
-
if (!toDelete) {
|
1719
|
-
acc.push(localStripper(`${nextPath}[${i}]`, restrips, v));
|
1720
|
-
}
|
1721
|
-
return acc;
|
1722
|
-
}, []);
|
1723
|
-
} else {
|
1724
|
-
ret[key] = localStripper(nextPath, restrips, ret[key]);
|
1725
|
-
}
|
1565
|
+
const unwrapped = data.unwrap();
|
1566
|
+
if (typeof unwrapped === "string") {
|
1567
|
+
return this.decode(unwrapped);
|
1726
1568
|
}
|
1727
1569
|
}
|
1570
|
+
if (typeof data === "string") {
|
1571
|
+
return data;
|
1572
|
+
}
|
1573
|
+
return this.decoder.decode(coerceIntoUint8(data).Ok());
|
1728
1574
|
}
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1733
|
-
function coerceKey(key, def) {
|
1734
|
-
if (typeof key === "object") {
|
1735
|
-
const keys = Object.keys(key);
|
1736
|
-
if (keys.length !== 1) {
|
1737
|
-
throw new Error(`Invalid key: ${JSON.stringify(key)}`);
|
1575
|
+
async asyncDecode(data) {
|
1576
|
+
let resolved = await data;
|
1577
|
+
if (resolved instanceof Blob) {
|
1578
|
+
resolved = await resolved.arrayBuffer();
|
1738
1579
|
}
|
1739
|
-
return
|
1580
|
+
return this.decode(resolved);
|
1740
1581
|
}
|
1741
|
-
|
1742
|
-
|
1743
|
-
function
|
1744
|
-
return
|
1582
|
+
};
|
1583
|
+
var txtEnDecoder = new ResolveOnce();
|
1584
|
+
function TxtEnDecoderSingleton() {
|
1585
|
+
return txtEnDecoder.once(() => new TxtOps());
|
1745
1586
|
}
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1587
|
+
|
1588
|
+
// src/option.ts
|
1589
|
+
var Option = class _Option {
|
1590
|
+
static Some(t) {
|
1591
|
+
return new Some(t);
|
1749
1592
|
}
|
1750
|
-
|
1751
|
-
|
1752
|
-
return new MutableURL(url);
|
1753
|
-
} catch (e) {
|
1754
|
-
return new MutableURL(`${defaultProtocol}//${url}`);
|
1755
|
-
}
|
1756
|
-
} else {
|
1757
|
-
return new MutableURL(url.toString());
|
1593
|
+
static None() {
|
1594
|
+
return new None();
|
1758
1595
|
}
|
1759
|
-
|
1760
|
-
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
super("defect://does.not.exist");
|
1766
|
-
const partedURL = urlStr.split(":");
|
1767
|
-
this._hasHostpart = hasHostPartProtocols.has(partedURL[0]);
|
1768
|
-
let hostPartUrl = ["http", ...partedURL.slice(1)].join(":");
|
1769
|
-
if (!this._hasHostpart) {
|
1770
|
-
const pathname = hostPartUrl.replace(/http:\/\/[/]*/, "").replace(/[#?].*$/, "");
|
1771
|
-
hostPartUrl = hostPartUrl.replace(/http:\/\//, `http://localhost/${pathname}`);
|
1772
|
-
}
|
1773
|
-
try {
|
1774
|
-
this._sysURL = new URL(hostPartUrl);
|
1775
|
-
} catch (ie) {
|
1776
|
-
const e = ie;
|
1777
|
-
e.message = `${e.message} for URL: ${urlStr}`;
|
1778
|
-
throw e;
|
1779
|
-
}
|
1780
|
-
this._protocol = `${partedURL[0]}:`;
|
1781
|
-
if (this._hasHostpart) {
|
1782
|
-
this._pathname = this._sysURL.pathname;
|
1783
|
-
} else {
|
1784
|
-
this._pathname = urlStr.replace(new RegExp(`^${this._protocol}//`), "").replace(/[#?].*$/, "");
|
1596
|
+
static Is(t) {
|
1597
|
+
return t instanceof _Option;
|
1598
|
+
}
|
1599
|
+
static From(t) {
|
1600
|
+
if (!t) {
|
1601
|
+
return new None();
|
1785
1602
|
}
|
1786
|
-
|
1603
|
+
return new Some(t);
|
1787
1604
|
}
|
1788
|
-
|
1789
|
-
return
|
1605
|
+
IsNone() {
|
1606
|
+
return this.is_none();
|
1790
1607
|
}
|
1791
|
-
|
1792
|
-
|
1793
|
-
throw new Error(
|
1794
|
-
`you can use hostname only if protocol is ${this.toString()} ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`
|
1795
|
-
);
|
1796
|
-
}
|
1797
|
-
return this._sysURL.host;
|
1608
|
+
IsSome() {
|
1609
|
+
return this.is_some();
|
1798
1610
|
}
|
1799
|
-
|
1800
|
-
|
1801
|
-
throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);
|
1802
|
-
}
|
1803
|
-
return this._sysURL.port;
|
1611
|
+
Unwrap() {
|
1612
|
+
return this.unwrap();
|
1804
1613
|
}
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
this.
|
1614
|
+
};
|
1615
|
+
var Some = class extends Option {
|
1616
|
+
constructor(_t) {
|
1617
|
+
super();
|
1618
|
+
this._t = _t;
|
1619
|
+
}
|
1620
|
+
is_none() {
|
1621
|
+
return false;
|
1622
|
+
}
|
1623
|
+
is_some() {
|
1624
|
+
return true;
|
1625
|
+
}
|
1626
|
+
unwrap() {
|
1627
|
+
return this._t;
|
1628
|
+
}
|
1629
|
+
};
|
1630
|
+
var None = class extends Option {
|
1631
|
+
is_none() {
|
1632
|
+
return true;
|
1633
|
+
}
|
1634
|
+
is_some() {
|
1635
|
+
return false;
|
1636
|
+
}
|
1637
|
+
unwrap() {
|
1638
|
+
throw new Error("None.unwrap");
|
1639
|
+
}
|
1640
|
+
};
|
1641
|
+
|
1642
|
+
// src/log-level-impl.ts
|
1643
|
+
var LevelHandlerImpl = class {
|
1644
|
+
constructor() {
|
1645
|
+
this._globalLevels = /* @__PURE__ */ new Set([Level.INFO, Level.ERROR, Level.WARN]);
|
1646
|
+
this._modules = /* @__PURE__ */ new Map();
|
1647
|
+
this.ignoreAttr = Option.Some(/^_/);
|
1648
|
+
this.isStackExposed = false;
|
1810
1649
|
}
|
1811
|
-
|
1812
|
-
if (
|
1813
|
-
|
1650
|
+
enableLevel(level, ...modules) {
|
1651
|
+
if (modules.length == 0) {
|
1652
|
+
this._globalLevels.add(level);
|
1653
|
+
return;
|
1814
1654
|
}
|
1815
|
-
|
1655
|
+
this.forModules(
|
1656
|
+
level,
|
1657
|
+
(p) => {
|
1658
|
+
this._modules.set(p, /* @__PURE__ */ new Set([...this._globalLevels, level]));
|
1659
|
+
},
|
1660
|
+
...modules
|
1661
|
+
);
|
1816
1662
|
}
|
1817
|
-
|
1818
|
-
if (
|
1819
|
-
|
1663
|
+
disableLevel(level, ...modules) {
|
1664
|
+
if (modules.length == 0) {
|
1665
|
+
this._globalLevels.delete(level);
|
1666
|
+
return;
|
1820
1667
|
}
|
1821
|
-
this.
|
1822
|
-
|
1823
|
-
|
1824
|
-
|
1668
|
+
this.forModules(
|
1669
|
+
level,
|
1670
|
+
(p) => {
|
1671
|
+
this._modules.delete(p);
|
1672
|
+
},
|
1673
|
+
...modules
|
1674
|
+
);
|
1825
1675
|
}
|
1826
|
-
|
1827
|
-
|
1676
|
+
setExposeStack(enable) {
|
1677
|
+
this.isStackExposed = !!enable;
|
1828
1678
|
}
|
1829
|
-
|
1830
|
-
|
1679
|
+
setIgnoreAttr(re) {
|
1680
|
+
this.ignoreAttr = Option.From(re);
|
1831
1681
|
}
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1682
|
+
forModules(level, fnAction, ...modules) {
|
1683
|
+
for (const m of modules.flat()) {
|
1684
|
+
if (typeof m !== "string") {
|
1685
|
+
continue;
|
1686
|
+
}
|
1687
|
+
const parts = m.split(",").map((s) => s.trim()).filter((s) => s.length);
|
1688
|
+
for (const p of parts) {
|
1689
|
+
fnAction(p);
|
1690
|
+
}
|
1835
1691
|
}
|
1836
|
-
this._protocol = p;
|
1837
1692
|
}
|
1838
|
-
|
1839
|
-
|
1693
|
+
setDebug(...modules) {
|
1694
|
+
this.forModules(
|
1695
|
+
Level.DEBUG,
|
1696
|
+
(p) => {
|
1697
|
+
this._modules.set(p, /* @__PURE__ */ new Set([...this._globalLevels, Level.DEBUG]));
|
1698
|
+
},
|
1699
|
+
...modules
|
1700
|
+
);
|
1840
1701
|
}
|
1841
|
-
|
1842
|
-
|
1843
|
-
if (
|
1844
|
-
|
1845
|
-
|
1702
|
+
isEnabled(ilevel, module2) {
|
1703
|
+
const level = ilevel;
|
1704
|
+
if (typeof module2 === "string") {
|
1705
|
+
const levels = this._modules.get(module2);
|
1706
|
+
if (levels && levels.has(level)) {
|
1707
|
+
return true;
|
1846
1708
|
}
|
1847
1709
|
}
|
1848
|
-
|
1849
|
-
if (
|
1850
|
-
|
1851
|
-
|
1852
|
-
hostpart += `:${this._sysURL.port}`;
|
1853
|
-
}
|
1854
|
-
if (!this._pathname.startsWith("/")) {
|
1855
|
-
hostpart += "/";
|
1710
|
+
const wlevel = this._modules.get("*");
|
1711
|
+
if (wlevel && typeof level === "string") {
|
1712
|
+
if (wlevel.has(level)) {
|
1713
|
+
return true;
|
1856
1714
|
}
|
1857
1715
|
}
|
1858
|
-
|
1716
|
+
if (typeof level !== "string") {
|
1717
|
+
return true;
|
1718
|
+
}
|
1719
|
+
return this._globalLevels.has(level);
|
1859
1720
|
}
|
1860
1721
|
};
|
1861
|
-
|
1862
|
-
|
1863
|
-
|
1864
|
-
return fac(new MutableURL(`${defaultProtocol}///`));
|
1865
|
-
case "string":
|
1866
|
-
return fac(ensureURLWithDefaultProto(strURLUri, defaultProtocol));
|
1867
|
-
case "object":
|
1868
|
-
if (BuildURI.is(strURLUri)) {
|
1869
|
-
return fac(new MutableURL(strURLUri._url.toString()));
|
1870
|
-
} else if (URI.is(strURLUri)) {
|
1871
|
-
return fac(new MutableURL(strURLUri._url.toString()));
|
1872
|
-
} else if (isURL(strURLUri)) {
|
1873
|
-
return fac(new MutableURL(strURLUri.toString()));
|
1874
|
-
}
|
1875
|
-
throw new Error(`unknown object type: ${strURLUri}`);
|
1876
|
-
default:
|
1877
|
-
throw new Error(`Invalid argument: ${typeof strURLUri}`);
|
1878
|
-
}
|
1722
|
+
var levelSingleton = new LevelHandlerImpl();
|
1723
|
+
function LevelHandlerSingleton() {
|
1724
|
+
return levelSingleton;
|
1879
1725
|
}
|
1880
|
-
|
1881
|
-
|
1882
|
-
|
1883
|
-
|
1884
|
-
|
1726
|
+
|
1727
|
+
// src/runtime.ts
|
1728
|
+
function isSet(value, ref = globalThis) {
|
1729
|
+
const [head, ...tail] = value.split(".");
|
1730
|
+
if (["object", "function"].includes(typeof ref) && ref && ["object", "function"].includes(typeof ref[head]) && ref[head]) {
|
1731
|
+
if (tail.length <= 1) {
|
1732
|
+
return true;
|
1733
|
+
}
|
1734
|
+
return isSet(tail.join("."), ref[head]);
|
1885
1735
|
}
|
1886
|
-
return
|
1736
|
+
return false;
|
1887
1737
|
}
|
1888
|
-
|
1889
|
-
|
1890
|
-
|
1891
|
-
|
1892
|
-
|
1893
|
-
|
1894
|
-
|
1895
|
-
|
1896
|
-
|
1897
|
-
return from((url) => new _BuildURI(url), strURLUri, defaultProtocol);
|
1898
|
-
}
|
1899
|
-
port(p) {
|
1900
|
-
this._url.port = p;
|
1901
|
-
return this;
|
1902
|
-
}
|
1903
|
-
hostname(h) {
|
1904
|
-
this._url.hostname = h;
|
1905
|
-
return this;
|
1738
|
+
function runtimeFn() {
|
1739
|
+
const gt = globalThis;
|
1740
|
+
let isReactNative = (
|
1741
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
1742
|
+
isSet("navigator.product") && typeof gt["navigator"] === "object" && gt["navigator"]["product"] === "ReactNative"
|
1743
|
+
);
|
1744
|
+
let isNodeIsh = false;
|
1745
|
+
if (!isSet("Deno")) {
|
1746
|
+
isNodeIsh = isSet("process.versions.node") && !isReactNative;
|
1906
1747
|
}
|
1907
|
-
|
1908
|
-
|
1909
|
-
|
1910
|
-
|
1911
|
-
|
1912
|
-
|
1748
|
+
let isDeno = isSet("Deno");
|
1749
|
+
const isCFWorker = isSet("caches.default") && isSet("WebSocketPair");
|
1750
|
+
if (isCFWorker) {
|
1751
|
+
isDeno = false;
|
1752
|
+
isNodeIsh = false;
|
1753
|
+
isReactNative = false;
|
1913
1754
|
}
|
1914
|
-
|
1915
|
-
|
1916
|
-
|
1755
|
+
return {
|
1756
|
+
isNodeIsh,
|
1757
|
+
isBrowser: !(isNodeIsh || isDeno || isCFWorker || isReactNative),
|
1758
|
+
isDeno,
|
1759
|
+
isReactNative,
|
1760
|
+
isCFWorker
|
1761
|
+
};
|
1762
|
+
}
|
1763
|
+
|
1764
|
+
// src/sys-abstraction.ts
|
1765
|
+
var TimeMode = {
|
1766
|
+
REAL: "real",
|
1767
|
+
CONST: "const",
|
1768
|
+
STEP: "step"
|
1769
|
+
};
|
1770
|
+
var RandomMode = {
|
1771
|
+
CONST: "const",
|
1772
|
+
STEP: "step",
|
1773
|
+
RANDOM: "random"
|
1774
|
+
};
|
1775
|
+
var IDMode = {
|
1776
|
+
UUID: "uuid",
|
1777
|
+
CONST: "const",
|
1778
|
+
STEP: "step"
|
1779
|
+
};
|
1780
|
+
function String2TimeMode(s) {
|
1781
|
+
switch (s == null ? void 0 : s.toLowerCase()) {
|
1782
|
+
case "real":
|
1783
|
+
return TimeMode.REAL;
|
1784
|
+
case "const":
|
1785
|
+
return TimeMode.CONST;
|
1786
|
+
case "step":
|
1787
|
+
return TimeMode.STEP;
|
1788
|
+
default:
|
1789
|
+
return TimeMode.REAL;
|
1917
1790
|
}
|
1918
|
-
|
1919
|
-
|
1920
|
-
|
1921
|
-
|
1922
|
-
|
1923
|
-
|
1924
|
-
|
1925
|
-
if (!p.match(/^[a-zA-Z0-9]+:/)) {
|
1926
|
-
if (p.startsWith("/")) {
|
1927
|
-
this.pathname(p);
|
1928
|
-
return this;
|
1929
|
-
}
|
1930
|
-
return this.appendRelative(p);
|
1931
|
-
}
|
1932
|
-
}
|
1933
|
-
this._url = new MutableURL(p.toString());
|
1934
|
-
return this;
|
1791
|
+
}
|
1792
|
+
|
1793
|
+
// src/time.ts
|
1794
|
+
var Time = class {
|
1795
|
+
TimeSince(start) {
|
1796
|
+
const now = this.Now();
|
1797
|
+
return now.getTime() - start.getTime();
|
1935
1798
|
}
|
1936
|
-
|
1937
|
-
|
1938
|
-
|
1939
|
-
|
1940
|
-
|
1941
|
-
|
1942
|
-
|
1943
|
-
|
1944
|
-
|
1799
|
+
};
|
1800
|
+
var TimeUnits = {
|
1801
|
+
Microsecond: 1,
|
1802
|
+
Second: 1e3 * 1,
|
1803
|
+
//Microsecond,
|
1804
|
+
Minute: 60 * 1e3 * 1,
|
1805
|
+
//Second,
|
1806
|
+
Hour: 60 * 60 * 1e3 * 1
|
1807
|
+
// Minute,
|
1808
|
+
};
|
1809
|
+
|
1810
|
+
// src/deno/deno-env-actions.ts
|
1811
|
+
var once = new ResolveOnce();
|
1812
|
+
var _deno;
|
1813
|
+
var _DenoEnvActions = class _DenoEnvActions {
|
1814
|
+
constructor(opts) {
|
1815
|
+
__privateAdd(this, _deno, globalThis);
|
1816
|
+
this.opts = opts;
|
1945
1817
|
}
|
1946
|
-
|
1947
|
-
|
1948
|
-
this._url.searchParams.delete(key);
|
1949
|
-
}
|
1950
|
-
return this;
|
1818
|
+
static new(opts) {
|
1819
|
+
return once.once(() => new _DenoEnvActions(opts));
|
1951
1820
|
}
|
1952
|
-
|
1953
|
-
this.
|
1954
|
-
return this;
|
1821
|
+
get _env() {
|
1822
|
+
return __privateGet(this, _deno).Deno.env;
|
1955
1823
|
}
|
1956
|
-
|
1957
|
-
|
1958
|
-
this.
|
1824
|
+
register(env) {
|
1825
|
+
for (const key of env.keys()) {
|
1826
|
+
this._env.set(key, env.get(key) || "");
|
1959
1827
|
}
|
1960
|
-
return
|
1828
|
+
return env;
|
1961
1829
|
}
|
1962
|
-
|
1963
|
-
|
1964
|
-
return this;
|
1830
|
+
active() {
|
1831
|
+
return runtimeFn().isDeno;
|
1965
1832
|
}
|
1966
|
-
|
1967
|
-
return this.
|
1833
|
+
keys() {
|
1834
|
+
return Object.keys(this._env.toObject());
|
1968
1835
|
}
|
1969
|
-
get
|
1970
|
-
return this.
|
1836
|
+
get(key) {
|
1837
|
+
return this._env.get(key);
|
1971
1838
|
}
|
1972
|
-
|
1973
|
-
|
1974
|
-
|
1975
|
-
if (!falsy2undef(val) && d) {
|
1976
|
-
val = d;
|
1839
|
+
set(key, value) {
|
1840
|
+
if (value) {
|
1841
|
+
this._env.set(key, value);
|
1977
1842
|
}
|
1978
|
-
return falsy2undef(val);
|
1979
1843
|
}
|
1980
|
-
|
1981
|
-
|
1844
|
+
delete(key) {
|
1845
|
+
this._env.delete(key);
|
1982
1846
|
}
|
1983
|
-
|
1984
|
-
|
1847
|
+
};
|
1848
|
+
_deno = new WeakMap();
|
1849
|
+
var DenoEnvActions = _DenoEnvActions;
|
1850
|
+
|
1851
|
+
// src/node/node-env-actions.ts
|
1852
|
+
var once2 = new ResolveOnce();
|
1853
|
+
var _node;
|
1854
|
+
var _NodeEnvActions = class _NodeEnvActions {
|
1855
|
+
constructor(opts) {
|
1856
|
+
__privateAdd(this, _node, globalThis);
|
1857
|
+
this._env = this.active() ? __privateGet(this, _node).process.env : {};
|
1858
|
+
this.opts = opts;
|
1985
1859
|
}
|
1986
|
-
|
1987
|
-
|
1988
|
-
return this._url.toString();
|
1860
|
+
static new(opts) {
|
1861
|
+
return once2.once(() => new _NodeEnvActions(opts));
|
1989
1862
|
}
|
1990
|
-
|
1991
|
-
|
1863
|
+
register(env) {
|
1864
|
+
for (const key of env.keys()) {
|
1865
|
+
this._env[key] = env.get(key) || "";
|
1866
|
+
}
|
1867
|
+
return env;
|
1992
1868
|
}
|
1993
|
-
|
1994
|
-
return
|
1869
|
+
active() {
|
1870
|
+
return runtimeFn().isNodeIsh;
|
1995
1871
|
}
|
1996
|
-
|
1997
|
-
return
|
1872
|
+
keys() {
|
1873
|
+
return Object.keys(this._env);
|
1998
1874
|
}
|
1999
|
-
|
2000
|
-
return
|
1875
|
+
get(key) {
|
1876
|
+
return this._env[key];
|
2001
1877
|
}
|
2002
|
-
|
2003
|
-
|
1878
|
+
set(key, value) {
|
1879
|
+
if (value) {
|
1880
|
+
this._env[key] = value;
|
1881
|
+
}
|
1882
|
+
}
|
1883
|
+
delete(key) {
|
1884
|
+
delete this._env[key];
|
2004
1885
|
}
|
2005
1886
|
};
|
2006
|
-
|
2007
|
-
|
2008
|
-
|
1887
|
+
_node = new WeakMap();
|
1888
|
+
var NodeEnvActions = _NodeEnvActions;
|
1889
|
+
|
1890
|
+
// src/web/web-env-actions.ts
|
1891
|
+
var once3 = new ResolveOnce();
|
1892
|
+
var BrowserEnvActions = class _BrowserEnvActions {
|
1893
|
+
constructor(opts) {
|
1894
|
+
this.env = /* @__PURE__ */ new Map();
|
1895
|
+
this.opts = opts;
|
2009
1896
|
}
|
2010
|
-
|
2011
|
-
return
|
1897
|
+
static new(opts) {
|
1898
|
+
return once3.once(() => new _BrowserEnvActions(opts));
|
2012
1899
|
}
|
2013
|
-
|
2014
|
-
return
|
1900
|
+
get(key) {
|
1901
|
+
return this.env.get(key);
|
2015
1902
|
}
|
2016
|
-
|
2017
|
-
|
1903
|
+
set(key, value) {
|
1904
|
+
if (value) {
|
1905
|
+
this.env.set(key, value);
|
1906
|
+
}
|
2018
1907
|
}
|
2019
|
-
|
2020
|
-
|
1908
|
+
delete(key) {
|
1909
|
+
this.env.delete(key);
|
2021
1910
|
}
|
2022
|
-
|
2023
|
-
|
2024
|
-
var hasHostPartProtocols = /* @__PURE__ */ new Set(["http", "https", "ws", "wss"]);
|
2025
|
-
var URI = class _URI {
|
2026
|
-
static protocolHasHostpart(protocol) {
|
2027
|
-
protocol = protocol.replace(/:$/, "");
|
2028
|
-
hasHostPartProtocols.add(protocol);
|
2029
|
-
return () => {
|
2030
|
-
hasHostPartProtocols.delete(protocol);
|
2031
|
-
};
|
1911
|
+
keys() {
|
1912
|
+
return Array.from(this.env.keys());
|
2032
1913
|
}
|
2033
|
-
|
2034
|
-
|
2035
|
-
const intoUrl = BuildURI.from(into, defaultProtocol);
|
2036
|
-
const fromUrl = _URI.from(from2, defaultProtocol);
|
2037
|
-
intoUrl.protocol(fromUrl.protocol);
|
2038
|
-
const fPath = fromUrl.pathname;
|
2039
|
-
if (!(fPath.length === 0 || fPath === "/" || fPath === "./")) {
|
2040
|
-
intoUrl.pathname(fromUrl.pathname);
|
2041
|
-
}
|
2042
|
-
for (const [key, value] of fromUrl.getParams) {
|
2043
|
-
intoUrl.setParam(key, value);
|
2044
|
-
}
|
2045
|
-
return intoUrl.URI();
|
1914
|
+
active() {
|
1915
|
+
return true;
|
2046
1916
|
}
|
2047
|
-
|
2048
|
-
|
1917
|
+
register(env) {
|
1918
|
+
const sym = Symbol.for(this.opts.symbol || "CP_ENV");
|
1919
|
+
const browser = globalThis;
|
1920
|
+
browser[sym] = env;
|
1921
|
+
return env;
|
2049
1922
|
}
|
2050
|
-
|
2051
|
-
|
2052
|
-
|
1923
|
+
};
|
1924
|
+
|
1925
|
+
// src/cf/cf-env-actions.ts
|
1926
|
+
var once4 = new ResolveOnce();
|
1927
|
+
var CFEnvActions = class _CFEnvActions {
|
1928
|
+
constructor(env) {
|
1929
|
+
this.injectOnRegister = {};
|
1930
|
+
this.cfEnv = new Map(Object.entries(env.presetEnv || {}));
|
2053
1931
|
}
|
2054
|
-
static
|
2055
|
-
return
|
1932
|
+
static new(opts) {
|
1933
|
+
return once4.once(() => new _CFEnvActions(opts));
|
2056
1934
|
}
|
2057
|
-
|
2058
|
-
|
1935
|
+
static inject(o) {
|
1936
|
+
const env = _CFEnvActions.new({});
|
1937
|
+
for (const key in o) {
|
1938
|
+
const value = o[key];
|
1939
|
+
if (typeof value === "string") {
|
1940
|
+
if (env.env) {
|
1941
|
+
env.env.set(key, value);
|
1942
|
+
} else {
|
1943
|
+
env.injectOnRegister[key] = value;
|
1944
|
+
}
|
1945
|
+
}
|
1946
|
+
}
|
2059
1947
|
}
|
2060
|
-
|
2061
|
-
return
|
1948
|
+
active() {
|
1949
|
+
return runtimeFn().isCFWorker;
|
2062
1950
|
}
|
2063
|
-
|
2064
|
-
|
1951
|
+
register(env) {
|
1952
|
+
this.env = env;
|
1953
|
+
for (const key in this.injectOnRegister) {
|
1954
|
+
env.set(key, this.injectOnRegister[key]);
|
1955
|
+
}
|
1956
|
+
return env;
|
2065
1957
|
}
|
2066
|
-
|
2067
|
-
|
2068
|
-
// }
|
2069
|
-
get port() {
|
2070
|
-
return this._url.port;
|
1958
|
+
get(key) {
|
1959
|
+
return this.cfEnv.get(key);
|
2071
1960
|
}
|
2072
|
-
|
2073
|
-
|
1961
|
+
set(key, value) {
|
1962
|
+
if (value) {
|
1963
|
+
this.cfEnv.set(key, value);
|
1964
|
+
}
|
2074
1965
|
}
|
2075
|
-
|
2076
|
-
|
2077
|
-
// }
|
2078
|
-
// get search(): string {
|
2079
|
-
// return this._url.search;
|
2080
|
-
// }
|
2081
|
-
get protocol() {
|
2082
|
-
return this._url.protocol;
|
1966
|
+
delete(key) {
|
1967
|
+
this.cfEnv.delete(key);
|
2083
1968
|
}
|
2084
|
-
|
2085
|
-
return this.
|
1969
|
+
keys() {
|
1970
|
+
return Array.from(this.cfEnv.keys());
|
1971
|
+
}
|
1972
|
+
};
|
1973
|
+
|
1974
|
+
// src/sys-env.ts
|
1975
|
+
var envActions = [
|
1976
|
+
{ id: "cf", fn: (opts) => CFEnvActions.new(opts) },
|
1977
|
+
{ id: "node", fn: (opts) => NodeEnvActions.new(opts) },
|
1978
|
+
{ id: "deno", fn: (opts) => DenoEnvActions.new(opts) },
|
1979
|
+
{ id: "browser", fn: (opts) => BrowserEnvActions.new(opts) }
|
1980
|
+
];
|
1981
|
+
function registerEnvAction(fn) {
|
1982
|
+
const id = `id-${Math.random()}`;
|
1983
|
+
envActions.unshift({ id, fn });
|
1984
|
+
_envFactories.unget(id);
|
1985
|
+
return () => {
|
1986
|
+
const index = envActions.findIndex((i) => i.id === id);
|
1987
|
+
if (index >= 0) {
|
1988
|
+
envActions.splice(index, 1);
|
1989
|
+
}
|
1990
|
+
};
|
1991
|
+
}
|
1992
|
+
var _envFactories = new KeyedResolvOnce();
|
1993
|
+
function envFactory(opts = {}) {
|
1994
|
+
const found = envActions.find((fi) => fi.fn(opts).active());
|
1995
|
+
if (!found) {
|
1996
|
+
throw new Error("SysContainer:envFactory: no env available");
|
2086
1997
|
}
|
2087
|
-
|
2088
|
-
|
2089
|
-
|
2090
|
-
|
2091
|
-
|
2092
|
-
|
2093
|
-
|
2094
|
-
|
1998
|
+
return _envFactories.get(found.id).once(() => {
|
1999
|
+
const action = found.fn(opts);
|
2000
|
+
const ret = new EnvImpl(action, opts);
|
2001
|
+
action.register(ret);
|
2002
|
+
return ret;
|
2003
|
+
});
|
2004
|
+
}
|
2005
|
+
function isIterable(obj) {
|
2006
|
+
if (obj == null) {
|
2007
|
+
return false;
|
2095
2008
|
}
|
2096
|
-
|
2097
|
-
|
2009
|
+
return typeof obj[Symbol.iterator] === "function";
|
2010
|
+
}
|
2011
|
+
var EnvImpl = class {
|
2012
|
+
constructor(map, opts = {}) {
|
2013
|
+
this._onSet = [];
|
2014
|
+
this._map = map;
|
2015
|
+
this._updatePresets(opts.presetEnv);
|
2098
2016
|
}
|
2099
|
-
|
2100
|
-
|
2101
|
-
|
2102
|
-
|
2103
|
-
val = d;
|
2104
|
-
}
|
2105
|
-
return falsy2undef(val);
|
2017
|
+
gets(...kparams) {
|
2018
|
+
return getParamsResult(kparams, {
|
2019
|
+
getParam: (k) => this.get(k)
|
2020
|
+
});
|
2106
2021
|
}
|
2107
|
-
|
2108
|
-
|
2022
|
+
sets(...keys) {
|
2023
|
+
keys.forEach((key) => {
|
2024
|
+
if (Array.isArray(key)) {
|
2025
|
+
if (key.length === 2) {
|
2026
|
+
const [k, v] = key;
|
2027
|
+
if (typeof k === "string" && typeof v === "string") {
|
2028
|
+
this.set(k, v);
|
2029
|
+
return;
|
2030
|
+
}
|
2031
|
+
}
|
2032
|
+
for (const item of key) {
|
2033
|
+
if (Array.isArray(item)) {
|
2034
|
+
if (item.length === 2) {
|
2035
|
+
const [k, v] = item;
|
2036
|
+
if (typeof k === "string" && typeof v === "string") {
|
2037
|
+
this.set(k, v);
|
2038
|
+
}
|
2039
|
+
}
|
2040
|
+
}
|
2041
|
+
}
|
2042
|
+
} else {
|
2043
|
+
if (isIterable(key)) {
|
2044
|
+
for (const [k, v] of key) {
|
2045
|
+
if (typeof k === "string" && typeof v === "string") {
|
2046
|
+
this.set(k, v);
|
2047
|
+
}
|
2048
|
+
}
|
2049
|
+
} else {
|
2050
|
+
const rKey = key;
|
2051
|
+
for (const k in rKey) {
|
2052
|
+
const v = rKey[k];
|
2053
|
+
if (typeof k === "string" && typeof v === "string") {
|
2054
|
+
this.set(k, v);
|
2055
|
+
}
|
2056
|
+
}
|
2057
|
+
}
|
2058
|
+
}
|
2059
|
+
});
|
2109
2060
|
}
|
2110
|
-
|
2111
|
-
|
2061
|
+
_updatePresets(presetEnv) {
|
2062
|
+
if (!presetEnv) {
|
2063
|
+
return;
|
2064
|
+
}
|
2065
|
+
for (const [key, value] of presetEnv) {
|
2066
|
+
this._map.set(key, value);
|
2067
|
+
}
|
2112
2068
|
}
|
2113
|
-
|
2114
|
-
|
2069
|
+
_applyOnSet(onSet, key, value) {
|
2070
|
+
onSet.forEach((item) => {
|
2071
|
+
let keys = [];
|
2072
|
+
if (key) {
|
2073
|
+
keys = [key];
|
2074
|
+
} else {
|
2075
|
+
keys = this._map.keys();
|
2076
|
+
}
|
2077
|
+
keys.filter((k) => {
|
2078
|
+
if (item.filter.size === 0) {
|
2079
|
+
return true;
|
2080
|
+
}
|
2081
|
+
if (item.filter.has(k)) {
|
2082
|
+
return true;
|
2083
|
+
}
|
2084
|
+
return false;
|
2085
|
+
}).forEach((k) => {
|
2086
|
+
let v;
|
2087
|
+
if (!key && !value) {
|
2088
|
+
v = this._map.get(k);
|
2089
|
+
} else if (key && !value) {
|
2090
|
+
v = void 0;
|
2091
|
+
} else {
|
2092
|
+
v = value;
|
2093
|
+
}
|
2094
|
+
item.fn(k, v);
|
2095
|
+
});
|
2096
|
+
});
|
2115
2097
|
}
|
2116
|
-
|
2117
|
-
return this.
|
2098
|
+
keys() {
|
2099
|
+
return this._map.keys();
|
2118
2100
|
}
|
2119
|
-
|
2120
|
-
|
2101
|
+
// filter is not set all sets passed
|
2102
|
+
onSet(fn, ...filter) {
|
2103
|
+
const item = { filter: new Set(filter), fn };
|
2104
|
+
this._onSet.push(item);
|
2105
|
+
this._applyOnSet([item]);
|
2121
2106
|
}
|
2122
|
-
|
2123
|
-
return this.
|
2107
|
+
get(key) {
|
2108
|
+
return this._map.get(key);
|
2124
2109
|
}
|
2125
|
-
|
2126
|
-
|
2127
|
-
|
2128
|
-
protocol: this.protocol,
|
2129
|
-
pathname: this.pathname,
|
2130
|
-
searchParams: Object.fromEntries(this.getParams)
|
2131
|
-
};
|
2132
|
-
if (hasHostPartProtocols.has(this.protocol.replace(/:$/, ""))) {
|
2133
|
-
return stripper(strips, {
|
2134
|
-
...pathURI,
|
2135
|
-
style: "host",
|
2136
|
-
hostname: this.hostname,
|
2137
|
-
port: this.port
|
2138
|
-
});
|
2110
|
+
set(key, value) {
|
2111
|
+
if (!value) {
|
2112
|
+
return;
|
2139
2113
|
}
|
2140
|
-
|
2114
|
+
this._map.set(key, value);
|
2115
|
+
this._applyOnSet(this._onSet, key, value);
|
2116
|
+
}
|
2117
|
+
delete(key) {
|
2118
|
+
this._map.delete(key);
|
2119
|
+
this._applyOnSet(this._onSet, key);
|
2141
2120
|
}
|
2142
2121
|
};
|
2143
2122
|
|
@@ -2206,190 +2185,361 @@ var ConsoleWriterStream = class {
|
|
2206
2185
|
}
|
2207
2186
|
};
|
2208
2187
|
|
2209
|
-
// src/
|
2210
|
-
var
|
2211
|
-
constructor(
|
2212
|
-
this.
|
2213
|
-
this._flushIsRunning = false;
|
2214
|
-
this._flushDoneFns = [];
|
2215
|
-
this._out = out;
|
2188
|
+
// src/web/web-basic-sys-abstraction.ts
|
2189
|
+
var WebSystemService = class {
|
2190
|
+
constructor(ende) {
|
2191
|
+
this._txtEnDe = ende;
|
2216
2192
|
}
|
2217
|
-
|
2218
|
-
|
2219
|
-
|
2220
|
-
|
2221
|
-
|
2222
|
-
|
2223
|
-
|
2224
|
-
|
2225
|
-
|
2193
|
+
Env() {
|
2194
|
+
return envFactory();
|
2195
|
+
}
|
2196
|
+
Args() {
|
2197
|
+
throw new Error("Args-Method not implemented.");
|
2198
|
+
}
|
2199
|
+
Stdout() {
|
2200
|
+
return new ConsoleWriterStream();
|
2201
|
+
}
|
2202
|
+
Stderr() {
|
2203
|
+
const decoder = this._txtEnDe;
|
2204
|
+
return new WritableStream({
|
2205
|
+
write(chunk) {
|
2206
|
+
return new Promise((resolve) => {
|
2207
|
+
const decoded = decoder.decode(chunk);
|
2208
|
+
console.error(decoded.trimEnd());
|
2209
|
+
resolve();
|
2210
|
+
});
|
2226
2211
|
}
|
2227
|
-
};
|
2228
|
-
this._toFlush.push(my2);
|
2229
|
-
this._flush();
|
2212
|
+
});
|
2230
2213
|
}
|
2231
|
-
|
2214
|
+
};
|
2215
|
+
var baseSysAbstraction = new ResolveOnce();
|
2216
|
+
function WebBasicSysAbstraction(param2) {
|
2217
|
+
var _a;
|
2218
|
+
const my = baseSysAbstraction.once(() => {
|
2219
|
+
return new BaseBasicSysAbstraction({
|
2220
|
+
TxtEnDecoder: (param2 == null ? void 0 : param2.TxtEnDecoder) || TxtEnDecoderSingleton()
|
2221
|
+
});
|
2222
|
+
});
|
2223
|
+
return new WrapperBasicSysAbstraction(my, {
|
2224
|
+
basicRuntimeService: new WebSystemService((_a = param2 == null ? void 0 : param2.TxtEnDecoder) != null ? _a : my._txtEnDe),
|
2225
|
+
...param2
|
2226
|
+
});
|
2227
|
+
}
|
2228
|
+
|
2229
|
+
// src/cf/cf-basic-sys-abstraction.ts
|
2230
|
+
var CFRuntimeService = class {
|
2231
|
+
constructor(ende) {
|
2232
|
+
this._txtEnDe = ende;
|
2233
|
+
}
|
2234
|
+
Env() {
|
2235
|
+
return envFactory();
|
2236
|
+
}
|
2237
|
+
Args() {
|
2238
|
+
throw new Error("Args-Method not implemented.");
|
2239
|
+
}
|
2240
|
+
Stdout() {
|
2241
|
+
return CFWriteableStream((chunk) => {
|
2242
|
+
const decoded = this._txtEnDe.decode(chunk);
|
2243
|
+
console.log(decoded.trimEnd());
|
2244
|
+
return Promise.resolve();
|
2245
|
+
});
|
2246
|
+
}
|
2247
|
+
Stderr() {
|
2248
|
+
return CFWriteableStream((chunk) => {
|
2249
|
+
const decoded = this._txtEnDe.decode(chunk);
|
2250
|
+
console.error(decoded.trimEnd());
|
2251
|
+
return Promise.resolve();
|
2252
|
+
});
|
2253
|
+
}
|
2254
|
+
};
|
2255
|
+
function consumeReadableStream(reader, writeFn) {
|
2256
|
+
reader.read().then(({ done, value }) => {
|
2232
2257
|
if (done) {
|
2233
|
-
this._flushDoneFns.push(done);
|
2234
|
-
}
|
2235
|
-
if (this._toFlush.length == 0) {
|
2236
|
-
this._flushIsRunning = false;
|
2237
|
-
this._flushDoneFns.forEach((fn) => fn());
|
2238
|
-
this._flushDoneFns = [];
|
2239
2258
|
return;
|
2240
2259
|
}
|
2241
|
-
|
2242
|
-
|
2243
|
-
}
|
2244
|
-
|
2245
|
-
}
|
2246
|
-
|
2247
|
-
|
2248
|
-
|
2249
|
-
|
2250
|
-
|
2260
|
+
writeFn(value).then(() => {
|
2261
|
+
consumeReadableStream(reader, writeFn);
|
2262
|
+
}).catch((e) => {
|
2263
|
+
console.error("consumeReadableStream:writeFn", e);
|
2264
|
+
});
|
2265
|
+
}).catch((e) => {
|
2266
|
+
console.error("consumeReadableStream:read", e);
|
2267
|
+
});
|
2268
|
+
}
|
2269
|
+
function CFWriteableStream(writeFn) {
|
2270
|
+
const ts = new TransformStream();
|
2271
|
+
consumeReadableStream(ts.readable.getReader(), writeFn);
|
2272
|
+
return ts.writable;
|
2273
|
+
}
|
2274
|
+
var baseSysAbstraction2 = new ResolveOnce();
|
2275
|
+
function CFBasicSysAbstraction(param2) {
|
2276
|
+
var _a;
|
2277
|
+
const my = baseSysAbstraction2.once(() => {
|
2278
|
+
return new BaseBasicSysAbstraction({
|
2279
|
+
TxtEnDecoder: (param2 == null ? void 0 : param2.TxtEnDecoder) || TxtEnDecoderSingleton()
|
2251
2280
|
});
|
2281
|
+
});
|
2282
|
+
return new WrapperBasicSysAbstraction(my, {
|
2283
|
+
basicRuntimeService: new CFRuntimeService((_a = param2 == null ? void 0 : param2.TxtEnDecoder) != null ? _a : my._txtEnDe),
|
2284
|
+
...param2
|
2285
|
+
});
|
2286
|
+
}
|
2287
|
+
|
2288
|
+
// src/deno/deno-basic-sys-abstraction.ts
|
2289
|
+
var DenoRuntimeService = class {
|
2290
|
+
constructor(ende) {
|
2291
|
+
this._txtEnDe = ende;
|
2292
|
+
}
|
2293
|
+
Env() {
|
2294
|
+
return envFactory();
|
2295
|
+
}
|
2296
|
+
Args() {
|
2297
|
+
return globalThis.Deno.args;
|
2298
|
+
}
|
2299
|
+
Stdout() {
|
2300
|
+
return globalThis.Deno.stdout.writable;
|
2301
|
+
}
|
2302
|
+
Stderr() {
|
2303
|
+
return globalThis.Deno.stderr.writable;
|
2252
2304
|
}
|
2253
2305
|
};
|
2306
|
+
var baseSysAbstraction3 = new ResolveOnce();
|
2307
|
+
function DenoBasicSysAbstraction(param2) {
|
2308
|
+
var _a;
|
2309
|
+
const my = baseSysAbstraction3.once(() => {
|
2310
|
+
return new BaseBasicSysAbstraction({
|
2311
|
+
TxtEnDecoder: (param2 == null ? void 0 : param2.TxtEnDecoder) || TxtEnDecoderSingleton()
|
2312
|
+
});
|
2313
|
+
});
|
2314
|
+
return new WrapperBasicSysAbstraction(my, {
|
2315
|
+
basicRuntimeService: new DenoRuntimeService((_a = param2 == null ? void 0 : param2.TxtEnDecoder) != null ? _a : my._txtEnDe),
|
2316
|
+
...param2
|
2317
|
+
});
|
2318
|
+
}
|
2254
2319
|
|
2255
|
-
// src/
|
2256
|
-
var
|
2257
|
-
|
2258
|
-
|
2259
|
-
|
2260
|
-
static None() {
|
2261
|
-
return new None();
|
2262
|
-
}
|
2263
|
-
static Is(t) {
|
2264
|
-
return t instanceof _Option;
|
2320
|
+
// src/node/node-basic-sys-abstraction.ts
|
2321
|
+
var NodeRuntimeService = class {
|
2322
|
+
constructor(ende) {
|
2323
|
+
this._txtEnDe = ende;
|
2324
|
+
this._gthis = globalThis;
|
2265
2325
|
}
|
2266
|
-
|
2267
|
-
|
2268
|
-
return new None();
|
2269
|
-
}
|
2270
|
-
return new Some(t);
|
2326
|
+
Env() {
|
2327
|
+
return envFactory();
|
2271
2328
|
}
|
2272
|
-
|
2273
|
-
return this.
|
2329
|
+
Args() {
|
2330
|
+
return this._gthis.process.argv;
|
2274
2331
|
}
|
2275
|
-
|
2276
|
-
return
|
2332
|
+
Stdout() {
|
2333
|
+
return new WritableStream({
|
2334
|
+
write: (chunk) => {
|
2335
|
+
this._gthis.process.stdout.write(chunk);
|
2336
|
+
}
|
2337
|
+
});
|
2277
2338
|
}
|
2278
|
-
|
2279
|
-
return
|
2339
|
+
Stderr() {
|
2340
|
+
return new WritableStream({
|
2341
|
+
write: (chunk) => {
|
2342
|
+
this._gthis.process.stderr.write(chunk);
|
2343
|
+
}
|
2344
|
+
});
|
2280
2345
|
}
|
2281
2346
|
};
|
2282
|
-
var
|
2283
|
-
|
2284
|
-
|
2285
|
-
|
2347
|
+
var baseSysAbstraction4 = new ResolveOnce();
|
2348
|
+
function NodeBasicSysAbstraction(param2) {
|
2349
|
+
var _a;
|
2350
|
+
const my = baseSysAbstraction4.once(() => {
|
2351
|
+
return new BaseBasicSysAbstraction({
|
2352
|
+
TxtEnDecoder: (param2 == null ? void 0 : param2.TxtEnDecoder) || TxtEnDecoderSingleton()
|
2353
|
+
});
|
2354
|
+
});
|
2355
|
+
return new WrapperBasicSysAbstraction(my, {
|
2356
|
+
basicRuntimeService: new NodeRuntimeService((_a = param2 == null ? void 0 : param2.TxtEnDecoder) != null ? _a : my._txtEnDe),
|
2357
|
+
...param2
|
2358
|
+
});
|
2359
|
+
}
|
2360
|
+
|
2361
|
+
// src/base-sys-abstraction.ts
|
2362
|
+
var SysTime = class extends Time {
|
2363
|
+
Now() {
|
2364
|
+
return /* @__PURE__ */ new Date();
|
2286
2365
|
}
|
2287
|
-
|
2288
|
-
return
|
2366
|
+
Sleep(duration) {
|
2367
|
+
return new Promise((resolve) => {
|
2368
|
+
setTimeout(() => {
|
2369
|
+
resolve();
|
2370
|
+
}, duration);
|
2371
|
+
});
|
2289
2372
|
}
|
2290
|
-
|
2291
|
-
|
2373
|
+
};
|
2374
|
+
var ConstTime = class extends Time {
|
2375
|
+
Now() {
|
2376
|
+
return new Date(2021, 1, 1, 0, 0, 0, 0);
|
2292
2377
|
}
|
2293
|
-
|
2294
|
-
|
2378
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2379
|
+
Sleep(duration) {
|
2380
|
+
return Promise.resolve();
|
2295
2381
|
}
|
2296
2382
|
};
|
2297
|
-
var
|
2298
|
-
|
2299
|
-
|
2383
|
+
var StepTime = class extends Time {
|
2384
|
+
constructor() {
|
2385
|
+
super();
|
2386
|
+
this._step = new ConstTime().Now();
|
2387
|
+
this._start = this._step;
|
2300
2388
|
}
|
2301
|
-
|
2302
|
-
|
2389
|
+
Now(steps = 1) {
|
2390
|
+
for (let i = 0; steps > 0 && i < steps; i++) {
|
2391
|
+
this._step = new Date(this._step.getTime() + 1e3);
|
2392
|
+
}
|
2393
|
+
if (steps < 1) {
|
2394
|
+
this._step = new Date(this._start.getTime() + steps * -1e3);
|
2395
|
+
}
|
2396
|
+
return this._step;
|
2303
2397
|
}
|
2304
|
-
|
2305
|
-
|
2398
|
+
Sleep(duration) {
|
2399
|
+
this._step = new Date(this._step.getTime() + duration);
|
2400
|
+
return Promise.resolve();
|
2306
2401
|
}
|
2307
2402
|
};
|
2308
|
-
|
2309
|
-
|
2310
|
-
|
2311
|
-
|
2312
|
-
|
2313
|
-
|
2314
|
-
|
2315
|
-
|
2403
|
+
function TimeFactory(timeMode) {
|
2404
|
+
switch (timeMode) {
|
2405
|
+
case TimeMode.REAL:
|
2406
|
+
return new SysTime();
|
2407
|
+
case TimeMode.CONST:
|
2408
|
+
return new ConstTime();
|
2409
|
+
case TimeMode.STEP:
|
2410
|
+
return new StepTime();
|
2316
2411
|
}
|
2317
|
-
|
2318
|
-
|
2319
|
-
|
2320
|
-
|
2412
|
+
return new SysTime();
|
2413
|
+
}
|
2414
|
+
var RandomService = class {
|
2415
|
+
constructor(mode) {
|
2416
|
+
this._step = 0;
|
2417
|
+
this._mode = mode;
|
2418
|
+
}
|
2419
|
+
Random0ToValue(value) {
|
2420
|
+
switch (this._mode) {
|
2421
|
+
case RandomMode.CONST:
|
2422
|
+
return 0.5 * value;
|
2423
|
+
case RandomMode.STEP:
|
2424
|
+
this._step += 1e-4;
|
2425
|
+
return this._step * value;
|
2426
|
+
case RandomMode.RANDOM:
|
2427
|
+
return Math.random() * value;
|
2428
|
+
default:
|
2429
|
+
throw new Error("Unknown RandomMode");
|
2321
2430
|
}
|
2322
|
-
this.forModules(
|
2323
|
-
level,
|
2324
|
-
(p) => {
|
2325
|
-
this._modules.set(p, /* @__PURE__ */ new Set([...this._globalLevels, level]));
|
2326
|
-
},
|
2327
|
-
...modules
|
2328
|
-
);
|
2329
2431
|
}
|
2330
|
-
|
2331
|
-
|
2332
|
-
|
2333
|
-
|
2432
|
+
};
|
2433
|
+
var IdService = class {
|
2434
|
+
constructor(mode) {
|
2435
|
+
this._step = 0;
|
2436
|
+
if (!mode) {
|
2437
|
+
mode = IDMode.UUID;
|
2334
2438
|
}
|
2335
|
-
this.
|
2336
|
-
level,
|
2337
|
-
(p) => {
|
2338
|
-
this._modules.delete(p);
|
2339
|
-
},
|
2340
|
-
...modules
|
2341
|
-
);
|
2439
|
+
this._mode = mode;
|
2342
2440
|
}
|
2343
|
-
|
2344
|
-
this.
|
2441
|
+
NextId() {
|
2442
|
+
switch (this._mode) {
|
2443
|
+
case IDMode.UUID:
|
2444
|
+
return crypto.randomUUID();
|
2445
|
+
case IDMode.CONST:
|
2446
|
+
return "VeryUniqueID";
|
2447
|
+
case IDMode.STEP:
|
2448
|
+
return `STEPId-${this._step++}`;
|
2449
|
+
default:
|
2450
|
+
throw new Error("Unknown IDMode");
|
2451
|
+
}
|
2345
2452
|
}
|
2346
|
-
|
2347
|
-
|
2453
|
+
};
|
2454
|
+
var BaseBasicSysAbstraction = class {
|
2455
|
+
constructor(params) {
|
2456
|
+
this._time = new SysTime();
|
2457
|
+
// system independent services
|
2458
|
+
this._idService = new IdService();
|
2459
|
+
this._randomService = new RandomService(RandomMode.RANDOM);
|
2460
|
+
this._txtEnDe = params.TxtEnDecoder;
|
2348
2461
|
}
|
2349
|
-
|
2350
|
-
|
2351
|
-
|
2352
|
-
|
2353
|
-
|
2354
|
-
|
2355
|
-
for (const p of parts) {
|
2356
|
-
fnAction(p);
|
2357
|
-
}
|
2358
|
-
}
|
2462
|
+
};
|
2463
|
+
var BaseSysAbstraction = class extends BaseBasicSysAbstraction {
|
2464
|
+
constructor(params) {
|
2465
|
+
super(params);
|
2466
|
+
this._fileSystem = params.FileSystem;
|
2467
|
+
this._systemService = params.SystemService;
|
2359
2468
|
}
|
2360
|
-
|
2361
|
-
|
2362
|
-
|
2363
|
-
|
2364
|
-
|
2365
|
-
|
2366
|
-
|
2367
|
-
|
2469
|
+
};
|
2470
|
+
function BasicSysAbstractionFactory(params) {
|
2471
|
+
const fn = runtimeFn();
|
2472
|
+
switch (true) {
|
2473
|
+
case fn.isBrowser:
|
2474
|
+
return WebBasicSysAbstraction(params);
|
2475
|
+
case fn.isDeno:
|
2476
|
+
return DenoBasicSysAbstraction(params);
|
2477
|
+
case fn.isCFWorker:
|
2478
|
+
return CFBasicSysAbstraction(params);
|
2479
|
+
case fn.isNodeIsh:
|
2480
|
+
return NodeBasicSysAbstraction(params);
|
2481
|
+
default:
|
2482
|
+
throw new Error("Unknown runtime");
|
2368
2483
|
}
|
2369
|
-
|
2370
|
-
|
2371
|
-
|
2372
|
-
|
2373
|
-
|
2374
|
-
|
2375
|
-
|
2484
|
+
}
|
2485
|
+
var WrapperBasicSysAbstraction = class {
|
2486
|
+
constructor(base, params) {
|
2487
|
+
this._time = base._time;
|
2488
|
+
this._basicRuntimeService = params.basicRuntimeService;
|
2489
|
+
this._idService = base._idService;
|
2490
|
+
this._randomService = base._randomService;
|
2491
|
+
if (params.TimeMode) {
|
2492
|
+
this._time = TimeFactory(params.TimeMode);
|
2376
2493
|
}
|
2377
|
-
|
2378
|
-
|
2379
|
-
if (wlevel.has(level)) {
|
2380
|
-
return true;
|
2381
|
-
}
|
2494
|
+
if (params.IdMode) {
|
2495
|
+
this._idService = new IdService(params.IdMode);
|
2382
2496
|
}
|
2383
|
-
if (
|
2384
|
-
|
2497
|
+
if (params.RandomMode) {
|
2498
|
+
this._randomService = new RandomService(params.RandomMode);
|
2385
2499
|
}
|
2386
|
-
|
2500
|
+
}
|
2501
|
+
Time() {
|
2502
|
+
return this._time;
|
2503
|
+
}
|
2504
|
+
NextId() {
|
2505
|
+
return this._idService.NextId();
|
2506
|
+
}
|
2507
|
+
Random0ToValue(value) {
|
2508
|
+
return this._randomService.Random0ToValue(value);
|
2509
|
+
}
|
2510
|
+
Stdout() {
|
2511
|
+
return this._basicRuntimeService.Stdout();
|
2512
|
+
}
|
2513
|
+
Stderr() {
|
2514
|
+
return this._basicRuntimeService.Stderr();
|
2515
|
+
}
|
2516
|
+
Env() {
|
2517
|
+
return this._basicRuntimeService.Env();
|
2518
|
+
}
|
2519
|
+
Args() {
|
2520
|
+
return this._basicRuntimeService.Args();
|
2521
|
+
}
|
2522
|
+
// System(): SystemService {
|
2523
|
+
// return this._systemService;
|
2524
|
+
// }
|
2525
|
+
// FileSystem(): FileService {
|
2526
|
+
// return this._fileSystem;
|
2527
|
+
// }
|
2528
|
+
};
|
2529
|
+
var WrapperRuntimeSysAbstraction = class extends WrapperBasicSysAbstraction {
|
2530
|
+
constructor(base, params) {
|
2531
|
+
var _a, _b;
|
2532
|
+
super(base, params);
|
2533
|
+
this._systemService = (_a = params.systemService) != null ? _a : base._systemService;
|
2534
|
+
this._fileSystem = (_b = params.fileSystem) != null ? _b : base._fileSystem;
|
2535
|
+
}
|
2536
|
+
System() {
|
2537
|
+
return this._systemService;
|
2538
|
+
}
|
2539
|
+
FileSystem() {
|
2540
|
+
return this._fileSystem;
|
2387
2541
|
}
|
2388
2542
|
};
|
2389
|
-
var levelSingleton = new LevelHandlerImpl();
|
2390
|
-
function LevelHandlerSingleton() {
|
2391
|
-
return levelSingleton;
|
2392
|
-
}
|
2393
2543
|
|
2394
2544
|
// src/logger-impl.ts
|
2395
2545
|
function getLen(value, lvs) {
|
@@ -2450,7 +2600,7 @@ var LoggerImpl = class _LoggerImpl {
|
|
2450
2600
|
params = {};
|
2451
2601
|
}
|
2452
2602
|
if (!params.sys) {
|
2453
|
-
this._sys =
|
2603
|
+
this._sys = BasicSysAbstractionFactory();
|
2454
2604
|
} else {
|
2455
2605
|
this._sys = params.sys;
|
2456
2606
|
}
|
@@ -2468,18 +2618,7 @@ var LoggerImpl = class _LoggerImpl {
|
|
2468
2618
|
this._logWriter = params.logWriter;
|
2469
2619
|
} else {
|
2470
2620
|
if (!params.out) {
|
2471
|
-
|
2472
|
-
let stream;
|
2473
|
-
if (rt.isBrowser) {
|
2474
|
-
stream = new ConsoleWriterStream();
|
2475
|
-
} else {
|
2476
|
-
if (rt.isNodeIsh || rt.isReactNative || rt.isDeno || rt.isCFWorker) {
|
2477
|
-
stream = this._sys.Stdout();
|
2478
|
-
} else {
|
2479
|
-
throw new Error("No output defined for runtime");
|
2480
|
-
}
|
2481
|
-
}
|
2482
|
-
this._logWriter = new LogWriterStream(stream);
|
2621
|
+
this._logWriter = new LogWriterStream(this._sys.Stdout());
|
2483
2622
|
} else {
|
2484
2623
|
this._logWriter = new LogWriterStream(params.out);
|
2485
2624
|
}
|
@@ -3659,7 +3798,9 @@ function UInt8ArrayEqual(a, b) {
|
|
3659
3798
|
}
|
3660
3799
|
// Annotate the CommonJS export names for ESM import in node:
|
3661
3800
|
0 && (module.exports = {
|
3801
|
+
BaseBasicSysAbstraction,
|
3662
3802
|
BaseSysAbstraction,
|
3803
|
+
BasicSysAbstractionFactory,
|
3663
3804
|
BuildURI,
|
3664
3805
|
ConstTime,
|
3665
3806
|
EnvImpl,
|
@@ -3708,7 +3849,8 @@ function UInt8ArrayEqual(a, b) {
|
|
3708
3849
|
TxtEnDecoderSingleton,
|
3709
3850
|
URI,
|
3710
3851
|
VERSION,
|
3711
|
-
|
3852
|
+
WrapperBasicSysAbstraction,
|
3853
|
+
WrapperRuntimeSysAbstraction,
|
3712
3854
|
YAMLFormatter,
|
3713
3855
|
asyncLogValue,
|
3714
3856
|
bin2string,
|