@adviser/cement 0.3.1 → 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 (138) 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 +393 -143
  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 +34 -1729
  30. package/index.js.map +1 -1
  31. package/node/index.cjs +265 -217
  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 +19 -113
  51. package/src/test/index.ts +2 -0
  52. package/src/web/web-sys-abstraction.ts +42 -2
  53. package/sys-abstraction-GNnBj2sz.d.cts +102 -0
  54. package/sys-abstraction-GNnBj2sz.d.ts +102 -0
  55. package/test/index.cjs +2681 -0
  56. package/test/index.cjs.map +1 -0
  57. package/test/index.d.cts +3 -0
  58. package/test/index.d.ts +3 -0
  59. package/test/index.js +14 -0
  60. package/test/index.js.map +1 -0
  61. package/ts/base-sys-abstraction.test.js +8 -2
  62. package/ts/base-sys-abstraction.test.js.map +1 -1
  63. package/ts/cf/cf-sys-abstraction.d.ts +24 -0
  64. package/ts/cf/cf-sys-abstraction.d.ts.map +1 -0
  65. package/ts/cf/cf-sys-abstraction.js +72 -0
  66. package/ts/cf/cf-sys-abstraction.js.map +1 -0
  67. package/ts/cf/index.d.ts +2 -0
  68. package/ts/cf/index.d.ts.map +1 -0
  69. package/ts/cf/index.js +2 -0
  70. package/ts/cf/index.js.map +1 -0
  71. package/ts/crypto.test.js +1 -1
  72. package/ts/crypto.test.js.map +1 -1
  73. package/ts/{node → deno}/deno-file-service.d.ts.map +1 -1
  74. package/ts/{node → deno}/deno-file-service.js +1 -1
  75. package/ts/{node → deno}/deno-file-service.js.map +1 -1
  76. package/ts/deno/deno-sys-abstraction.d.ts +43 -0
  77. package/ts/deno/deno-sys-abstraction.d.ts.map +1 -0
  78. package/ts/{node → deno}/deno-sys-abstraction.js +46 -2
  79. package/ts/deno/deno-sys-abstraction.js.map +1 -0
  80. package/ts/deno/index.d.ts +3 -0
  81. package/ts/deno/index.d.ts.map +1 -0
  82. package/ts/deno/index.js +3 -0
  83. package/ts/deno/index.js.map +1 -0
  84. package/ts/index.d.ts +1 -2
  85. package/ts/index.d.ts.map +1 -1
  86. package/ts/index.js +1 -2
  87. package/ts/index.js.map +1 -1
  88. package/ts/logger-impl.js +2 -2
  89. package/ts/logger-impl.js.map +1 -1
  90. package/ts/logger.d.ts.map +1 -1
  91. package/ts/logger.js +9 -3
  92. package/ts/logger.js.map +1 -1
  93. package/ts/logger.test.js +9 -9
  94. package/ts/logger.test.js.map +1 -1
  95. package/ts/node/index.d.ts +0 -1
  96. package/ts/node/index.d.ts.map +1 -1
  97. package/ts/node/index.js +0 -1
  98. package/ts/node/index.js.map +1 -1
  99. package/ts/node/node-sys-abstraction.d.ts +14 -1
  100. package/ts/node/node-sys-abstraction.d.ts.map +1 -1
  101. package/ts/node/node-sys-abstraction.js +43 -0
  102. package/ts/node/node-sys-abstraction.js.map +1 -1
  103. package/ts/runtime.d.ts +1 -0
  104. package/ts/runtime.d.ts.map +1 -1
  105. package/ts/runtime.js +10 -3
  106. package/ts/runtime.js.map +1 -1
  107. package/ts/sys-env.d.ts +0 -11
  108. package/ts/sys-env.d.ts.map +1 -1
  109. package/ts/sys-env.js +19 -104
  110. package/ts/sys-env.js.map +1 -1
  111. package/ts/sys-env.test.js +16 -3
  112. package/ts/sys-env.test.js.map +1 -1
  113. package/ts/test/index.d.ts +3 -0
  114. package/ts/test/index.d.ts.map +1 -0
  115. package/ts/test/index.js +3 -0
  116. package/ts/test/index.js.map +1 -0
  117. package/ts/test/test-exit-handler.js +1 -1
  118. package/ts/web/web-sys-abstraction.d.ts +27 -0
  119. package/ts/web/web-sys-abstraction.d.ts.map +1 -1
  120. package/ts/web/web-sys-abstraction.js +35 -1
  121. package/ts/web/web-sys-abstraction.js.map +1 -1
  122. package/utils/index.js +6 -4
  123. package/web/index.cjs +389 -67
  124. package/web/index.cjs.map +1 -1
  125. package/web/index.d.cts +28 -2
  126. package/web/index.d.ts +28 -2
  127. package/web/index.js +5 -2
  128. package/base-sys-abstraction-BPFyK8XL.d.ts +0 -195
  129. package/base-sys-abstraction-KYXfUGd6.d.cts +0 -195
  130. package/chunk-3RHIVQAA.js.map +0 -1
  131. package/chunk-PSPOGR2I.js +0 -627
  132. package/chunk-PSPOGR2I.js.map +0 -1
  133. package/chunk-STUPETPE.js +0 -87
  134. package/chunk-STUPETPE.js.map +0 -1
  135. package/ts/node/deno-sys-abstraction.d.ts +0 -22
  136. package/ts/node/deno-sys-abstraction.d.ts.map +0 -1
  137. package/ts/node/deno-sys-abstraction.js.map +0 -1
  138. /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,24 +676,70 @@ var BrowserEnvActions = class {
539
676
  return env;
540
677
  }
