@adviser/cement 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/base-sys-abstraction-CR_Z-Ceg.d.ts +84 -0
  2. package/base-sys-abstraction-DWtPI7Kg.d.cts +84 -0
  3. package/cf/index.cjs +929 -0
  4. package/cf/index.cjs.map +1 -0
  5. package/cf/index.d.cts +26 -0
  6. package/cf/index.d.ts +26 -0
  7. package/cf/index.js +12 -0
  8. package/cf/index.js.map +1 -0
  9. package/{chunk-3RHIVQAA.js → chunk-A7OPSHUV.js} +6 -94
  10. package/chunk-A7OPSHUV.js.map +1 -0
  11. package/chunk-DZPKZQIT.js +1182 -0
  12. package/chunk-DZPKZQIT.js.map +1 -0
  13. package/chunk-HFP74WLI.js +96 -0
  14. package/chunk-HFP74WLI.js.map +1 -0
  15. package/chunk-R2EEZNZN.js +1742 -0
  16. package/chunk-R2EEZNZN.js.map +1 -0
  17. package/deno/index.cjs +940 -0
  18. package/deno/index.cjs.map +1 -0
  19. package/deno/index.d.cts +59 -0
  20. package/deno/index.d.ts +59 -0
  21. package/deno/index.js +16 -0
  22. package/deno/index.js.map +1 -0
  23. package/index-BfZxTAe_.d.cts +318 -0
  24. package/index-CfSl8Gmj.d.ts +318 -0
  25. package/index.cjs +407 -139
  26. package/index.cjs.map +1 -1
  27. package/index.d.cts +7 -317
  28. package/index.d.ts +7 -317
  29. package/index.js +36 -1729
  30. package/index.js.map +1 -1
  31. package/node/index.cjs +267 -214
  32. package/node/index.cjs.map +1 -1
  33. package/node/index.d.cts +16 -21
  34. package/node/index.d.ts +16 -21
  35. package/node/index.js +8 -352
  36. package/node/index.js.map +1 -1
  37. package/package.json +18 -11
  38. package/src/cf/cf-sys-abstraction.ts +78 -0
  39. package/src/cf/index.ts +1 -0
  40. package/src/{node → deno}/deno-file-service.ts +2 -2
  41. package/src/{node → deno}/deno-sys-abstraction.ts +64 -7
  42. package/src/deno/index.ts +2 -0
  43. package/src/index.ts +1 -2
  44. package/src/jsr.json +1 -1
  45. package/src/logger-impl.ts +2 -2
  46. package/src/logger.ts +10 -3
  47. package/src/node/index.ts +0 -1
  48. package/src/node/node-sys-abstraction.ts +45 -1
  49. package/src/runtime.ts +13 -3
  50. package/src/sys-env.ts +36 -109
  51. package/src/test/index.ts +2 -0
  52. package/src/uri.ts +2 -2
  53. package/src/web/web-sys-abstraction.ts +42 -2
  54. package/sys-abstraction-GNnBj2sz.d.cts +102 -0
  55. package/sys-abstraction-GNnBj2sz.d.ts +102 -0
  56. package/test/index.cjs +2681 -0
  57. package/test/index.cjs.map +1 -0
  58. package/test/index.d.cts +3 -0
  59. package/test/index.d.ts +3 -0
  60. package/test/index.js +14 -0
  61. package/test/index.js.map +1 -0
  62. package/ts/base-sys-abstraction.test.js +8 -2
  63. package/ts/base-sys-abstraction.test.js.map +1 -1
  64. package/ts/cf/cf-sys-abstraction.d.ts +24 -0
  65. package/ts/cf/cf-sys-abstraction.d.ts.map +1 -0
  66. package/ts/cf/cf-sys-abstraction.js +72 -0
  67. package/ts/cf/cf-sys-abstraction.js.map +1 -0
  68. package/ts/cf/index.d.ts +2 -0
  69. package/ts/cf/index.d.ts.map +1 -0
  70. package/ts/cf/index.js +2 -0
  71. package/ts/cf/index.js.map +1 -0
  72. package/ts/crypto.test.js +1 -1
  73. package/ts/crypto.test.js.map +1 -1
  74. package/ts/{node → deno}/deno-file-service.d.ts.map +1 -1
  75. package/ts/{node → deno}/deno-file-service.js +1 -1
  76. package/ts/{node → deno}/deno-file-service.js.map +1 -1
  77. package/ts/deno/deno-sys-abstraction.d.ts +43 -0
  78. package/ts/deno/deno-sys-abstraction.d.ts.map +1 -0
  79. package/ts/{node → deno}/deno-sys-abstraction.js +46 -2
  80. package/ts/deno/deno-sys-abstraction.js.map +1 -0
  81. package/ts/deno/index.d.ts +3 -0
  82. package/ts/deno/index.d.ts.map +1 -0
  83. package/ts/deno/index.js +3 -0
  84. package/ts/deno/index.js.map +1 -0
  85. package/ts/index.d.ts +1 -2
  86. package/ts/index.d.ts.map +1 -1
  87. package/ts/index.js +1 -2
  88. package/ts/index.js.map +1 -1
  89. package/ts/logger-impl.js +2 -2
  90. package/ts/logger-impl.js.map +1 -1
  91. package/ts/logger.d.ts.map +1 -1
  92. package/ts/logger.js +9 -3
  93. package/ts/logger.js.map +1 -1
  94. package/ts/logger.test.js +9 -9
  95. package/ts/logger.test.js.map +1 -1
  96. package/ts/node/index.d.ts +0 -1
  97. package/ts/node/index.d.ts.map +1 -1
  98. package/ts/node/index.js +0 -1
  99. package/ts/node/index.js.map +1 -1
  100. package/ts/node/node-sys-abstraction.d.ts +14 -1
  101. package/ts/node/node-sys-abstraction.d.ts.map +1 -1
  102. package/ts/node/node-sys-abstraction.js +43 -0
  103. package/ts/node/node-sys-abstraction.js.map +1 -1
  104. package/ts/runtime.d.ts +1 -0
  105. package/ts/runtime.d.ts.map +1 -1
  106. package/ts/runtime.js +10 -3
  107. package/ts/runtime.js.map +1 -1
  108. package/ts/sys-env.d.ts +2 -11
  109. package/ts/sys-env.d.ts.map +1 -1
  110. package/ts/sys-env.js +29 -98
  111. package/ts/sys-env.js.map +1 -1
  112. package/ts/sys-env.test.js +68 -3
  113. package/ts/sys-env.test.js.map +1 -1
  114. package/ts/test/index.d.ts +3 -0
  115. package/ts/test/index.d.ts.map +1 -0
  116. package/ts/test/index.js +3 -0
  117. package/ts/test/index.js.map +1 -0
  118. package/ts/test/test-exit-handler.js +1 -1
  119. package/ts/uri.d.ts +2 -2
  120. package/ts/uri.d.ts.map +1 -1
  121. package/ts/web/web-sys-abstraction.d.ts +27 -0
  122. package/ts/web/web-sys-abstraction.d.ts.map +1 -1
  123. package/ts/web/web-sys-abstraction.js +35 -1
  124. package/ts/web/web-sys-abstraction.js.map +1 -1
  125. package/utils/index.js +6 -4
  126. package/web/index.cjs +391 -64
  127. package/web/index.cjs.map +1 -1
  128. package/web/index.d.cts +28 -2
  129. package/web/index.d.ts +28 -2
  130. package/web/index.js +5 -2
  131. package/base-sys-abstraction-BkEiLHl0.d.ts +0 -193
  132. package/base-sys-abstraction-Qj7pkY1N.d.cts +0 -193
  133. package/chunk-3RHIVQAA.js.map +0 -1
  134. package/chunk-N3NUTN4B.js +0 -87
  135. package/chunk-N3NUTN4B.js.map +0 -1
  136. package/chunk-N5LQQXOU.js +0 -610
  137. package/chunk-N5LQQXOU.js.map +0 -1
  138. package/ts/node/deno-sys-abstraction.d.ts +0 -22
  139. package/ts/node/deno-sys-abstraction.d.ts.map +0 -1
  140. package/ts/node/deno-sys-abstraction.js.map +0 -1
  141. /package/ts/{node → deno}/deno-file-service.d.ts +0 -0
