@adviser/cement 0.3.1 → 0.3.3

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 +936 -0
  4. package/cf/index.cjs.map +1 -0
  5. package/cf/index.d.cts +27 -0
  6. package/cf/index.d.ts +27 -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-HFP74WLI.js +96 -0
  12. package/chunk-HFP74WLI.js.map +1 -0
  13. package/chunk-P6LDM7PY.js +1189 -0
  14. package/chunk-P6LDM7PY.js.map +1 -0
  15. package/chunk-PRCFKZR7.js +1742 -0
  16. package/chunk-PRCFKZR7.js.map +1 -0
  17. package/deno/index.cjs +947 -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 +400 -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 +272 -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 +86 -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 +2688 -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 +25 -0
  64. package/ts/cf/cf-sys-abstraction.d.ts.map +1 -0
  65. package/ts/cf/cf-sys-abstraction.js +80 -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 +396 -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/web/index.cjs CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __typeError = (msg) => {
7
9
  throw TypeError(msg);
@@ -18,6 +20,14 @@ var __copyProps = (to, from, except, desc) => {
18
20
  }
19
21
  return to;
20
22
  };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
21
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
32
  var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
23
33
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
@@ -27,6 +37,8 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
27
37
  // src/web/index.ts
28
38
  var web_exports = {};
29
39
  __export(web_exports, {
40
+ BrowserEnvActions: () => BrowserEnvActions,
41
+ WebFileService: () => WebFileService,
30
42
  WebSysAbstraction: () => WebSysAbstraction
31
43
  });
32
44
  module.exports = __toCommonJS(web_exports);
@@ -45,9 +57,9 @@ var SysTime = class extends Time {
45
57
  return /* @__PURE__ */ new Date();
46
58
  }