541
678
  };
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
+ }
694
+ }
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
542
723
  var envActions = [
543
- { id: "node", fn: (opts) => new NodeEnvActions(opts) },
544
- { id: "deno", fn: (opts) => new DenoEnvActions(opts) },
545
- { id: "browser", fn: (opts) => new BrowserEnvActions(opts) }
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) }
546
728
  ];
547
- var _envFactory = new ResolveOnce();
729
+ var _envFactories = new KeyedResolvOnce();
548
730
  function envFactory(opts = {}) {
549
- return _envFactory.once(() => {
550
- const found = envActions.map((facItem) => facItem.fn(opts)).find((env) => env.active());
551
- if (!found) {
552
- throw new Error("SysContainer:envFactory: no env available");
553
- }
554
- const ret = new EnvImpl(found, opts);
555
- found.register(ret);
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);
556
739
  return ret;
557
740
  });
558
741
  }
559
- var EnvImpl = class {
742
+ var EnvImpl2 = class {
560
743
  constructor(map, opts = {}) {
561
744
  this._onSet = [];
562
745
  this._map = map;
@@ -626,6 +809,43 @@ var EnvImpl = class {
626
809
 
627
810
  // src/node/node-sys-abstraction.ts
628
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;
629
849
  var NodeExitServiceImpl = class {
630
850
  constructor() {
631
851
  this._exitHandlers = [];
@@ -718,176 +938,6 @@ function NodeSysAbstraction(param) {
718
938
  return new WrapperSysAbstraction(my, param);
719
939
  }
720
940
 
721
- // src/node/deno-sys-abstraction.ts
722
- var process3 = __toESM(require("process"), 1);
723
-
724
- // src/node/deno-file-service.ts
725
- var path2 = __toESM(require("path"), 1);
726
- var Deno = globalThis.Deno;
727
- var DenoFileService = class {
728
- constructor(baseDir = Deno.cwd(), txtEnde = Utf8EnDecoderSingleton()) {
729
- this.baseDir = this.abs(baseDir);
730
- this.txtEnde = txtEnde;
731
- }
732
- // nodeImport(fname: string): string {
733
- // // console.log('nodeImport:'+ fname);
734
- // if (path.isAbsolute(fname)) {
735
- // return fname;
736
- // } else {
737
- // return "./" + path.normalize(fname);
738
- // }
739
- // }
740
- async readFileString(fname) {
741
- return this.txtEnde.decode(await Deno.readFile(fname));
742
- }
743
- dirname(fname) {
744
- return path2.dirname(fname);
745
- }
746
- basename(fname) {
747
- return path2.basename(fname);
748
- }
749
- join(...paths) {
750
- return path2.join(...paths);
751
- }
752
- relative(from, to) {
753
- if (to === void 0) {
754
- to = from;
755
- from = Deno.cwd();
756
- }
757
- const ret = path2.relative(from, to);
758
- return ret;
759
- }
760
- abs(fname) {
761
- if (path2.isAbsolute(fname)) {
762
- return fname;
763
- } else {
764
- const cwd = Deno.cwd();
765
- return path2.resolve(cwd, fname);
766
- }
767
- }
768
- isAbsolute(fname) {
769
- return path2.isAbsolute(fname);
770
- }
771
- async writeFileString(fname, content, ende = Utf8EnDecoderSingleton()) {
772
- const o = await this.create(fname);
773
- const wr = o.stream.getWriter();
774
- await wr.write(ende.encode(content));
775
- await wr.close();
776
- }
777
- async create(fname) {
778
- let oName = fname;
779
- if (!path2.isAbsolute(fname)) {
780
- oName = this.abs(fname);
781
- }
782
- const base = path2.dirname(oName);
783
- await Deno.mkdir(base, { recursive: true });
784
- const out = await Deno.open(oName, {
785
- write: true,
786
- create: true,
787
- truncate: true
788
- });
789
- return {
790
- name: oName,
791
- stream: out
792
- };
793
- }
794
- };
795
-
796
- // src/node/deno-sys-abstraction.ts
797
- var Deno2 = globalThis.Deno;
798
- var DenoExitServiceImpl = class {
799
- constructor() {
800
- this._exitHandlers = [];
801
- this.invoked = false;
802
- this._handleExit = async () => {
803
- if (this.invoked) {
804
- return;
805
- }
806
- this.invoked = true;
807
- for (const h of this._exitHandlers) {
808
- try {
809
- const ret = h.hdl();
810
- if (typeof ret.then === "function") {
811
- await ret;
812
- }
813
- } finally {
814
- }
815
- }
816
- };
817
- globalThis.addEventListener("unhandledrejection", (e) => {
818
- e.preventDefault();
819
- this.exit(19);
820
- });
821
- globalThis.addEventListener("error", () => {
822
- this.exit(19);
823
- });
824
- globalThis.addEventListener("uncaughtException", () => {
825
- this.exit(19);
826
- });
827
- globalThis.addEventListener("unload", () => {
828
- this.exit(0);
829
- });
830
- Deno2.addSignalListener("SIGQUIT", () => {
831
- this.exit(3);
832
- });
833
- Deno2.addSignalListener("SIGINT", () => {
834
- this.exit(2);
835
- });
836
- Deno2.addSignalListener("SIGTERM", () => {
837
- this.exit(9);
838
- });
839
- }
840
- injectExitHandlers(hdls) {
841
- this._exitHandlers = hdls;
842
- }
843
- exit(code) {
844
- this._handleExit().then(() => {
845
- Deno2.exit(code);
846
- }).catch((err) => {
847
- console.error("ExitService: failed to handle exit", err);
848
- Deno2.exit(code);
849
- });
850
- }
851
- };
852
- var _DenoSystemService = class _DenoSystemService {
853
- constructor() {
854
- this._exitService = new DenoExitServiceImpl();
855
- this._exitService.injectExitHandlers(_DenoSystemService._exitHandlers);
856
- }
857
- Env() {
858
- return envFactory();
859
- }
860
- Args() {
861
- return process3.argv;
862
- }
863
- OnExit(hdl) {
864
- const id = crypto.randomUUID();
865
- _DenoSystemService._exitHandlers.push({ hdl, id });
866
- return () => {
867
- const idx = _DenoSystemService._exitHandlers.findIndex((h) => h.id === id);
868
- if (idx >= 0) {
869
- _DenoSystemService._exitHandlers.splice(idx, 1);
870
- }
871
- };
872
- }
873
- Exit(code) {
874
- this._exitService.exit(code);
875
- }
876
- };
877
- _DenoSystemService._exitHandlers = [];
878
- var DenoSystemService = _DenoSystemService;
879
- var my2 = void 0;
880
- function DenoSysAbstraction(param) {
881
- if (!my2) {
882
- my2 = new BaseSysAbstraction({
883
- TxtEnDecoder: (param == null ? void 0 : param.TxtEnDecoder) || Utf8EnDecoderSingleton(),
884
- FileSystem: new DenoFileService(),
885
- SystemService: new DenoSystemService()
886
- });
887
- }
888
- return new WrapperSysAbstraction(my2, param);
889
- }
890
-
891
941
  // src/node/mock-file-service.ts
892
942
  var MockFileService = class extends NodeFileService {
893
943
  constructor() {
@@ -926,10 +976,8 @@ var MockFileService = class extends NodeFileService {
926
976
  };
927
977
  // Annotate the CommonJS export names for ESM import in node:
928
978
  0 && (module.exports = {
929
- DenoExitServiceImpl,
930
- DenoSysAbstraction,
931
- DenoSystemService,
932
979
  MockFileService,
980
+ NodeEnvActions,
933
981
  NodeExitServiceImpl,
934
982
  NodeFileService,
935
983
  NodeSysAbstraction,