package/node/index.cjs CHANGED
@@ -37,10 +37,8 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
37
37
  // src/node/index.ts
38
38
  var node_exports = {};
39
39
  __export(node_exports, {
40
- DenoExitServiceImpl: () => DenoExitServiceImpl,
41
- DenoSysAbstraction: () => DenoSysAbstraction,
42
- DenoSystemService: () => DenoSystemService,
43
40
  MockFileService: () => MockFileService,
41
+ NodeEnvActions: () => NodeEnvActions,
44
42
  NodeExitServiceImpl: () => NodeExitServiceImpl,
45
43
  NodeFileService: () => NodeFileService,
46
44
  NodeSysAbstraction: () => NodeSysAbstraction,
@@ -448,54 +446,105 @@ var ResolveOnce = class {
448
446
  }
449
447
  }
450
448
  };
451
-
452
- // src/sys-env.ts
453
- var _node;
454
- var NodeEnvActions = class {
455
- // eslint-disable-next-line @typescript-eslint/no-useless-constructor, @typescript-eslint/no-unused-vars
456
- constructor(opts) {
457
- __privateAdd(this, _node, globalThis);
458
- this._env = this.active() ? __privateGet(this, _node).process.env : {};
459
- }
460
- register(env) {
461
- return env;
462
- }
463
- active() {
464
- return typeof __privateGet(this, _node) === "object" && typeof __privateGet(this, _node).process === "object" && typeof __privateGet(this, _node).process.env === "object";
449
+ var Keyed = class {
450
+ constructor(factory) {
451
+ this._map = /* @__PURE__ */ new Map();
452
+ this.factory = factory;
465
453
  }
466
- keys() {
467
- return Object.keys(this._env);
454
+ async asyncGet(key) {
455
+ return this.get(await key());
468
456
  }
469
457
  get(key) {
470
- return this._env[key];
471
- }
472
- set(key, value) {
473
- if (value) {
474
- this._env[key] = value;
458
+ if (typeof key === "function") {
459
+ key = key();
475
460
  }
461
+ let keyed = this._map.get(key);
462
+ if (!keyed) {
463
+ keyed = this.factory(key);
464
+ this._map.set(key, keyed);
465
+ }
466
+ return keyed;
476
467
  }
477
- delete(key) {
478
- delete this._env[key];
468
+ unget(key) {
469
+ const keyed = this._map.get(key);
470
+ keyed == null ? void 0 : keyed.reset();
471
+ this._map.delete(key);
472
+ }
473
+ reset() {
474
+ this._map.forEach((keyed) => keyed.reset());
475
+ this._map.clear();
479
476
  }
480
477
  };
481
- _node = new WeakMap();
478
+ var KeyedResolvOnce = class extends Keyed {
479
+ constructor() {
480
+ super((key) => new ResolveOnce(key));
481
+ }
482
+ };
483
+
484
+ // src/runtime.ts
485
+ function isSet(value, ref = globalThis) {
486
+ const [head, ...tail] = value.split(".");
487
+ if (["object", "function"].includes(typeof ref) && ref && ["object", "function"].includes(typeof ref[head]) && ref[head]) {
488
+ if (tail.length <= 1) {
489
+ return true;
490
+ }
491
+ return isSet(tail.join("."), ref[head]);
492
+ }
493
+ return false;
494
+ }
495
+ function runtimeFn() {
496
+ const gt = globalThis;
497
+ let isReactNative = isSet("navigator.product") && typeof gt["navigator"] === "object" && gt["navigator"]["product"] === "ReactNative";
498
+ let isNodeIsh = false;
499
+ if (!isSet("Deno")) {
500
+ isNodeIsh = isSet("process.versions.node") && !isReactNative;
501
+ }
502
+ let isDeno = isSet("Deno");
503
+ const isCFWorker = isSet("caches.default") && isSet("WebSocketPair");
504
+ if (isCFWorker) {
505
+ isDeno = false;
506
+ isNodeIsh = false;
507
+ isReactNative = false;
508
+ }
509
+ return {
510
+ isNodeIsh,
511
+ isBrowser: !(isNodeIsh || isDeno || isCFWorker || isReactNative),
512
+ isDeno,
513
+ isReactNative,
514
+ isCFWorker
515
+ };
516
+ }
517
+
518
+ // src/deno/deno-file-service.ts
519
+ var path2 = __toESM(require("path"), 1);
520
+ var Deno = globalThis.Deno;
521
+
522
+ // src/deno/deno-sys-abstraction.ts
523
+ var Deno2 = globalThis.Deno;
524
+ var once = new ResolveOnce();
482
525
  var _deno;
483
- var DenoEnvActions = class {
484
- // eslint-disable-next-line @typescript-eslint/no-useless-constructor, @typescript-eslint/no-unused-vars
526
+ var _DenoEnvActions = class _DenoEnvActions {
485
527
  constructor(opts) {
486
528
  __privateAdd(this, _deno, globalThis);
529
+ this.opts = opts;
530
+ }
531
+ static new(opts) {
532
+ return once.once(() => new _DenoEnvActions(opts));
487
533
  }
488
534
  get _env() {
489
535
  return __privateGet(this, _deno).Deno.env;
490
536
  }
491
537
  register(env) {
538
+ for (const key of env.keys()) {
539
+ this._env.set(key, env.get(key) || "");
540
+ }
492
541
  return env;
493
542
  }
494
543
  active() {
495
- return typeof __privateGet(this, _deno) === "object" && typeof __privateGet(this, _deno).Deno === "object" && typeof __privateGet(this, _deno).Deno.env === "object";
544
+ return runtimeFn().isDeno;
496
545
  }
497
546
  keys() {
498
- return Array.from(this._env.keys());
547
+ return Object.keys(this._env.toObject());
499
548
  }
500
549
  get(key) {
501
550
  return this._env.get(key);
@@ -510,11 +559,99 @@ var DenoEnvActions = class {
510
559
  }
511
560
  };
512
561
  _deno = new WeakMap();
513
- var BrowserEnvActions = class {
562
+ var DenoEnvActions = _DenoEnvActions;
563
+ var DenoExitServiceImpl = class {
564
+ constructor() {
565
+ this._exitHandlers = [];
566
+ this.invoked = false;
567
+ this._handleExit = async () => {
568
+ if (this.invoked) {
569
+ return;
570
+ }
571
+ this.invoked = true;
572
+ for (const h of this._exitHandlers) {
573
+ try {
574
+ const ret = h.hdl();
575
+ if (typeof ret.then === "function") {
576
+ await ret;
577
+ }
578
+ } finally {
579
+ }
580
+ }
581
+ };
582
+ globalThis.addEventListener("unhandledrejection", (e) => {
583
+ e.preventDefault();
584
+ this.exit(19);
585
+ });
586
+ globalThis.addEventListener("error", () => {
587
+ this.exit(19);
588
+ });
589
+ globalThis.addEventListener("uncaughtException", () => {
590
+ this.exit(19);
591
+ });
592
+ globalThis.addEventListener("unload", () => {
593
+ this.exit(0);
594
+ });
595
+ Deno2.addSignalListener("SIGQUIT", () => {
596
+ this.exit(3);
597
+ });
598
+ Deno2.addSignalListener("SIGINT", () => {
599
+ this.exit(2);
600
+ });
601
+ Deno2.addSignalListener("SIGTERM", () => {
602
+ this.exit(9);
603
+ });
604
+ }
605
+ injectExitHandlers(hdls) {
606
+ this._exitHandlers = hdls;
607
+ }
608
+ exit(code) {
609
+ this._handleExit().then(() => {
610
+ Deno2.exit(code);
611
+ }).catch((err) => {
612
+ console.error("ExitService: failed to handle exit", err);
613
+ Deno2.exit(code);
614
+ });
615
+ }
616
+ };
617
+ var _DenoSystemService = class _DenoSystemService {
618
+ constructor() {
619
+ this._exitService = new DenoExitServiceImpl();
620
+ this._exitService.injectExitHandlers(_DenoSystemService._exitHandlers);
621
+ }
622
+ Env() {
623
+ return envFactory();
624
+ }
625
+ Args() {
626
+ return Deno2.args;
627
+ }
628
+ OnExit(hdl) {
629
+ const id = crypto.randomUUID();
630
+ _DenoSystemService._exitHandlers.push({ hdl, id });
631
+ return () => {
632
+ const idx = _DenoSystemService._exitHandlers.findIndex((h) => h.id === id);
633
+ if (idx >= 0) {
634
+ _DenoSystemService._exitHandlers.splice(idx, 1);
635
+ }
636
+ };
637
+ }
638
+ Exit(code) {
639
+ this._exitService.exit(code);
640
+ }
641
+ };
642
+ _DenoSystemService._exitHandlers = [];
643
+ var DenoSystemService = _DenoSystemService;
644
+
645
+ // src/web/web-sys-abstraction.ts
646
+ var once2 = new ResolveOnce();
647
+ var BrowserEnvActions = class _BrowserEnvActions {
514
648
  constructor(opts) {
515
649
  this.env = /* @__PURE__ */ new Map();
516
650
  this.opts = opts;
517
651
  }
652
+ static new(opts) {
653
+ return once2.once(() => new _BrowserEnvActions(opts));
654
+ }
518
655
  get(key) {
519
656
  return this.env.get(key);
520
657
  }
@@ -539,19 +676,70 @@ var BrowserEnvActions = class {
539
676
  return env;
540
677
  }
541
678
  };
542
- var _envFactory = new ResolveOnce();
543
- function envFactory(opts = {}) {
544
- return _envFactory.once(() => {
545
- const found = [new NodeEnvActions(opts), new DenoEnvActions(opts), new BrowserEnvActions(opts)].find((env) => env.active());
546
- if (!found) {
547
- throw new Error("SysContainer:envFactory: no env available");
679
+
680
+ // src/cf/cf-sys-abstraction.ts
681
+ var once3 = new ResolveOnce();
682
+ var CFEnvActions = class _CFEnvActions {
683
+ static new(opts) {
684
+ return once3.once(() => new _CFEnvActions(opts));
685
+ }
686
+ static inject(o) {
687
+ var _a;
688
+ const env = _CFEnvActions.new({});
689
+ for (const key in o) {
690
+ const value = o[key];
691
+ if (typeof value === "string") {
692
+ (_a = env.env) == null ? void 0 : _a.set(key, value);
693
+ }
548
694
  }
549
- const ret = new EnvImpl(found, opts);
550
- found.register(ret);
695
+ }
696
+ constructor(env) {
697
+ this.cfEnv = new Map(Object.entries(env.presetEnv || {}));
698
+ }
699
+ active() {
700
+ return runtimeFn().isCFWorker;
701
+ }
702
+ register(env) {
703
+ this.env = env;
704
+ return env;
705
+ }
706
+ get(key) {
707
+ return this.cfEnv.get(key);
708
+ }
709
+ set(key, value) {
710
+ if (value) {
711
+ this.cfEnv.set(key, value);
712
+ }
713
+ }
714
+ delete(key) {
715
+ this.cfEnv.delete(key);
716
+ }
717
+ keys() {
718
+ return Array.from(this.cfEnv.keys());
719
+ }
720
+ };
721
+
722
+ // src/sys-env.ts
723
+ var envActions = [
724
+ { id: "cf", fn: (opts) => CFEnvActions.new(opts) },
725
+ { id: "node", fn: (opts) => NodeEnvActions.new(opts) },
726
+ { id: "deno", fn: (opts) => DenoEnvActions.new(opts) },
727
+ { id: "browser", fn: (opts) => BrowserEnvActions.new(opts) }
728
+ ];
729
+ var _envFactories = new KeyedResolvOnce();
730
+ function envFactory(opts = {}) {
731
+ const found = envActions.find((fi) => fi.fn(opts).active());
732
+ if (!found) {
733
+ throw new Error("SysContainer:envFactory: no env available");
734
+ }
735
+ return _envFactories.get(found.id).once(() => {
736
+ const action = found.fn(opts);
737
+ const ret = new EnvImpl2(action, opts);
738
+ action.register(ret);
551
739
  return ret;
552
740
  });
553
741
  }
554
- var EnvImpl = class {
742
+ var EnvImpl2 = class {
555
743
  constructor(map, opts = {}) {
556
744
  this._onSet = [];
557
745
  this._map = map;
@@ -621,6 +809,43 @@ var EnvImpl = class {
621
809
 
622
810
  // src/node/node-sys-abstraction.ts
623
811
  var import_node_process2 = __toESM(require("process"), 1);
812
+ var once4 = new ResolveOnce();
813
+ var _node;
814
+ var _NodeEnvActions = class _NodeEnvActions {
815
+ constructor(opts) {
816
+ __privateAdd(this, _node, globalThis);
817
+ this._env = this.active() ? __privateGet(this, _node).process.env : {};
818
+ this.opts = opts;
819
+ }
820
+ static new(opts) {
821
+ return once4.once(() => new _NodeEnvActions(opts));
822
+ }
823
+ register(env) {
824
+ for (const key of env.keys()) {
825
+ this._env[key] = env.get(key) || "";
826
+ }
827
+ return env;
828
+ }
829
+ active() {
830
+ return runtimeFn().isNodeIsh;
831
+ }
832
+ keys() {
833
+ return Object.keys(this._env);
834
+ }
835
+ get(key) {
836
+ return this._env[key];
837
+ }
838
+ set(key, value) {
839
+ if (value) {
840
+ this._env[key] = value;
841
+ }
842
+ }
843
+ delete(key) {
844
+ delete this._env[key];
845
+ }
846
+ };
847
+ _node = new WeakMap();
848
+ var NodeEnvActions = _NodeEnvActions;
624
849
  var NodeExitServiceImpl = class {
625
850
  constructor() {
626
851
  this._exitHandlers = [];
@@ -713,176 +938,6 @@ function NodeSysAbstraction(param) {
713
938
  return new WrapperSysAbstraction(my, param);
714
939
  }
715
940
 
716
- // src/node/deno-sys-abstraction.ts
717
- var process3 = __toESM(require("process"), 1);
718
-
719
- // src/node/deno-file-service.ts
720
- var path2 = __toESM(require("path"), 1);
721
- var Deno = globalThis.Deno;
722
- var DenoFileService = class {
723
- constructor(baseDir = Deno.cwd(), txtEnde = Utf8EnDecoderSingleton()) {
724
- this.baseDir = this.abs(baseDir);
725
- this.txtEnde = txtEnde;
726
- }
727
- // nodeImport(fname: string): string {
728
- // // console.log('nodeImport:'+ fname);
729
- // if (path.isAbsolute(fname)) {
730
- // return fname;
731
- // } else {
732
- // return "./" + path.normalize(fname);
733
- // }
734
- // }
735
- async readFileString(fname) {
736
- return this.txtEnde.decode(await Deno.readFile(fname));
737
- }
738
- dirname(fname) {
739
- return path2.dirname(fname);
740
- }
741
- basename(fname) {
742
- return path2.basename(fname);
743
- }
744
- join(...paths) {
745
- return path2.join(...paths);
746
- }
747
- relative(from, to) {
748
- if (to === void 0) {
749
- to = from;
750
- from = Deno.cwd();
751
- }
752
- const ret = path2.relative(from, to);
753
- return ret;
754
- }
755
- abs(fname) {
756
- if (path2.isAbsolute(fname)) {
757
- return fname;
758
- } else {
759
- const cwd = Deno.cwd();
760
- return path2.resolve(cwd, fname);
761
- }
762
- }
763
- isAbsolute(fname) {
764
- return path2.isAbsolute(fname);
765
- }
766
- async writeFileString(fname, content, ende = Utf8EnDecoderSingleton()) {
767
- const o = await this.create(fname);
768
- const wr = o.stream.getWriter();
769
- await wr.write(ende.encode(content));
770
- await wr.close();
771
- }
772
- async create(fname) {
773
- let oName = fname;
774
- if (!path2.isAbsolute(fname)) {
775
- oName = this.abs(fname);
776
- }
777
- const base = path2.dirname(oName);
778
- await Deno.mkdir(base, { recursive: true });
779
- const out = await Deno.open(oName, {
780
- write: true,
781
- create: true,
782
- truncate: true
783
- });
784
- return {
785
- name: oName,
786
- stream: out
787
- };
788
- }
789
- };
790
-
791
- // src/node/deno-sys-abstraction.ts
792
- var Deno2 = globalThis.Deno;
793
- var DenoExitServiceImpl = class {
794
- constructor() {
795
- this._exitHandlers = [];
796
- this.invoked = false;
797
- this._handleExit = async () => {
798
- if (this.invoked) {
799
- return;
800
- }
801
- this.invoked = true;
802
- for (const h of this._exitHandlers) {
803
- try {
804
- const ret = h.hdl();
805
- if (typeof ret.then === "function") {
806
- await ret;
807
- }
808
- } finally {
809
- }
810
- }
811
- };
812
- globalThis.addEventListener("unhandledrejection", (e) => {
813
- e.preventDefault();
814
- this.exit(19);
815
- });
816
- globalThis.addEventListener("error", () => {
817
- this.exit(19);
818
- });
819
- globalThis.addEventListener("uncaughtException", () => {
820
- this.exit(19);
821
- });
822
- globalThis.addEventListener("unload", () => {
823
- this.exit(0);
824
- });
825
- Deno2.addSignalListener("SIGQUIT", () => {
826
- this.exit(3);
827
- });
828
- Deno2.addSignalListener("SIGINT", () => {
829
- this.exit(2);
830
- });
831
- Deno2.addSignalListener("SIGTERM", () => {
832
- this.exit(9);
833
- });
834
- }
835
- injectExitHandlers(hdls) {
836
- this._exitHandlers = hdls;
837
- }
838
- exit(code) {
839
- this._handleExit().then(() => {
840
- Deno2.exit(code);
841
- }).catch((err) => {
842
- console.error("ExitService: failed to handle exit", err);
843
- Deno2.exit(code);
844
- });
845
- }
846
- };
847
- var _DenoSystemService = class _DenoSystemService {
848
- constructor() {
849
- this._exitService = new DenoExitServiceImpl();
850
- this._exitService.injectExitHandlers(_DenoSystemService._exitHandlers);
851
- }
852
- Env() {
853
- return envFactory();
854
- }
855
- Args() {
856
- return process3.argv;
857
- }
858
- OnExit(hdl) {
859
- const id = crypto.randomUUID();
860
- _DenoSystemService._exitHandlers.push({ hdl, id });
861
- return () => {
862
- const idx = _DenoSystemService._exitHandlers.findIndex((h) => h.id === id);
863
- if (idx >= 0) {
864
- _DenoSystemService._exitHandlers.splice(idx, 1);
865
- }
866
- };
867
- }
868
- Exit(code) {
869
- this._exitService.exit(code);
870
- }
871
- };
872
- _DenoSystemService._exitHandlers = [];
873
- var DenoSystemService = _DenoSystemService;
874
- var my2 = void 0;
875
- function DenoSysAbstraction(param) {
876
- if (!my2) {
877
- my2 = new BaseSysAbstraction({
878
- TxtEnDecoder: (param == null ? void 0 : param.TxtEnDecoder) || Utf8EnDecoderSingleton(),
879
- FileSystem: new DenoFileService(),
880
- SystemService: new DenoSystemService()
881
- });
882
- }
883
- return new WrapperSysAbstraction(my2, param);
884
- }
885
-
886
941
  // src/node/mock-file-service.ts
887
942
  var MockFileService = class extends NodeFileService {
888
943
  constructor() {
@@ -921,10 +976,8 @@ var MockFileService = class extends NodeFileService {
921
976
  };
922
977
  // Annotate the CommonJS export names for ESM import in node:
923
978
  0 && (module.exports = {
924
- DenoExitServiceImpl,
925
- DenoSysAbstraction,
926
- DenoSystemService,
927
979
  MockFileService,
980
+ NodeEnvActions,
928
981
  NodeExitServiceImpl,
929
982
  NodeFileService,
930
983
  NodeSysAbstraction,