47
59
  Sleep(duration) {
48
- return new Promise((resolve) => {
60
+ return new Promise((resolve2) => {
49
61
  setTimeout(() => {
50
- resolve();
62
+ resolve2();
51
63
  }, duration);
52
64
  });
53
65
  }
@@ -237,8 +249,8 @@ var Future = class {
237
249
  __privateAdd(this, _rejectFn, () => {
238
250
  throw new Error("This Promise is not working as expected.");
239
251
  });
240
- __privateSet(this, _promise, new Promise((resolve, reject) => {
241
- __privateSet(this, _resolveFn, resolve);
252
+ __privateSet(this, _promise, new Promise((resolve2, reject) => {
253
+ __privateSet(this, _resolveFn, resolve2);
242
254
  __privateSet(this, _rejectFn, reject);
243
255
  }));
244
256
  }
@@ -335,54 +347,121 @@ var ResolveOnce = class {
335
347
  }
336
348
  }
337
349
  };
338
-
339
- // src/sys-env.ts
340
- var _node;
341
- var NodeEnvActions = class {
342
- // eslint-disable-next-line @typescript-eslint/no-useless-constructor, @typescript-eslint/no-unused-vars
343
- constructor(opts) {
344
- __privateAdd(this, _node, globalThis);
345
- this._env = this.active() ? __privateGet(this, _node).process.env : {};
350
+ var Keyed = class {
351
+ constructor(factory) {
352
+ this._map = /* @__PURE__ */ new Map();
353
+ this.factory = factory;
346
354
  }
347
- register(env) {
348
- return env;
355
+ async asyncGet(key) {
356
+ return this.get(await key());
349
357
  }
350
- active() {
351
- return typeof __privateGet(this, _node) === "object" && typeof __privateGet(this, _node).process === "object" && typeof __privateGet(this, _node).process.env === "object";
358
+ get(key) {
359
+ if (typeof key === "function") {
360
+ key = key();
361
+ }
362
+ let keyed = this._map.get(key);
363
+ if (!keyed) {
364
+ keyed = this.factory(key);
365
+ this._map.set(key, keyed);
366
+ }
367
+ return keyed;
352
368
  }
353
- keys() {
354
- return Object.keys(this._env);
369
+ unget(key) {
370
+ const keyed = this._map.get(key);
371
+ keyed == null ? void 0 : keyed.reset();
372
+ this._map.delete(key);
355
373
  }
356
- get(key) {
357
- return this._env[key];
374
+ reset() {
375
+ this._map.forEach((keyed) => keyed.reset());
376
+ this._map.clear();
358
377
  }
359
- set(key, value) {
360
- if (value) {
361
- this._env[key] = value;
378
+ };
379
+ var KeyedResolvOnce = class extends Keyed {
380
+ constructor() {
381
+ super((key) => new ResolveOnce(key));
382
+ }
383
+ };
384
+
385
+ // src/runtime.ts
386
+ function isSet(value, ref = globalThis) {
387
+ const [head, ...tail] = value.split(".");
388
+ if (["object", "function"].includes(typeof ref) && ref && ["object", "function"].includes(typeof ref[head]) && ref[head]) {
389
+ if (tail.length <= 1) {
390
+ return true;
362
391
  }
392
+ return isSet(tail.join("."), ref[head]);
363
393
  }
364
- delete(key) {
365
- delete this._env[key];
394
+ return false;
395
+ }
396
+ function runtimeFn() {
397
+ const gt = globalThis;
398
+ let isReactNative = isSet("navigator.product") && typeof gt["navigator"] === "object" && gt["navigator"]["product"] === "ReactNative";
399
+ let isNodeIsh = false;
400
+ if (!isSet("Deno")) {
401
+ isNodeIsh = isSet("process.versions.node") && !isReactNative;
402
+ }
403
+ let isDeno = isSet("Deno");
404
+ const isCFWorker = isSet("caches.default") && isSet("WebSocketPair");
405
+ if (isCFWorker) {
406
+ isDeno = false;
407
+ isNodeIsh = false;
408
+ isReactNative = false;
409
+ }
410
+ return {
411
+ isNodeIsh,
412
+ isBrowser: !(isNodeIsh || isDeno || isCFWorker || isReactNative),
413
+ isDeno,
414
+ isReactNative,
415
+ isCFWorker
416
+ };
417
+ }
418
+
419
+ // src/txt-en-decoder.ts
420
+ var encoder = new TextEncoder();
421
+ var decoder = new TextDecoder();
422
+ var Utf8EnDecoder = class {
423
+ encode(str) {
424
+ return encoder.encode(str);
425
+ }
426
+ decode(data) {
427
+ return decoder.decode(data);
366
428
  }
367
429
  };
368
- _node = new WeakMap();
430
+ var utf8EnDecoder = new Utf8EnDecoder();
431
+ function Utf8EnDecoderSingleton() {
432
+ return utf8EnDecoder;
433
+ }
434
+
435
+ // src/deno/deno-file-service.ts
436
+ var path = __toESM(require("path"), 1);
437
+ var Deno = globalThis.Deno;
438
+
439
+ // src/deno/deno-sys-abstraction.ts
440
+ var Deno2 = globalThis.Deno;
441
+ var once = new ResolveOnce();
369
442
  var _deno;
370
- var DenoEnvActions = class {
371
- // eslint-disable-next-line @typescript-eslint/no-useless-constructor, @typescript-eslint/no-unused-vars
443
+ var _DenoEnvActions = class _DenoEnvActions {
372
444
  constructor(opts) {
373
445
  __privateAdd(this, _deno, globalThis);
446
+ this.opts = opts;
447
+ }
448
+ static new(opts) {
449
+ return once.once(() => new _DenoEnvActions(opts));
374
450
  }
375
451
  get _env() {
376
452
  return __privateGet(this, _deno).Deno.env;
377
453
  }
378
454
  register(env) {
455
+ for (const key of env.keys()) {
456
+ this._env.set(key, env.get(key) || "");
457
+ }
379
458
  return env;
380
459
  }
381
460
  active() {
382
- return typeof __privateGet(this, _deno) === "object" && typeof __privateGet(this, _deno).Deno === "object" && typeof __privateGet(this, _deno).Deno.env === "object";
461
+ return runtimeFn().isDeno;
383
462
  }
384
463
  keys() {
385
- return Array.from(this._env.keys());
464
+ return Object.keys(this._env.toObject());
386
465
  }
387
466
  get(key) {
388
467
  return this._env.get(key);
@@ -397,53 +476,284 @@ var DenoEnvActions = class {
397
476
  }
398
477
  };
399
478
  _deno = new WeakMap();
400
- var BrowserEnvActions = class {
479
+ var DenoEnvActions = _DenoEnvActions;
480
+ var DenoExitServiceImpl = class {
481
+ constructor() {
482
+ this._exitHandlers = [];
483
+ this.invoked = false;
484
+ this._handleExit = async () => {
485
+ if (this.invoked) {
486
+ return;
487
+ }
488
+ this.invoked = true;
489
+ for (const h of this._exitHandlers) {
490
+ try {
491
+ const ret = h.hdl();
492
+ if (typeof ret.then === "function") {
493
+ await ret;
494
+ }
495
+ } finally {
496
+ }
497
+ }
498
+ };
499
+ globalThis.addEventListener("unhandledrejection", (e) => {
500
+ e.preventDefault();
501
+ this.exit(19);
502
+ });
503
+ globalThis.addEventListener("error", () => {
504
+ this.exit(19);
505
+ });
506
+ globalThis.addEventListener("uncaughtException", () => {
507
+ this.exit(19);
508
+ });
509
+ globalThis.addEventListener("unload", () => {
510
+ this.exit(0);
511
+ });
512
+ Deno2.addSignalListener("SIGQUIT", () => {
513
+ this.exit(3);
514
+ });
515
+ Deno2.addSignalListener("SIGINT", () => {
516
+ this.exit(2);
517
+ });
518
+ Deno2.addSignalListener("SIGTERM", () => {
519
+ this.exit(9);
520
+ });
521
+ }
522
+ injectExitHandlers(hdls) {
523
+ this._exitHandlers = hdls;
524
+ }
525
+ exit(code) {
526
+ this._handleExit().then(() => {
527
+ Deno2.exit(code);
528
+ }).catch((err) => {
529
+ console.error("ExitService: failed to handle exit", err);
530
+ Deno2.exit(code);
531
+ });
532
+ }
533
+ };
534
+ var _DenoSystemService = class _DenoSystemService {
535
+ constructor() {
536
+ this._exitService = new DenoExitServiceImpl();
537
+ this._exitService.injectExitHandlers(_DenoSystemService._exitHandlers);
538
+ }
539
+ Env() {
540
+ return envFactory();
541
+ }
542
+ Args() {
543
+ return Deno2.args;
544
+ }
545
+ OnExit(hdl) {
546
+ const id = crypto.randomUUID();
547
+ _DenoSystemService._exitHandlers.push({ hdl, id });
548
+ return () => {
549
+ const idx = _DenoSystemService._exitHandlers.findIndex((h) => h.id === id);
550
+ if (idx >= 0) {
551
+ _DenoSystemService._exitHandlers.splice(idx, 1);
552
+ }
553
+ };
554
+ }
555
+ Exit(code) {
556
+ this._exitService.exit(code);
557
+ }
558
+ };
559
+ _DenoSystemService._exitHandlers = [];
560
+ var DenoSystemService = _DenoSystemService;
561
+
562
+ // src/node/node-file-service.ts
563
+ var import_node_path = __toESM(require("path"), 1);
564
+ var import_node_fs = __toESM(require("fs"), 1);
565
+ var import_node_process = __toESM(require("process"), 1);
566
+
567
+ // src/node/node-sys-abstraction.ts
568
+ var import_node_process2 = __toESM(require("process"), 1);
569
+ var once2 = new ResolveOnce();
570
+ var _node;
571
+ var _NodeEnvActions = class _NodeEnvActions {
401
572
  constructor(opts) {
402
- this.env = /* @__PURE__ */ new Map();
573
+ __privateAdd(this, _node, globalThis);
574
+ this._env = this.active() ? __privateGet(this, _node).process.env : {};
403
575
  this.opts = opts;
404
576
  }
577
+ static new(opts) {
578
+ return once2.once(() => new _NodeEnvActions(opts));
579
+ }
580
+ register(env) {
581
+ for (const key of env.keys()) {
582
+ this._env[key] = env.get(key) || "";
583
+ }
584
+ return env;
585
+ }
586
+ active() {
587
+ return runtimeFn().isNodeIsh;
588
+ }
589
+ keys() {
590
+ return Object.keys(this._env);
591
+ }
405
592
  get(key) {
406
- return this.env.get(key);
593
+ return this._env[key];
407
594
  }
408
595
  set(key, value) {
409
596
  if (value) {
410
- this.env.set(key, value);
597
+ this._env[key] = value;
411
598
  }
412
599
  }
413
600
  delete(key) {
414
- this.env.delete(key);
601
+ delete this._env[key];
415
602
  }
416
- keys() {
417
- return Array.from(this.env.keys());
603
+ };
604
+ _node = new WeakMap();
605
+ var NodeEnvActions = _NodeEnvActions;
606
+ var NodeExitServiceImpl = class {
607
+ constructor() {
608
+ this._exitHandlers = [];
609
+ this.invoked = false;
610
+ this._handleExit = async () => {
611
+ if (this.invoked) {
612
+ return;
613
+ }
614
+ this.invoked = true;
615
+ for (const h of this._exitHandlers) {
616
+ try {
617
+ const ret = h.hdl();
618
+ if (typeof ret.then === "function") {
619
+ await ret;
620
+ }
621
+ } finally {
622
+ }
623
+ }
624
+ };
625
+ import_node_process2.default.on("unhandledRejection", (reason, p) => {
626
+ this.exit(19);
627
+ });
628
+ import_node_process2.default.on("uncaughtException", (error) => {
629
+ this.exit(18);
630
+ });
631
+ import_node_process2.default.on("close", () => {
632
+ this.exit(0);
633
+ });
634
+ import_node_process2.default.on("exit", () => {
635
+ this.exit(0);
636
+ });
637
+ import_node_process2.default.on("SIGQUIT", () => {
638
+ this.exit(3);
639
+ });
640
+ import_node_process2.default.on("SIGINT", () => {
641
+ this.exit(2);
642
+ });
643
+ import_node_process2.default.on("SIGTERM", () => {
644
+ this.exit(9);
645
+ });
646
+ }
647
+ injectExitHandlers(hdls) {
648
+ this._exitHandlers = hdls;
649
+ }
650
+ exit(code) {
651
+ this._handleExit().then(() => {
652
+ import_node_process2.default.exit(code);
653
+ }).catch((err) => {
654
+ console.error("ExitService: failed to handle exit", err);
655
+ import_node_process2.default.exit(code);
656
+ });
657
+ }
658
+ };
659
+ var _NodeSystemService = class _NodeSystemService {
660
+ constructor() {
661
+ this._exitService = new NodeExitServiceImpl();
662
+ this._exitService.injectExitHandlers(_NodeSystemService._exitHandlers);
663
+ }
664
+ Env() {
665
+ return envFactory();
666
+ }
667
+ Args() {
668
+ return import_node_process2.default.argv;
669
+ }
670
+ OnExit(hdl) {
671
+ const id = crypto.randomUUID();
672
+ _NodeSystemService._exitHandlers.push({ hdl, id });
673
+ return () => {
674
+ const idx = _NodeSystemService._exitHandlers.findIndex((h) => h.id === id);
675
+ if (idx >= 0) {
676
+ _NodeSystemService._exitHandlers.splice(idx, 1);
677
+ }
678
+ };
679
+ }
680
+ Exit(code) {
681
+ this._exitService.exit(code);
682
+ }
683
+ };
684
+ _NodeSystemService._exitHandlers = [];
685
+ var NodeSystemService = _NodeSystemService;
686
+
687
+ // src/cf/cf-sys-abstraction.ts
688
+ var once3 = new ResolveOnce();
689
+ var CFEnvActions = class _CFEnvActions {
690
+ constructor(env) {
691
+ this.injectOnRegister = {};
692
+ this.cfEnv = new Map(Object.entries(env.presetEnv || {}));
693
+ }
694
+ static new(opts) {
695
+ return once3.once(() => new _CFEnvActions(opts));
696
+ }
697
+ static inject(o) {
698
+ const env = _CFEnvActions.new({});
699
+ for (const key in o) {
700
+ const value = o[key];
701
+ if (typeof value === "string") {
702
+ if (env.env) {
703
+ env.env.set(key, value);
704
+ } else {
705
+ env.injectOnRegister[key] = value;
706
+ }
707
+ }
708
+ }
418
709
  }
419
710
  active() {
420
- return true;
711
+ return runtimeFn().isCFWorker;
421
712
  }
422
713
  register(env) {
423
- const sym = Symbol.for(this.opts.symbol || "CP_ENV");
424
- const browser = globalThis;
425
- browser[sym] = env;
714
+ this.env = env;
715
+ for (const key in this.injectOnRegister) {
716
+ env.set(key, this.injectOnRegister[key]);
717
+ }
426
718
  return env;
427
719
  }
720
+ get(key) {
721
+ return this.cfEnv.get(key);
722
+ }
723
+ set(key, value) {
724
+ if (value) {
725
+ this.cfEnv.set(key, value);
726
+ }
727
+ }
728
+ delete(key) {
729
+ this.cfEnv.delete(key);
730
+ }
731
+ keys() {
732
+ return Array.from(this.cfEnv.keys());
733
+ }
428
734
  };
735
+
736
+ // src/sys-env.ts
429
737
  var envActions = [
430
- { id: "node", fn: (opts) => new NodeEnvActions(opts) },
431
- { id: "deno", fn: (opts) => new DenoEnvActions(opts) },
432
- { id: "browser", fn: (opts) => new BrowserEnvActions(opts) }
738
+ { id: "cf", fn: (opts) => CFEnvActions.new(opts) },
739
+ { id: "node", fn: (opts) => NodeEnvActions.new(opts) },
740
+ { id: "deno", fn: (opts) => DenoEnvActions.new(opts) },
741
+ { id: "browser", fn: (opts) => BrowserEnvActions.new(opts) }
433
742
  ];
434
- var _envFactory = new ResolveOnce();
743
+ var _envFactories = new KeyedResolvOnce();
435
744
  function envFactory(opts = {}) {
436
- return _envFactory.once(() => {
437
- const found = envActions.map((facItem) => facItem.fn(opts)).find((env) => env.active());
438
- if (!found) {
439
- throw new Error("SysContainer:envFactory: no env available");
440
- }
441
- const ret = new EnvImpl(found, opts);
442
- found.register(ret);
745
+ const found = envActions.find((fi) => fi.fn(opts).active());
746
+ if (!found) {
747
+ throw new Error("SysContainer:envFactory: no env available");
748
+ }
749
+ return _envFactories.get(found.id).once(() => {
750
+ const action = found.fn(opts);
751
+ const ret = new EnvImpl2(action, opts);
752
+ action.register(ret);
443
753
  return ret;
444
754
  });
445
755
  }
446
- var EnvImpl = class {
756
+ var EnvImpl2 = class {
447
757
  constructor(map, opts = {}) {
448
758
  this._onSet = [];
449
759
  this._map = map;
@@ -511,23 +821,40 @@ var EnvImpl = class {
511
821
  }
512
822
  };
513
823
 
514
- // src/txt-en-decoder.ts
515
- var encoder = new TextEncoder();
516
- var decoder = new TextDecoder();
517
- var Utf8EnDecoder = class {
518
- encode(str) {
519
- return encoder.encode(str);
824
+ // src/web/web-sys-abstraction.ts
825
+ var once4 = new ResolveOnce();
826
+ var BrowserEnvActions = class _BrowserEnvActions {
827
+ constructor(opts) {
828
+ this.env = /* @__PURE__ */ new Map();
829
+ this.opts = opts;
520
830
  }
521
- decode(data) {
522
- return decoder.decode(data);
831
+ static new(opts) {
832
+ return once4.once(() => new _BrowserEnvActions(opts));
833
+ }
834
+ get(key) {
835
+ return this.env.get(key);
836
+ }
837
+ set(key, value) {
838
+ if (value) {
839
+ this.env.set(key, value);
840
+ }
841
+ }
842
+ delete(key) {
843
+ this.env.delete(key);
844
+ }
845
+ keys() {
846
+ return Array.from(this.env.keys());
847
+ }
848
+ active() {
849
+ return true;
850
+ }
851
+ register(env) {
852
+ const sym = Symbol.for(this.opts.symbol || "CP_ENV");
853
+ const browser = globalThis;
854
+ browser[sym] = env;
855
+ return env;
523
856
  }
524
857
  };
525
- var utf8EnDecoder = new Utf8EnDecoder();
526
- function Utf8EnDecoderSingleton() {
527
- return utf8EnDecoder;
528
- }
529
-
530
- // src/web/web-sys-abstraction.ts
531
858
  var WebFileService = class {
532
859
  get baseDir() {
533
860
  throw new Error("basedir-Method not implemented.");
@@ -602,6 +929,8 @@ function WebSysAbstraction(param) {
602
929
  }
603
930
  // Annotate the CommonJS export names for ESM import in node:
604
931
  0 && (module.exports = {
932
+ BrowserEnvActions,
933
+ WebFileService,
605
934
  WebSysAbstraction
606
935
  });
607
936
  //# sourceMappingURL=index.cjs.map